Skip to content

Conversation

@thromel
Copy link

@thromel thromel commented Dec 4, 2025

Summary

  • Pass tool_call_id to on_tool_start and on_tool_end callback handlers in BaseTool.run() and BaseTool.arun()
  • Add regression tests for both sync and async tool invocation

Why

When invoking a tool with a ToolCall input (which contains an id field), the tool_call_id was correctly extracted but never forwarded to callback handlers. This made it impossible for callbacks to correlate tool execution with the original LLM tool call.

Test plan

  • Added test_tool_call_id_passed_to_callbacks for sync invocation
  • Added test_tool_call_id_passed_to_async_callbacks for async invocation
  • All 148 existing tool tests pass

Fixes #34168

When invoking a tool with a ToolCall input, the tool_call_id was
correctly extracted but not forwarded to callback handlers. This
made it impossible for callbacks to correlate tool execution with
the original LLM tool call.

Fixes langchain-ai#34168
@thromel thromel requested a review from eyurtsev as a code owner December 4, 2025 08:12
@github-actions github-actions bot added core Related to the package `langchain-core` fix labels Dec 4, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 4, 2025

CodSpeed Performance Report

Merging #34201 will not alter performance

Comparing thromel:fix/tool-call-id-callbacks (d6106e3) with master (1867521)1

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched
⏩ 21 skipped2

Footnotes

  1. No successful run was found on master (b95cb77) during the generation of this report, so 1867521 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions github-actions bot added fix and removed fix labels Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Related to the package `langchain-core` fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tool_call_id not passed to on_tool_start callback in BaseTool.run()

1 participant