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

AsyncBaseTracer Drops `Name` In `On_tool_start` And `Response` In `On_llm_error`, Diverging From `BaseTracer`

AsyncBaseTracer in langchain-core fails to forward the `name` argument to `_create_tool_run` and the `response` argument to `_errored_llm_run`, causing async tracers (including `with_alisteners`) to record incorrect run names and lose partial LLM outputs on streaming errors, unlike their sync counterparts.

highConfidence 95%LangchainAgentsVector Storeslangchain-coreAffected V1.6.3

Origin Analysis

In `AsyncBaseTracer.on_tool_start`, the explicit `name` parameter is not passed to `_create_tool_run`; in `AsyncBaseTracer.on_llm_error`, the `response` keyword argument is not extracted from `**kwargs` and forwarded to `_errored_llm_run`, while the equivalent `BaseTracer` methods correctly forward these arguments.
1. Define an async tracer subclass of `AsyncBaseTracer` that captures run names and error outputs. 2. Call `tool.with_alisteners(on_end=...)` with `run_name='renamed'`; observe async run name is the original function name ('add') instead of 'renamed'. 3. Stream a chat model that yields a partial chunk then raises; observe `on_llm_error` stores `run.outputs == {}` instead of containing `generations` with the partial output. 4. Compare with sync `BaseTracer` behavior, which correctly returns `'renamed'` and includes `generations`.

Fixing Code Block

Edge Case Audit

The fix is low-risk as it only adds previously omitted arguments. However, it changes the content of `run.outputs` on async LLM errors, which may affect downstream consumers that assumed empty outputs; this is the intended correct behavior. The change does not alter method signatures or return types, so custom subclasses should remain compatible. For rollback, revert to the prior version of `langchain-core` (e.g., 1.6.3) or remove the added `name=name` and `response=...` arguments. No concurrency-specific risks are introduced, but ensure any serialization of partial outputs handles potential larger payloads when streams fail late.

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