Choose a setup method
Start with one method for a call path. Combining SDK tracking with framework
OpenTelemetry on the same call can create duplicate interactions.
Recommended: Agnost AI skill
Recommended. Choose this path when you want your coding agent to inspect the
project, select a supported transport, make the smallest instrumentation change,
send a test event, and verify that it reached Agnost AI.
Manual setup: Agnost AI SDK
agnost.shutdown() once when the application exits, not after each request.
Shutting down per request disables telemetry for later agent runs in the same process.
Manual setup: OpenTelemetry
CAMEL-AI has no OpenTelemetry export of its own. Its built-in tracing hooks target AgentOps, Langfuse, and TraceRoot. CAMEL calls each model provider through that provider’s Python SDK, so instrument the SDK instead. This guide uses Claude through the OpenInference Anthropic instrumentation. For OpenAI models, swap inopeninference-instrumentation-openai and OpenAIInstrumentor. Add an OpenInference decorator to each tool function, and wrap each turn in one span that carries the user’s message and the agent’s answer.
1. Install
camel-ai 0.2.90, anthropic 1.17.0, mcp 1.30.0, openinference-instrumentation-anthropic 3.3.9, and opentelemetry-sdk 1.45.2 on Python 3.12.
The two pins keep camel-ai 0.2.90 importable and runnable. With mcp 2.x, import camel.agents fails on from mcp.server import FastMCP. With anthropic 2.x, CAMEL’s Anthropic token counter fails with TypeError: Cannot instantiate typing.Union. The instrumentation needs anthropic 1.8 or newer.
2. Point OpenTelemetry at Agnost AI and run an agent
TracerProviderfromopeninference.instrumentationis the OpenTelemetry SDK provider with OpenInference helpers added. Its tracers give you@tracer.toolandopeninference_span_kind.AnthropicInstrumentor().instrument()traces everymessages.createcall CAMEL makes, with input and output messages, tool calls, and token counts.@tracer.toolrecords each tool call with its arguments and result. It keeps the function’s name, signature, and docstring, soFunctionToolbuilds the same tool schema.using_attributes(user_id=..., session_id=...)writesuser.idandsession.idonto every OpenInference span inside the block. Every turn with the samesession_idlands in the same Agnost AI conversation.- The
agent_turnspan becomes the root of each trace. Agnost AI builds the conversation transcript from each trace’s root span, so the wrapper holds the plain user message and the final answer. model_config_dict={"max_tokens": 1024}is required for Anthropic models in CAMEL. Without it, CAMEL sendsmax_tokens: nulland Anthropic rejects the request.
TracerProvider and call instrument() once at startup, call run_turn per request, and call provider.shutdown() on graceful shutdown.
What appears in Agnost AI
- Conversations: one per
session_id. Agnost AI keeps the raw session ID asoriginal_conversation_idin the conversation metadata. - Users: the
user_idyou pass tousing_attributes. - Messages: the user’s message and the agent’s answer for each turn, from the
agent_turnspan. - Events: the turn (
agent), eachmessages.createcall (llm) with the model name, messages, and token counts, and each tool call (tool) with arguments and result. CAMEL counts context tokens through Anthropic’s token counting API, so each step also shows amessages.count_tokensevent.
Verify
Run the script, wait up to a minute for ingestion, then open Conversations in Agnost AI. Confirm the conversation shows youruser_id, a user message and an assistant answer, two messages.create events, and a get_order_status tool event with arguments and a result.
Troubleshooting
- Nothing arrives: confirm the exporter’s headers contain
X-Agnost-Org-ID, and that the script callsprovider.shutdown()orprovider.force_flush()before it exits.BatchSpanProcessorexports in the background. - The log says
AnthropicInstrumentor only instruments "anthropic >= 1.8.0": an olderanthropicis installed, so no model spans are created. Install"anthropic>=1.8,<2". ImportError: cannot import name 'FastMCP' from 'mcp.server': install"mcp<2".TypeError: Cannot instantiate typing.Unionon the first step:anthropic2.x is installed. Install"anthropic>=1.8,<2".- No tool events: decorate each tool function with
@tracer.toolbefore passing it toFunctionTool. - User or conversation is missing: call
agent.step()inside theusing_attributesblock. - Each model call appears twice: set
ANTHROPIC_OPEN_TELEMETRY=falsebefore CAMEL creates the model.
References
- OpenInference Anthropic instrumentation
- OpenInference tracing helpers
- CAMEL-AI models
- CAMEL-AI agent tracking with AgentOps
Next steps
- Conversations: review the complete CAMEL-AI session.
- Events: inspect model and tool activity.
- Patterns: organize production conversations by what users wanted.