Preserve newline before leaked CONTENT_FILTER and make XML tool-call parsing more robust#210
Preserve newline before leaked CONTENT_FILTER and make XML tool-call parsing more robust#210CJackHwang wants to merge 1 commit intodevfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6878d81a75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if argsRaw := findMarkupTagValue(inner, toolCallMarkupArgsTagNames, toolCallMarkupArgsPatternByTag); strings.TrimSpace(argsRaw) != "" { | ||
| if parsed := parseToolCallInput(argsRaw); len(parsed) > 0 { | ||
| if !(len(parsed) == 1 && parsed["_raw"] != nil) { | ||
| return ParsedToolCall{ | ||
| Name: strings.TrimSpace(nameFromTags), | ||
| Input: parsed, | ||
| }, true |
There was a problem hiding this comment.
Defer early return until all XML arg tags are considered
This early return makes parseSingleXMLToolCall commit to a single argument block chosen by findMarkupTagValue priority, so mixed payloads like <parameters>{...}</parameters><arguments>{...}</arguments> now lose fields that the XML decoder previously merged. In that case the parser returns from the regex path with only one map and never reaches the decoder loop, which can change tool inputs and break calls that rely on keys from the skipped tag.
Useful? React with 👍 / 👎.
Motivation
CONTENT_FILTERmarkers after a newline.&in shell commands) and better extract tool names and parameters from varied tag names.Description
filterLeakedContentFilterParts/stripLeakedContentFilterSuffixbehavior to preserve trailing newline characters and factor the drop logic intoshouldDropCleanedLeakedChunkwhich keeps newline-only chunks.shouldDropCleanedLeakedChunkto avoid dropping chunks that contain\nwhile still removing empty/whitespace-only chunks.xmlToolCallNameTagNamesandxmlToolCallNamePatternByTagand attempt tag-based parameter parsing before full XML decoding to handle non-XML-safe payloads.parseSingleXMLToolCallto tryparseXMLChildKVwhenparseToolCallInputyields only_raw, and to merge parsed key/value pairs intoparamswhen present.internal/sse/line_test.goandinternal/util/toolcalls_test.gocovering preserved newlines before leakedCONTENT_FILTERand XML parameter JSON containing raw ampersands.Testing
go test ./...including SSE and util packages and all tests completed successfully.TestParseDeepSeekContentLinePreservesTrailingNewlineBeforeLeakedContentFilterandTestParseDeepSeekContentLineKeepsNewlineOnlyChunkBeforeLeakedContentFilterpassed.TestParseToolCallsSupportsXMLParametersJSONWithRawAmpersandpassed and verifies preservation of raw shell commands in parameters.Codex Task