Skip to main content

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. 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.
Install the skill once in your coding-agent environment:
Run the framework-specific prompt below from the application root. Review the resulting diff before deploying it.

Manual setup: Agnost AI SDK

Call 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 in openinference-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

Tested with 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

What each piece does:
  • TracerProvider from openinference.instrumentation is the OpenTelemetry SDK provider with OpenInference helpers added. Its tracers give you @tracer.tool and openinference_span_kind.
  • AnthropicInstrumentor().instrument() traces every messages.create call CAMEL makes, with input and output messages, tool calls, and token counts.
  • @tracer.tool records each tool call with its arguments and result. It keeps the function’s name, signature, and docstring, so FunctionTool builds the same tool schema.
  • using_attributes(user_id=..., session_id=...) writes user.id and session.id onto every OpenInference span inside the block. Every turn with the same session_id lands in the same Agnost AI conversation.
  • The agent_turn span 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 sends max_tokens: null and Anthropic rejects the request.
In a long-running server, create the 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 as original_conversation_id in the conversation metadata.
  • Users: the user_id you pass to using_attributes.
  • Messages: the user’s message and the agent’s answer for each turn, from the agent_turn span.
  • Events: the turn (agent), each messages.create call (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 a messages.count_tokens event.

Verify

Run the script, wait up to a minute for ingestion, then open Conversations in Agnost AI. Confirm the conversation shows your user_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 calls provider.shutdown() or provider.force_flush() before it exits. BatchSpanProcessor exports in the background.
  • The log says AnthropicInstrumentor only instruments "anthropic >= 1.8.0": an older anthropic is 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.Union on the first step: anthropic 2.x is installed. Install "anthropic>=1.8,<2".
  • No tool events: decorate each tool function with @tracer.tool before passing it to FunctionTool.
  • User or conversation is missing: call agent.step() inside the using_attributes block.
  • Each model call appears twice: set ANTHROPIC_OPEN_TELEMETRY=false before CAMEL creates the model.

References

Next steps

  • Conversations: review the complete CAMEL-AI session.
  • Events: inspect model and tool activity.
  • Patterns: organize production conversations by what users wanted.