Frameworks
Auto-instrumentation for agent frameworks.
Risicare instruments popular agent frameworks. The integrations do not all send the same spans. Read What Is Captured before you rely on a tool span.
Supported Frameworks
LangGraph
Graph-based agents
CrewAI
Multi-agent crews
AutoGen
Conversational agents
LangChain
Chains and agents
OpenAI Agents
OpenAI Agents SDK
Instructor
Structured outputs
LiteLLM
Unified LLM interface
DSPy
Declarative prompting
Pydantic AI
Type-safe AI
LlamaIndex
RAG framework
JavaScript SDK
The JS SDK supports 4 of the 10 frameworks above. The remaining 6 have no JavaScript integration in the Risicare SDK.
| Framework | JS Import | Function |
|---|---|---|
| LangChain | risicare/langchain | RisicareCallbackHandler + withSuppression() |
| LangGraph | risicare/langgraph | instrumentLangGraph() |
| Instructor | risicare/instructor | patchInstructor() |
| LlamaIndex | risicare/llamaindex | RisicareLlamaIndexHandler |
What Is Captured
The table says what the SDK sends for each framework. It comes from a test of a small agent that has one tool. The first call of the tool fails. The test used SDK 0.15.0. The versions are LangGraph 1.2.24, LangChain 1.5.2 (with langchain-classic 1.0.8), CrewAI 1.15.44, OpenAI Agents SDK 0.20.0 and DSPy 3.5.0. The cells that Python 0.16.0 changed follow the release notes of 0.16.0 (marked "since 0.16.0"). The test was not made again with 0.16.0.
| Framework | One trace per run | LLM spans | Tool spans | Failed tool marked | Agent name |
|---|---|---|---|---|---|
| LangGraph | Yes | Yes (langchain.chat/{model}) | Yes (langchain.tool/{name}), with input and output | Yes. The tool span, and the spans above it, are error | Yes. A graph that has a name gives its name. A graph with no name is the agent LangGraph (since 0.16.0) |
| LangChain | Yes. The root is langchain.chain/AgentExecutor | Yes (langchain.chat/{model}) | Yes (langchain.tool/{name}), with input and output | Yes, when the exception leaves the tool. Not when LangChain turns the exception into the output of the tool (handle_tool_error=True): the tool span is ok, and the error text is in tool.output | Yes, for the classic AgentExecutor: the agent AgentExecutor, a span of kind agent (since 0.16.0). For another chain, put the run in @agent(name=...) |
| CrewAI | Yes | Yes. They are the spans of the provider, with the role of the agent | Yes (crewai.tool/{name}), with input and output (since 0.16.0) | Yes. The tool span is error, also when CrewAI gives the error to the model as text and the run ends ok (since 0.16.0) | The role of the agent, on crewai.agent/{role} and on its LLM spans. The crew span has the name of the crew, often crew (since 0.16.0) |
| OpenAI Agents | Yes | Yes (openai.responses.create/{model}) | Yes, for a function tool (openai_agents.tool/{name}), with input and output (since 0.16.0). A hosted tool has no tool span | Yes. The tool span is error, also when the Agents SDK gives the error to the model as the output of the tool (since 0.16.0) | Yes, on the LLM spans: Agent.name of each turn, and the new agent after a handoff. The run span has the starting agent (since 0.16.0) |
| DSPy | Yes. One call of a program is one trace, with DSPy parents (since 0.16.0) | Yes (dspy.lm/{model}) | Yes (dspy.tool/{name}), with input and output (since 0.16.0) | Yes for the tool span. The dspy.module/ReAct span stays ok | Yes, for a ReAct module: the agent ReAct, a span of kind agent (since 0.16.0). Another module has none |
A failed tool of CrewAI or of the Agents SDK makes an error trace (it counts for the trace.error webhook), also when the run ends ok. An agent name that the SDK gives (LangGraph, AgentExecutor, ReAct, crew) is the name for every object that has no name. The SDK sets it only when no agent is current. The Agents page shows one agent for each name. Give each graph, crew or agent a name to tell them apart.
AutoGen, Instructor, LiteLLM, LlamaIndex and Pydantic AI are not in this test. Read their pages.
A model call that your own code makes with the OpenAI or Anthropic client is not in the table. For the tool functions of such an agent, see Trace your own tool function (Python) or Trace your own tool function in JavaScript.
The input and the output of a tool are in tool.input and tool.output. They are content: the SDK sends them only with content capture on.
The Agents SDK has a tool span for a function tool only. A hosted tool (web search, file search) runs at OpenAI and has no tool span. A handoff, and the computer, shell and apply-patch tools, have none.
Provider Span Behavior
Some frameworks suppress the provider span of a call that the framework itself makes, so the call is counted once. Others let provider spans appear alongside framework spans. A provider call that your own code makes outside a framework call keeps its span. LiteLLM, DSPy and LlamaIndex suppress every provider call made while their call runs (LiteLLM: on the same thread), not only their own.
| Framework | Provider Suppression | Notes |
|---|---|---|
| LangChain | Yes | The provider call of a model run gets no second span |
| LiteLLM | Yes | Suppressed from the pre-call hook to the end of the call |
| DSPy | Yes | Suppresses for LM calls |
| LlamaIndex | Yes | The provider span of an LLM or embedding call is suppressed, a streamed LLM call too |
| LangGraph | No | A node that calls a LangChain model gets no provider span (the LangChain rule); a direct provider call does |
| CrewAI | No | Provider spans appear as children |
| AutoGen | No | Provider spans appear as children |
| OpenAI Agents | No | Provider spans appear as children, for the Responses API (the default of the Agents SDK) and for Chat Completions |
| Instructor | No | Provider spans appear as children |
| Pydantic AI | No | Provider spans appear as children, for models whose API the SDK traces (OpenAI: the Responses API and Chat Completions) |
Auto vs Manual Instrumentation
Auto-Instrumentation
Call risicare.init(), or use Tier 0 (import risicare with RISICARE_API_KEY and RISICARE_TRACING=true):
import risicare
risicare.init()
# Framework code is automatically traced
from langgraph.graph import StateGraph
# ... your agent codeThe order of your imports does not matter. risicare.init() (or import risicare with RISICARE_TRACING=true) traces a supported library that your program imported already, and one that it imports later with an import statement.
Manual Instrumentation
Add explicit context for more control:
from risicare import agent, trace_think, trace_decide, trace_act
@agent(name="researcher", role="specialist")
def research_agent(query: str):
@trace_think
def analyze():
return analyze_query(query)
@trace_decide
def plan():
return create_plan(analysis)
@trace_act
def execute():
return run_search(plan)
analysis = analyze()
plan = plan()
return execute()Framework Detection
Risicare automatically detects which frameworks are installed and instruments them:
import risicare
# Returns a dict keyed by module name; each value describes that
# module's instrumentation state
print(risicare.get_instrumented_modules())