Avatar for the langchain-ai user
langchain-ai
langchain
Instrumentation
Wall Time
BlogDocsChangelog

fix(langchain): prevent index desync causing `invalid_tool_calls`

#32581
Comparing
AyhamJo7:fix/responses-stream-invalid_tool_calls-32562
(
548d07d
) with
master
(
2d0713c
)
CodSpeed Performance Gauge
0%
Improvements
0
Regressions
0
Untouched
14
New
0
Dropped
0
Ignored
0

Benchmarks

Passed

test_stream_time
libs/partners/anthropic/tests/integration_tests/test_standard.py::TestAnthropicStandard::test_stream_time
CodSpeed Performance Gauge
0%
37.5 ms
37.4 ms
test_init_time
libs/partners/anthropic/tests/unit_tests/test_standard.py::TestAnthropicStandard::test_init_time
CodSpeed Performance Gauge
0%
3.8 ms
3.8 ms
test_init_time
libs/partners/mistralai/tests/unit_tests/test_standard.py::TestMistralStandard::test_init_time
CodSpeed Performance Gauge
0%
12.5 ms
12.5 ms
test_init_time
libs/partners/deepseek/tests/unit_tests/test_chat_models.py::TestChatDeepSeekUnit::test_init_time
CodSpeed Performance Gauge
0%
1.6 s
1.6 s
test_init_time
libs/partners/fireworks/tests/unit_tests/test_standard.py::TestFireworksStandard::test_init_time
CodSpeed Performance Gauge
0%
6.6 s
6.6 s
test_init_time
libs/partners/xai/tests/unit_tests/test_chat_models_standard.py::TestXAIStandard::test_init_time
CodSpeed Performance Gauge
0%
3.3 s
3.3 s
test_init_time
libs/partners/groq/tests/unit_tests/test_standard.py::TestGroqStandard::test_init_time
CodSpeed Performance Gauge
0%
1.6 s
1.6 s
test_init_time
libs/partners/openai/tests/unit_tests/chat_models/test_azure_standard.py::TestOpenAIStandard::test_init_time
CodSpeed Performance Gauge
0%
1.7 s
1.7 s
test_stream_time
libs/partners/openai/tests/integration_tests/chat_models/test_responses_standard.py::TestOpenAIStandard::test_stream_time
CodSpeed Performance Gauge
0%
1.1 s
1.1 s
test_stream_time
libs/partners/openai/tests/integration_tests/chat_models/test_base_standard.py::TestOpenAIStandard::test_stream_time
CodSpeed Performance Gauge
0%
1.1 s
1.1 s
test_stream_time
libs/partners/openai/tests/integration_tests/chat_models/test_responses_standard.py::TestOpenAIResponses::test_stream_time
CodSpeed Performance Gauge
0%
935.5 ms
936.7 ms
test_init_time
libs/partners/openai/tests/unit_tests/chat_models/test_responses_standard.py::TestOpenAIResponses::test_init_time
CodSpeed Performance Gauge
0%
17.1 ms
17.2 ms
test_init_time_with_client
libs/partners/anthropic/tests/unit_tests/test_standard.py::test_init_time_with_client
CodSpeed Performance Gauge
0%
5.3 ms
5.3 ms
test_init_time
libs/partners/openai/tests/unit_tests/chat_models/test_base_standard.py::TestOpenAIStandard::test_init_time
CodSpeed Performance Gauge
-1%
17.1 ms
17.2 ms

Commits

Click on a commit to change the comparison range
Base
master
2d0713c
0%
fix(langchain): prevent index desync causing invalid_tool_calls (#32562) This fixes issue #32562 where response.output_text.annotation.added events were advancing the sub-index, causing function_call_arguments.delta chunks to get different indices and leading to invalid_tool_calls in OpenAI responses. **Root Cause:** The annotation event handler called _advance(output_index, content_index) with sub_idx, while function call argument deltas called _advance(output_index) without sub_idx. This caused current_index to increment mid-tool-call when annotations were interleaved with function arguments. **Fix:** Change annotation event to call _advance(output_index) without sub_idx, treating annotations as metadata on existing content rather than new blocks. **Tests:** - Added regression test test_tool_call_args_with_annotation_index_consistency - Verifies tool call chunks maintain consistent indices - Confirms invalid_tool_calls remains empty - Ensures complete tool call argument reconstruction 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
8bdd6eb
8 days ago
by AyhamJo7
0%
Merge branch 'master' into fix/responses-stream-invalid_tool_calls-32562
548d07d
19 hours ago
by AyhamJo7
© 2025 CodSpeed Technology
Home Terms Privacy Docs