Skip to content

Relax tool-name allow-listing and improve tool-call detection/parsing across adapters and sieve#153

Merged
CJackHwang merged 4 commits intodevfrom
codex/investigate-tool-execution-bugs-in-output-7ocr8f
Mar 22, 2026
Merged

Relax tool-name allow-listing and improve tool-call detection/parsing across adapters and sieve#153
CJackHwang merged 4 commits intodevfrom
codex/investigate-tool-execution-bugs-in-output-7ocr8f

Conversation

@CJackHwang
Copy link
Owner

Motivation

  • Ensure streaming tool-detection remains active even when client tools schemas are malformed, empty, or when tool_choice=none, so tool payloads are still intercepted and emitted.
  • Stop canonicalizing or rejecting unknown tool names during parsing so original tool names/casing are preserved and unknown tools can be emitted as executable tool calls.
  • Improve robustness of the stream sieve and XML/markup parsers to detect more tool-call forms (including Claude <tool_use> variants and array payloads) and to detect tool calls when mixed with leading prose.

Description

  • Enabled a sentinel tool name ("__any_tool__") when tools are present but provide no valid names by adding ensureToolDetectionEnabled and equivalent logic in the JS policy resolver.
  • Relaxed incremental filtering in filterIncrementalToolCallDeltasByAllowed to preserve seen names and avoid blocking when allowedNames is empty, and adjusted formatting logic accordingly.
  • Stopped strict allow-list enforcement in parser layers and changed parsing to preserve original tool name casing and to keep unknown tool names; removed rejection paths from ParseToolCallsDetailed/filterToolCallsDetailed and updated JS helpers to match.
  • Extended the tool-call candidate extraction to include top-level arrays and look for "function" JSON keyword, and adjusted sieve keyword lists to catch more payload shapes.
  • Added support for additional <tool_use> XML/markup styles in parseXMLToolCalls and helpers to extract tool_name/function_name and parameter bodies.
  • Adjusted the Claude stream runtime to buffer and finalize tool detection using the standalone parsing routines (and added a test TestHandleClaudeStreamRealtimeDetectsToolUseWithLeadingProse).
  • Updated many tests and test expectations to reflect the new permissive behavior and added new unit tests for the new XML/markup styles and stream cases.

Testing

  • Ran Go unit tests with go test ./... covering internal/adapter/claude, internal/adapter/openai, and internal/util, and they all passed.
  • Ran the JS unit tests with the project's Node test harness (npm test / yarn test) for the stream-tool-sieve helpers and they passed.
  • Updated and added multiple tests (e.g. TestHandleClaudeStreamRealtimeDetectsToolUseWithLeadingProse, several ParseToolCalls cases, and stream-tool-sieve node tests) to assert the new permissive parsing and they succeed.

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 1:27pm

@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.

…issues

Sync tool-call compat fixtures and update node test to match permissive tool-call policy
@CJackHwang CJackHwang merged commit 5887821 into dev Mar 22, 2026
1 of 3 checks passed
@CJackHwang CJackHwang deleted the codex/investigate-tool-execution-bugs-in-output-7ocr8f branch March 22, 2026 13:27
CJackHwang added a commit that referenced this pull request Mar 22, 2026
Merge pull request #153 from CJackHwang/codex/investigate-tool-execution-bugs-in-output-7ocr8f

Relax tool-name allow-listing and improve tool-call detection/parsing across adapters and sieve
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