Skip to content

Normalize tool call names for Responses API - #9447

Closed
illanes00 wants to merge 1 commit into
openai:mainfrom
illanes00:fix/normalize-tool-call-names
Closed

illanes00 wants to merge 1 commit into
openai:mainfrom
illanes00:fix/normalize-tool-call-names

Conversation

@illanes00

@illanes00 illanes00 commented Jan 18, 2026 •

Copy link
Copy Markdown

Fixes #6540

What

Normalize legacy/namespaced tool call names in the transcript before sending request history to the OpenAI Responses API.

This avoids 400s like:

  • Invalid 'input[N].name': string does not match pattern '^[a-zA-Z0-9_-]+$'

How

  • Map legacy container.exec -> shell.
  • If tool name is namespaced (e.g. functions.exec_command), drop the prefix when the suffix matches a known tool in the current prompt.
  • Otherwise, replace invalid characters with _ as a fallback.
  • Apply the same formatting to compaction payloads as well.

Tests

  • cargo test -p codex-core tool_name_tests

Manual verification

  • Resumed a session containing tool calls named functions.exec_command; patched CLI continues without triggering input[*].name validation errors.

Normalize legacy/namespaced tool call names before sending request history.

- map container.exec -> shell
- strip namespaced prefixes (e.g. functions.exec_command -> exec_command) when tool exists
- sanitize invalid chars to '_' as a fallback
- apply normalization to compaction payloads too

Adds unit tests for regression.
@github-actions

github-actions Bot commented Jan 18, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@illanes00

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jan 18, 2026
@etraut-openai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ 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".

@etraut-openai

Copy link
Copy Markdown
Contributor

@illanes00, thanks for the contribution. The Codex Team member who has the most experience in this part of the code base is busy with higher-priority work at the moment. It will probably be at least a week before we'll be able to review this. It's in the queue.

@illanes00

Copy link
Copy Markdown
Author

@etraut-openai, thanks for letting me know! Totally understand; no rush on my side.
Happy to contribute, and I really appreciate you and the team keeping things running smoothly.

@etraut-openai

Copy link
Copy Markdown
Contributor

After some internal discussion, we've decided to pass on this PR. We don't think this is the correct fix. Thanks again for taking the time to post it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamable MCP run normally and return results, but soon get unexpected status 400 Bad Request error

2 participants