Skip to main content
Install:

Usage

Returning metadata: {"model": ...} records which model produced each response, powering the Sovereignty & Portability breakdown in the report. This pattern works the same way for AgentExecutor-style agents: call agent.invoke(...) instead of chain.invoke(...) inside langchain_agent.

With tracing

Pass an AgentXCallbackHandler into chain.invoke(..., config={"callbacks": [handler]}) to get a full Execution Timeline per result. Unlike the raw-tracer pattern used for OpenAI/Anthropic, the handler’s traces are always sent async, so trace_id isn’t available directly from it. Capture it by additionally wrapping the call in a sync=True span, the same way the Anthropic example does:
If you only want tracing (not evaluation), see the LangChain tracing integration: pass AgentXCallbackHandler on its own with no surrounding span, and every chain invocation is traced automatically.
A complete working example is available as langchain_eval.py in the AgentX-Python repository.