fix(model): normalize malformed streaming tool call fragments#1223
fix(model): normalize malformed streaming tool call fragments#1223Alexxigang wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Friendly ping when maintainers have time. The change is ready on my side, and I'm happy to make any follow-up adjustments if review feedback comes in. Thanks! |
|
Added targeted streaming edge-case coverage on top of this PR for missing-id first chunks, malformed complete JSON chunks, and thought-signature-only fragments. Validation:
|
|
The index field in the OpenAI streaming protocol is specifically designed to correlate multiple chunks of the same tool call. Wouldn't it be more appropriate to leverage this mechanism to address the issue? |
|
Friendly ping when maintainers have time. The branch is still ready on my side, including the added regression coverage, and I'm happy to make any follow-up adjustments if review feedback comes in. Thanks! |
|
Checked this against the current implementation before changing anything: The cases this PR is targeting are the ones where correlation alone still leaves us with a broken block:
So I agree |
|
Friendly follow-up on this one as well: the branch is still ready on my side with the regression coverage included, and I can adjust the implementation if you'd prefer a different direction around the streaming tool-call assembly path. |
|
PTAL @chickenlj |
Summary
}from becoming a new syntheticstreaming_tool callWhy this fix
Some OpenAI-compatible APIs can return the final argument fragment with
nameset even thoughidis null. The previous parser treated any non-empty name as a new tool call, generated a syntheticstreaming_id, and preventedToolCallsAccumulatorfrom merging the closing fragment back into the original call. The parser now recognizes that malformed named chunk as a fragment so the original call keeps complete JSON arguments.Validation
mvn -pl agentscope-core -Dtest=OpenAIChatFormatterTest,OpenAIStreamingToolCallTest,OpenAIResponseParserTest,ToolCallsAccumulatorTest,OpenAIChatModelTest test -qmvn -pl agentscope-core spotless:check -qFixes #1216