Skip to content

fix(proxy): retry Anthropic tools without strict - #6121

Open
kense-lab wants to merge 2 commits into
farion1231:mainfrom
kense-lab:fix/6118-bedrock-tool-strict
Open

fix(proxy): retry Anthropic tools without strict#6121
kense-lab wants to merge 2 commits into
farion1231:mainfrom
kense-lab:fix/6118-bedrock-tool-strict

Conversation

@kense-lab

@kense-lab kense-lab commented Aug 4, 2026

Copy link
Copy Markdown

Summary / 概述

Fixes Bedrock-backed Anthropic gateways rejecting Codex tool declarations with:

tools.0.custom.strict: Extra inputs are not permitted
  • preserves tool-level strict on the first request so native Anthropic keeps structured tool guarantees
  • detects the exact HTTP 400 unsupported-field error and retries the same Anthropic provider once without tool declaration strict
  • handles Responses/Anthropic, Chat Completions, namespace, and tool_search_output tool shapes
  • does not traverse parameters or input_schema, so a business schema property named strict is preserved
  • continues through existing media/thinking rectifiers if the compatibility retry reveals a different validation error

This is error-driven rather than model- or URL-driven because custom gateways can hide Bedrock behind an Anthropic-compatible endpoint.

Upstream implementations use the same compatibility behavior:

Related Issue / 关联 Issue

Fixes #6118

Screenshots / 截图

Not applicable; proxy compatibility fix with no UI changes.

Verification / 验证

  • cargo fmt --check
  • CARGO_INCREMENTAL=0 CARGO_PROFILE_DEV_DEBUG=0 cargo clippy --lib -- -D warnings
  • CARGO_INCREMENTAL=0 CARGO_PROFILE_TEST_DEBUG=0 cargo test --lib tool_strict_rectifier — 4 passed
  • CARGO_INCREMENTAL=0 CARGO_PROFILE_TEST_DEBUG=0 cargo test --lib anthropic_rectifiers_cover_codex_responses_bridge — 1 passed
  • CARGO_INCREMENTAL=0 CARGO_PROFILE_TEST_DEBUG=0 cargo test --lib test_request_tools_and_filtering — 1 passed
  • live end-to-end against octogw.imocto.cn with an isolated local relay — first outbound Anthropic request contained tools[0].strict=true and received the Bedrock 400; the automatic second request omitted strict and received HTTP 200
  • full cargo test --lib — 2319 passed, 1 unrelated existing-environment failure, 2 ignored. The failure was update_current_claude_desktop_provider_syncs_profile_when_proxy_takeover_is_active because the local proxy port was already in use.

Checklist / 检查清单

  • cargo fmt --check passes / 通过 Rust 格式检查
  • cargo clippy --lib -- -D warnings passes / 通过 Clippy 检查
  • Focused regression tests pass / 相关回归测试通过
  • No user-facing text or i18n changes / 无用户可见文本或国际化改动
  • No frontend changes; TypeScript checks are not applicable / 无前端改动,无需 TypeScript 检查

@kense-lab
kense-lab requested a review from farion1231 as a code owner August 4, 2026 10:02
@github-actions github-actions Bot added backend Backend (Rust/Tauri) proxy Related to proxy/API forwarding labels Aug 4, 2026
@kense-lab
kense-lab force-pushed the fix/6118-bedrock-tool-strict branch from 83bde0a to b00ce95 Compare August 4, 2026 10:14
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@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: b00ce95ad1

ℹ️ 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 thread src-tauri/src/proxy/forwarder.rs Outdated
@kense-lab
kense-lab force-pushed the fix/6118-bedrock-tool-strict branch from 9c14fb1 to 0faac87 Compare August 10, 2026 06:37
@kense-lab

Copy link
Copy Markdown
Author

@farion1231 CI is green and the Codex review feedback has been addressed. Could you please take a look when you have time? Thanks.

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

Labels

backend Backend (Rust/Tauri) proxy Related to proxy/API forwarding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(proxy): retry Anthropic tools without strict when Bedrock rejects it

2 participants