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

RunnableWithFallbacks.Invoke() Drops Parent_run_id For Child Callback Events

Regression in RunnableWithFallbacks.invoke() passes config instead of child_config to child runnables, causing child callback events to have parent_run_id=None, breaking tracing span trees.

highConfidence 95%Langchain-CoreRetrieverslangchain-coreAffected V1.2.19

Origin Analysis

In langchain_core/runnables/fallbacks.py line 196, the invoke method calls runnable.invoke with config instead of child_config inside the set_config_context block. Since child_config includes the child callback manager (run_manager.get_child()), the child runnable does not receive the parent run ID, leading to parent_run_id=None in callback events.
Use ChatOpenAI with fallbacks and a callback handler tracking parent_run_id. Invoke with config containing callbacks. Observe chat_model_start and llm_error events have parent_run_id=None instead of the chain run_id. See provided reproduction script.

Fixing Code Block

Edge Case Audit

The same issue likely affects ainvoke, batch, and abatch; ensure those paths also pass child_config. Test under concurrent invocation and callback managers to confirm thread-safety. Rollback: revert the one-line change if unexpected callback duplication or missing events occur. Also verify that fallback error callbacks still fire with correct run IDs.

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