AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Trace=False In Agent Model Node Prevents Callback Setup, Breaking Observability

The agent model node in langchain/agents/factory.py uses trace=False, which bypasses callback setup in RunnableCallable.ainvoke(). This silently prevents on_llm_start and other callbacks from firing for internal LLM calls, breaking integrations like Langfuse and OpenTelemetry.

highConfidence 98%LangchainMemoryRetrievers

Origin Analysis

In RunnableCallable.ainvoke(), the trace parameter controls whether callback manager setup and on_llm_start are invoked. When trace=False, the code skips the callback manager configuration and directly calls the wrapped function, so any callbacks passed via the config are never propagated to the underlying model invocation.
Run the provided minimal example: create a RunnableCallable with trace=False and pass a callback handler via config; observe that on_llm_start is not called. Alternatively, use create_react_agent with a mock model and a callback handler, then invoke the agent and verify that on_llm_start is missing.

Fixing Code Block

Edge Case Audit

This fix is safe and non-breaking. However, if any downstream code relies on trace=False to suppress callback propagation intentionally (unlikely), it may re-enable callbacks. Roll back by setting trace=False again. No concurrency or version-specific issues are anticipated.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state