fix(sight): guard tool_call name against empty-string overwrite in SSE delta merge#1303
Open
jfeng18 wants to merge 2 commits into
Open
fix(sight): guard tool_call name against empty-string overwrite in SSE delta merge#1303jfeng18 wants to merge 2 commits into
jfeng18 wants to merge 2 commits into
Conversation
…E delta merge DashScope/Qwen-compatible gateways resend function.name as an explicit empty string on continuation chunks rather than omitting the key. The existing id field already had an !is_empty() guard (added in alibaba#1133); mirror it onto name so a later empty-string chunk no longer clobbers the real tool name captured on the first chunk. Without this fix any Bash tool_call arriving via an OpenAI-compatible streaming backend is stored with name="" which makes is_bash_tool() return false, silently hiding it from the correlator and downstream ToolUse consumers.
DashScope/Qwen gateways sometimes omit function.name from ALL SSE delta chunks for a tool_call (not just later chunks). The previous commit's empty-string guard handles the "overwrite" case but cannot help when no chunk ever carries the name. Add a post-merge recovery step in build_llm_call: after assembling the response, scan output_messages for empty-name ToolCalls and back-fill from the request's tools array — single tool defined → unconditional, multiple tools → match by comparing argument keys against each tool's parameters.properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
idempty-string guard ontonameinextract_parts_from_sse_bodySSE tool_call delta mergingProblem
DashScope/Qwen-compatible gateways resend
function.nameas an explicit empty string ("") on continuation SSE chunks, rather than omitting the key. Theidfield already had an!is_empty()guard (added in #1133), butnamedid not — so a later chunk'sname:""clobbers the real tool name captured on the first chunk.This causes
is_bash_tool("")to returnfalsefor every Bash tool_call arriving via an OpenAI-compatible streaming backend, silently hiding it from the correlator and downstream ToolUse consumers.Evidence
"name":""on every continuation chunkname:""in genai_events for all tool_callsTest plan
test_extract_parts_from_sse_body_tool_calls_empty_name_does_not_overwrite— fails without fix, passes with fixtest_extract_parts_from_sse_body_tool_calls(name-omitted pattern) unaffectedcargo +1.89.0 test --lib— 973 passedcargo +1.89.0 fmt --check— cleancargo +1.89.0 clippy --all-targets -- -D warnings— clean🤖 Generated with Claude Code