Skip to content

fix: preserve tool safety on translated Messages fallbacks - #7919

Merged
lidge-jun merged 1 commit into
devfrom
fix/messages-translation-tool-constraints
Oct 29, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/messages-translation-tool-constraints

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Prevent translated Messages combo fallbacks from turning domain/location-scoped hosted search into unrestricted search. If any web_search* declaration supplies allowed_domains, blocked_domains or user_location, omit hosted search from the shared translated catalog and sidecar path. Duplicate declarations cannot bypass omission; a forced omitted search refuses locally. Original typed tools still reach first-party Anthropic when translation proceeds.
  • Keep valid defer_loading function definitions callable as ordinary functions on unsupported wires, including compatibility-enforced requests. This is eager-loading degradation, not native deferred discovery; unsupported top-level deferral and server-executed discovery retain admission checks. Existing direct-route append-only loading stays intact.
  • Follow-up to the pre-existing translated-lane R4 finding summarized in fix(combo): stop the prompt-cache usage leak — replay native Messages on Anthropic children #7374, separate from that contributor PR. No contributor code is reused. Update the owning structure contract and English/localized Claude Code documentation.

Verification

  • Base: origin/dev at f5a5e5bcf09136b310b420f71a139efbc2b33311; Bun 1.4.4; bun install --frozen-lockfile passed. Test invocations use OCX_TEST_NO_QUEUE=1; one Bun test process at a time.
  • RED on unchanged production source: bun test tests/claude-integration/claude-translated-tool-restrictions.test.ts — 1 pass / 9 fail, unexpected unrestricted hosted/synthetic search on both physical wires. Additional forced-search/eager-admission regressions failed 0 pass / 2 fail before those fixes.
  • GREEN: new 14-case contract suite — 14 pass / 0 fail, 102 assertions. Both combo targets use actual Anthropic refusal -> Responses/Chat sends; verify original Anthropic constraints, omitted fallback search, and full deferred schemas. Compatibility plus contract validation — 49 pass / 0 fail before expanding the two-send matrix.
  • Broad focused validation: 35 files comprising direct translation importers in adapter/Responses/Claude suites, translated server tools, tool-loading destinations, endpoint tests, test-layout/tooling, file-size ratchet and Lab boundary — 918 pass / 1 fail / 1 unhandled error. Command: bun test <35 focused files>; file list and full output retained in local scratch. present invalid compatibility modes return one fixed 503 before translation hit a Windows startup ACL error (EICACLS, /grant:r) and the existing 5000ms timeout. No assertion, timeout, retry, skip or production lock was weakened; this run is not reported green.
  • Exact-base comparison in a GOAT-managed worktree: bun run test --parallel=1 ./tests/claude-integration/claude-messages-endpoint.test.ts --test-name-pattern 'present invalid compatibility modes return one fixed 503 before translation' at unchanged f5a5e5bcf09136b310b420f71a139efbc2b33311 — 0 pass / 1 fail / 1 error / 53 filtered, exit 1, one run. The same 5000ms timeout reproduced (6236ms), followed by ENOENT writing the removed fixture config. The timeout is inherited; the base comparison does not establish the original delay or explain the candidate run's secondary EICACLS error.
  • bun run typecheck passed (2,227 files).
  • bun run structure:check and bun run privacy:scan passed. Test-layout/tooling, file-size ratchet and Lab-boundary guards passed within the broad focused run.
  • Documentation: cd docs-site; bun install --frozen-lockfile; bun run build passed — 593 pages and 85,247 internal links checked.
  • Independent security source review: PASS, 0 blockers across the 17-file diff. The first audit's valid-deferred-function admission finding was fixed and covered red-to-green. This is an independent agent source review, not maintainer approval or independent runtime proof.
  • Full-suite scope exception: the repository has concurrent shared-host worktree lanes; a full local suite is disproportionately expensive for this narrow translation slice. Required focused behavior and structural guards were exercised; remaining full-suite/platform coverage belongs to CI. This PR remains draft while validation limitations are unresolved.
  • NOT RUN: full local suite; live provider/OAuth sessions or measured cache hit rate; hosted Windows/macOS lanes. No CI dispatch/rerun or merge.
Exact 35-file focused test command
OCX_TEST_NO_QUEUE=1 bun test \
  tests/claude-integration/claude-alias.test.ts \
  tests/adapters/openai/openai-chat-system-order.test.ts \
  tests/claude-integration/claude-inbound-tool-reference.test.ts \
  tests/claude-integration/claude-inbound-debug.test.ts \
  tests/claude-integration/claude-inbound-token-footer.test.ts \
  tests/claude-integration/claude-inbound-tool-loading.test.ts \
  tests/claude-integration/claude-inbound-cache-stabilize.test.ts \
  tests/claude-integration/claude-intercept-model-bindings.test.ts \
  tests/claude-integration/claude-inbound.test.ts \
  tests/claude-integration/claude-native-fast-1m-ingress.test.ts \
  tests/claude-integration/claude-output-schema-strict.test.ts \
  tests/claude-integration/claude-native-reasoning-provenance.test.ts \
  tests/claude-integration/claude-native-reasoning-continuity.test.ts \
  tests/responses/chat-inline-document-bytes.test.ts \
  tests/claude-integration/claude-source-envelope.test.ts \
  tests/adapters/anthropic/anthropic-reasoning.test.ts \
  tests/responses/chat-inbound-developer-position.test.ts \
  tests/claude-integration/claude-subagent-model-force.test.ts \
  tests/adapters/anthropic/anthropic-tool-declaration-constraints.test.ts \
  tests/claude-integration/claude-translated-cache-ttl.test.ts \
  tests/adapters/anthropic/anthropic-thinking-signature.test.ts \
  tests/responses/openai-responses-summary-none.test.ts \
  tests/responses/protocol-features.test.ts \
  tests/responses/openai-responses-passthrough.test.ts \
  tests/responses/messages-native-bridge-policy.test.ts \
  tests/responses/reasoning-envelope.test.ts \
  tests/responses/protocol-messages-ir-parity.test.ts \
  tests/responses/responses-forward-prompt-envelope.test.ts \
  tests/claude-integration/claude-translated-server-tools.test.ts \
  tests/claude-integration/claude-tool-loading-destinations.test.ts \
  tests/claude-integration/claude-messages-endpoint.test.ts \
  tests/test-layout.test.ts \
  tests/test-layout-tooling.test.ts \
  tests/ci-workflows/file-size-ratchet.test.ts \
  tests/lab/core-lab-boundary.test.ts

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes
    • Restricted hosted searches are omitted from translated Responses/Chat requests when they include domain limits or location settings. Forcing a search that is no longer available returns an error.
    • Valid deferred function tools remain callable as ordinary functions on translated routes.
  • Documentation
    • Updated translated tool guidance across supported languages, including search restrictions and deferred-function behavior.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f5a5e5b and 4204f08.

Files selected for processing: 17
  • docs-site/src/content/docs/fr/guides/claude-code.md
  • docs-site/src/content/docs/guides/claude-code.md
  • docs-site/src/content/docs/ja/guides/claude-code.md
  • docs-site/src/content/docs/ko/guides/claude-code.md
  • docs-site/src/content/docs/ru/guides/claude-code.md
  • docs-site/src/content/docs/tr/guides/claude-code.md
  • docs-site/src/content/docs/zh-cn/guides/claude-code.md
  • docs-site/src/content/docs/zh-tw/guides/claude-code.md
  • scripts/test-layout/layout-clients.json
  • src/claude/compatibility.ts
  • src/claude/inbound-content-options.ts
  • structure/clients/claude-desktop.md
  • structure/data-planes/claude-tool-loading.md
  • tests/claude-integration/claude-compatibility.test.ts
  • tests/claude-integration/claude-messages-endpoint.test.ts
  • tests/claude-integration/claude-translated-tool-restrictions.test.ts
  • tests/fixtures/test-layout-expected.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The change updates Claude tool translation and compatibility handling. Restricted hosted-search declarations are omitted from translated Responses and Chat routes, and forced selection is rejected when no hosted search remains. Valid deferred function definitions remain callable. Tests and documentation cover these rules.

Changes: Claude translated tool handling

Layer / File(s) Summary
Translated tool rules
src/claude/inbound-content-options.ts, src/claude/compatibility.ts
Translated routes omit hosted search when a search declaration has its own allowed_domains, blocked_domains, or user_location property. Forced search selection raises an error when no hosted search declaration remains. Compatibility checks allow valid deferred function definitions and continue to reject unsupported deferral cases.
Integration validation
tests/claude-integration/*, scripts/test-layout/layout-clients.json, tests/fixtures/test-layout-expected.json
Integration tests cover restricted and unrestricted search translation, fallback to Responses and Chat, forced search selection, and deferred-tool compatibility. The test layout includes the new test file.
Tool handling documentation
docs-site/src/content/docs/guides/claude-code.md, docs-site/src/content/docs/*/guides/claude-code.md, structure/clients/claude-desktop.md, structure/data-planes/claude-tool-loading.md
The English and localized guides, client documentation, and tool-loading documentation describe the translated-route restrictions and deferred-function handling.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

  • Issue 7912 concerns translated Claude WebSearch behavior. This change addresses restricted-search omission and forced selection, but does not fully address the issue’s native-lane and sidecar-selection failures.
  • Issue 7655 concerns authorization for deferred catalog tools in a Responses additional_tools stream. This change updates deferred-tool admission but does not address the separate reported transport or test-harness problem.

Suggested reviewers: ingwannu, luvs01

Merge Risk: Minimal · up to 4204f

No actionable merge-blocking risk is established, though the reported focused test run was not green.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately identifies the main change: preserving tool safety during translated Messages fallbacks, including restricted hosted-search handling and related compatibility behavior.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 5 files. (12 skipped: 12 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun marked this pull request as ready for review October 28, 2026 18:59
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 28, 2026 18:59
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T18:59:41.531431Z 4204f08 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant