Before & After: Adding Identity OS¶
See exactly what changes in your code. Spoiler: it's not much.
LangGraph: 3 Lines Added¶
Before (no guardrails)¶
from langgraph.graph import StateGraph
graph = StateGraph(AgentState)
graph.add_node("agent", agent_node)
graph.add_node("tools", tool_node)
graph.add_edge("agent", "tools")
graph.add_edge("tools", "agent")
app = graph.compile()
result = app.invoke({"messages": [user_input]})
Problem: Agent can take any action. No behavioral constraints. No drift detection. Forbidden actions go straight through.
After (with Identity OS)¶
from langgraph.graph import StateGraph
from identity_os.integrations.langgraph import create_guard_node # ← NEW
client = IdentityOS(api_key="idos_sk_xxx") # ← NEW
guard = create_guard_node(client, instance_id) # ← NEW
graph = StateGraph(AgentState)
graph.add_node("identity_guard", guard) # ← NEW
graph.add_node("agent", agent_node)
graph.add_node("tools", tool_node)
graph.add_edge("identity_guard", "agent") # ← CHANGED
graph.add_edge("agent", "tools")
graph.add_edge("tools", "identity_guard") # ← CHANGED
app = graph.compile()
result = app.invoke({"messages": [user_input]})
What changed: 3 new lines, 2 edge changes. Every agent action now passes through Identity OS. Forbidden actions are blocked before reaching the LLM.
CrewAI: 2 Lines Added¶
Before¶
from crewai import Agent, Task, Crew
agent = Agent(
role="Research Assistant",
goal="Find relevant papers",
backstory="You are a meticulous researcher."
)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()
After¶
from crewai import Agent, Task, Crew
from identity_os.integrations.crewai import create_identity_callback # ← NEW
client = IdentityOS(api_key="idos_sk_xxx") # ← NEW
callback = create_identity_callback(client, instance_id) # ← NEW
agent = Agent(
role="Research Assistant",
goal="Find relevant papers",
backstory="You are a meticulous researcher.",
callbacks=[callback] # ← NEW
)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()
What changed: 3 new lines, 1 parameter added. Agent behavior is now constrained by ExecutionContract on every task step.
OpenAI Agents SDK: 1 Function Call¶
Before¶
from agents import Agent, Runner
agent = Agent(
name="Aria",
instructions="You are a helpful assistant.",
tools=[search_tool, calculate_tool]
)
result = Runner.run_sync(agent, "Help me plan my trip")
After¶
from agents import Runner
from identity_os.integrations.openai_agents import create_identity_agent # ← NEW
client = IdentityOS(api_key="idos_sk_xxx") # ← NEW
agent = create_identity_agent( # ← CHANGED
name="Aria",
instructions="You are a helpful assistant.",
tools=[search_tool, calculate_tool],
identity_client=client,
instance_id=instance_id
)
result = Runner.run_sync(agent, "Help me plan my trip")
What changed: Replace Agent() with create_identity_agent(). Input/output guardrails, tool wrapping, and stress detection are all automatic.
What You Get After Integration¶
Regardless of which framework you use, Identity OS adds:
| Capability | Without | With |
|---|---|---|
| Forbidden action blocking | ❌ Relies on prompt | ✅ Enforced at runtime |
| Behavioral drift detection | ❌ Invisible | ✅ D0–D3 classification, auto-rollback |
| Stress-adaptive constraints | ❌ Same rules always | ✅ Tightens under pressure, loosens on recovery |
| Audit trail | ❌ None | ✅ Every contract logged |
| Integration effort | — | 2–3 lines of code |