Skip to content

Do not promote fenced code examples to tool calls and centralize tool-keyword detection#150

Merged
CJackHwang merged 2 commits intocodex/fix-tool-miscall-during-complex-json-testfrom
codex/fix-markup-bypass-in-tool-call-parsing
Mar 22, 2026
Merged

Do not promote fenced code examples to tool calls and centralize tool-keyword detection#150
CJackHwang merged 2 commits intocodex/fix-tool-miscall-during-complex-json-testfrom
codex/fix-markup-bypass-in-tool-call-parsing

Conversation

@CJackHwang
Copy link
Owner

Motivation

  • Prevent accidental promotion of fenced code block examples into actionable tool_calls/tool_use events so example content remains as text.
  • Reduce duplicated keyword logic by centralizing tool-segment keywords and earliest-index lookup for more robust parsing.

Description

  • Add internal/js/helpers/stream-tool-sieve/tool-keywords.js with TOOL_SEGMENT_KEYWORDS and earliestKeywordIndex to centralize keyword detection.
  • Update JS parser (parse.js) and sieve (sieve.js) to use TOOL_SEGMENT_KEYWORDS and a small TOOL_MARKUP_PREFIXES list and simplify fence-checking logic so fenced examples are preserved as content-only when appropriate.
  • Adjust Go parsing helpers (internal/util/toolcalls_candidates.go) to stop promoting fenced code examples by simplifying shouldSkipToolCallParsingForCodeFenceExample behavior.
  • Update tests across adapters and format packages (handler_stream_test.go, handler_toolcall_test.go, render_test.go) to expect fenced JSON examples to remain content-only and add backward-compatible alias test functions for historical test names.

Testing

  • Ran the Go unit tests for the modified packages via go test ./... and verified the updated tests in internal/adapter/claude, internal/adapter/openai, and internal/format/openai passed.
  • Exercised the updated stream-tool-sieve logic through the modified unit tests which confirmed fenced examples are no longer promoted to tool calls.

Codex Task

@vercel
Copy link

vercel bot commented Mar 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ds2api Ready Ready Preview, Comment Mar 22, 2026 8:33am

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@CJackHwang CJackHwang merged commit 58f753d into codex/fix-tool-miscall-during-complex-json-test Mar 22, 2026
3 checks passed
@CJackHwang CJackHwang deleted the codex/fix-markup-bypass-in-tool-call-parsing branch March 22, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant