fix(openai): strip leaked tool result markers#483
Merged
CJackHwang merged 1 commit intoMay 10, 2026
Conversation
|
@NgoQuocViet2001 is attempting to deploy a commit to the cjack's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c9127a032
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2c9127a to
3e935c0
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
Fixes #456.
Some leaked DeepSeek tool-result control sections can reach visible OpenAI-compatible output as
<|Tool|>...<|end_of_toolresults|>, especially with fullwidth delimiters. The existing sanitizer removed standalone<|Tool|>markers and one JSON-object shape withtool_call_id, but it could leave the payload behind when the whole tool-result section was present.This change keeps the visible-output sanitizer defensive by:
<|Tool|>through<|end_of_toolresults|>/<|end▁of▁toolresults|>Assistant_END_OF_TOOL_CALLS/Assistant▁END▁OF▁TOOL_CALLSmarkers, plus standaloneend_of_tool_callsDuplicate check: reviewed current open PRs (#437, #407, #405) and recent merged sanitizer/tool-call work, especially #476. #476 covers adjacent leakage cases but not the
Assistant_END_OF_TOOL_CALLSmarker or full<|Tool|>...<|end_of_toolresults|>section shape.📝 补充信息 | Additional Information
Validation run locally with portable Go 1.26.0:
gofmt -w internal/httpapi/openai/shared/leaked_output_sanitize.go internal/httpapi/openai/leaked_output_sanitize_test.gogo test ./internal/httpapi/openai -run 'TestSanitizeLeakedOutput' -count=1go test ./internal/httpapi/openai/... -count=1git diff --check./tests/scripts/check-refactor-line-gate.sh./tests/scripts/run-unit-all.shnpm run build --prefix webui./scripts/lint.shin an LF validation clone withgolangci-lintv2.11.4:0 issuesNote: on the normal Windows CRLF checkout,
./scripts/lint.shreports repo-wide CRLF/LF formatting diffs in untouched Go files. The same patch passes the repo lint script in an LF clone.