Skip to content

fix: route Anthropic SDK clients through guarded transport#101357

Merged
steipete merged 1 commit into
mainfrom
codex/anthropic-guarded-sdk-fetch
Jul 7, 2026
Merged

fix: route Anthropic SDK clients through guarded transport#101357
steipete merged 1 commit into
mainfrom
codex/anthropic-guarded-sdk-fetch

Conversation

@steipete

@steipete steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Related: #100550

AI-assisted: Codex

What Problem This Solves

Fixes an issue where Anthropic-compatible requests from GitHub Copilot, Microsoft Foundry, Anthropic OAuth/API-key clients, Kimi, and Amazon Bedrock Mantle could bypass OpenClaw's guarded model transport when the Anthropic SDK created the HTTP request.

Why This Change Was Made

Every Anthropic SDK client now receives the host-built guarded fetch, matching the existing Cloudflare and extracted Anthropic transport paths. Kimi thinking streams retain their required SSE sanitizer bypass, and Mantle uses the public provider transport runtime seam.

User Impact

Anthropic-compatible provider routes now consistently receive OpenClaw's request policy, response normalization, and managed stream cleanup instead of depending on the SDK's default fetch. Provider auth and request payload behavior are unchanged.

Evidence

  • Baseline negative control at 21d919deb801939d185e548cb70268b05045ebf9: the real-SDK loopback test failed because the host fetch recorded zero calls.
  • Rebased focused proof at 31432bf10160512956573c8010b0d1bb5cdf75f2: 61 core Anthropic tests and 11 Mantle tests passed. The loopback test exercised the real Anthropic SDK over HTTP and verified Copilot, Foundry, OAuth, API-key, and Kimi auth/request paths.
  • pnpm check:changed on Blacksmith Testbox tbx_01kwxc5vmckc01qzmfff04chka: core/plugin typechecks, lint, dependency guards, import-cycle checks, and boundary checks passed.
  • .agents/skills/autoreview/scripts/autoreview --mode local --engine codex --model gpt-5.5 --thinking high: clean, no accepted/actionable findings.

Dependency contract checked against @anthropic-ai/sdk sdk-v0.109.1: ClientOptions.fetch is the supported constructor seam and request dispatch uses that configured fetch.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 7, 2026

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

Copy link
Copy Markdown
Contributor

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: 98a684caaf

ℹ️ 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 +1122 to +1126
const fetchOptions =
/^kimi(?:-|$)/.test(model.provider) && thinkingEnabled
? { sanitizeSse: false as const }
: undefined;
const fetch = getAiTransportHost().buildModelFetch(model, undefined, fetchOptions);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve Kimi sanitizer bypass for payload-patched thinking

When Kimi Anthropic thinking is enabled via the shipped plugin's extraParams.thinking wrapper rather than via options.reasoning, this check stays false because the wrapper only adds payload.thinking in onPayload (extensions/kimi-coding/stream.ts, covered by extensions/kimi-coding/stream.test.ts), and onPayload runs after this client/fetch is built. In that configuration (extraParams: { thinking: "enabled" } with the session thinking level still off), the new guarded SDK fetch uses the default SSE sanitizer even though the sibling Anthropic transport documents that Kimi thinking streams must pass sanitizeSse: false or they can stall before the text block (src/agents/anthropic-transport-stream.ts).

Useful? React with 👍 / 👎.

@steipete
steipete merged commit c5d4259 into main Jul 7, 2026
118 of 120 checks passed
@steipete
steipete deleted the codex/anthropic-guarded-sdk-fetch branch July 7, 2026 04:45
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
sheyanmin pushed a commit to sheyanmin/openclaw that referenced this pull request Jul 8, 2026
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant