Skip to content

[WRONG BRANCH] fix(responses): enforce explicit empty tool catalogs for undeclared-tool guard - #306

Draft
luvs01 wants to merge 2 commits into
mainfrom
codex/fix-guard-for-empty-tool-catalogs
Draft

[WRONG BRANCH] fix(responses): enforce explicit empty tool catalogs for undeclared-tool guard#306
luvs01 wants to merge 2 commits into
mainfrom
codex/fix-guard-for-empty-tool-catalogs

Conversation

@luvs01

@luvs01 luvs01 commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a bypass where an explicit empty tools: [] outbound catalog disabled the undeclared-tool guard and allowed routed passthrough providers to relay client-executed tool calls (for example apply_patch).

Description

  • Make the guard activate when the request either declares at least one wire tool name or carries an explicit tools array by adding hasExplicitWireToolCatalog and changing undeclaredToolGuardActive in src/server/responses/core.ts to consider that case while keeping the authMode === "forward" exemption.
  • Preserve the existing union with the caller's own catalog via toolBridgeMaps.declaredToolNames so hosted-tool mapping still widens the accepted set rather than narrowing it.
  • Update tests in tests/responses-undeclared-tool-guard.test.ts to assert that an omitted catalog (no tools field) remains relayed for compatibility but an explicit empty catalog (tools: []) now causes streamed and non-streamed upstream client tool calls to be refused.

Testing

  • Ran targeted compatibility and guard tests with bun test tests/responses-undeclared-tool-guard.test.ts tests/github-copilot-stream-contract.test.ts tests/deepseek-inbound-wire.test.ts tests/deepseek-responses-item-id-repair.test.ts tests/responses-custom-tool-repair.test.ts, which passed (91 tests across the touched suites).
  • Ran type checking and privacy checks with bun run typecheck and bun run privacy:scan, both of which succeeded in this environment.
  • A full bun run test of the entire suite in this session hit unrelated environment/timing failures (lab/timeouts and proxy-related harness constraints) and is not reflective of the focused regression coverage added; the focused Responses tests and compatibility scenarios for this change passed.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 16cb8819-ac48-4ad4-8bda-104ab2e05711

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 17, 2026
@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(responses): enforce explicit empty tool catalogs for undeclared-tool guard [WRONG BRANCH] fix(responses): enforce explicit empty tool catalogs for undeclared-tool guard Aug 17, 2026
@github-actions
github-actions Bot marked this pull request as draft August 17, 2026 05:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40b9ae62b6

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

Comment on lines +2365 to +2367
const hasExplicitWireToolCatalog = outboundRequestBody !== undefined
&& Array.isArray((outboundRequestBody as Record<string, unknown>).tools);
const undeclaredToolGuardActive = (declaredWireToolNames.size > 0 || hasExplicitWireToolCatalog)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat additional_tools as an explicit catalog

When a Responses Lite request carries its catalog only in an input item such as {type:"additional_tools", tools:[]} and omits top-level tools—a supported shape parsed in src/responses/parser.ts—this check remains false because the collected name set is empty and only outboundRequestBody.tools is inspected. A routed provider can therefore return a client-executed call such as apply_patch and have it relayed despite the explicit catalog authorizing no client tools. Detect array-bearing additional_tools items as explicit catalogs as well, and cover the empty additional-tools-only case in the regression tests.

Useful? React with 👍 / 👎.

@Wibias stepped down from developing opencodex, and repository permission was
reduced to read access. Move him out of the current-maintainers table into a
new Former maintainers section, drop him from the CODEOWNERS default-reviewer
line and the four high-impact runtime paths, and record the change with the
2026-07-27 addition entry it closes.

Nothing he authored is unwound: commits, merged pull requests, release-note
attributions, and the code comments citing his reviews stay as they are.
@luvs01 luvs01 closed this Aug 19, 2026
@luvs01 luvs01 reopened this Aug 19, 2026
@luvs01
luvs01 force-pushed the codex/fix-guard-for-empty-tool-catalogs branch from 40b9ae6 to 52f7324 Compare August 19, 2026 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants