anthropics / anthropics/claude-agent-sdk-typescript

Vertex AI 400: SDK forwards `effort-2025-11-24`, `tool-search-tool-2025-10-19`, `web-search-2025-03-05` betas that Vertex doesn't accept

Aperta
#307 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug enhancement
Lingua principale
Shell
Stelle
1.8k
Fork
226
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Summary

When the Agent SDK (we tested `0.2.112`, also reproduced symbolically in `0.2.119`) is configured to talk to Anthropic on **Vertex AI** (Google Cloud), the bundled CLI emits an `anthropic-beta` header containing tokens that Vertex AI rejects with HTTP 400. This breaks every chat round-trip via Vertex.

## Error returned by Vertex

```
API Error: 400 {
"type":"error",
"error":{
"type":"invalid_request_error",
"message":"Unexpected value(s) `effort-2025-11-24`, `tool-search-tool-2025-10-19`, `web-search-2025-03-05` for the `anthropic-beta` header. Please consult our documentation at docs.anthropic.com or try again without the header."
},
"request_id":"req_vrtx_011CaTrDBQjGki9q5shKdjFp"
}
```

The `req_vrtx_…` prefix confirms the request reached Vertex.

## Repro context

- SDK: `@anthropic-ai/claude-agent-sdk@0.2.112`
- Provider: Vertex AI (`alva-ai-prd` GCP project), Claude served via `aiplatform.googleapis.com`
- Models in play: Sonnet 4.6 / Opus 4.6 family
- Triggered by ordinary `query()` calls — no opt-in to `effort` / `web-search` / `tool-search` from our side. Our codebase contains zero references to these tokens (verified via grep across the entire monorepo).

## Evidence the SDK is the source

In the bundled CLI of `0.2.112` (`node_modules/@anthropic-ai/claude-agent-sdk/cli.js`):

```js
Qv1="web-search-2025-03-05",
GZq="advanced-tool-use-2025-11-20",
vZq="tool-search-tool-2025-10-19",
dv1="effort-2025-11-24",
```

These constants are present and joined into the `anthropic-beta` header on outgoing requests. The same three tokens are still present in the `0.2.119` platform binary (`@anthropic-ai/claude-agent-sdk-linux-x64@0.2.119/claude`), confirmed via `strings`.

The CLI even includes its own internal migration note saying these betas should be **removed** for newer model lineups (paraphrased from the bundled text):

> "Remove the `effort-2025-11-24` and `fine-grained-tool-streaming-2025-05-14` beta headers (GA on 4.6); remove `interleaved-thinking-2025-05-14` once you're on adaptive thinking. Then drop back from `client.beta.messages.create` to `client.messages.create`."

So the SDK *knows* these betas are not appropriate everywhere, but still attaches them unconditionally on the request path — including when the configured provider is Vertex AI, which has never accepted them.

## Expected

Either:
1. Don't emit `effort-2025-11-24`, `tool-search-tool-2025-10-19`, `web-search-2025-03-05` (and other Anthropic-only betas) when the provider is Vertex AI / Bedrock — strip them in the request path based on `ANTHROPIC_VERTEX_PROJECT_ID` / `CLAUDE_CODE_USE_VERTEX` (or whichever env you key off), **or**
2. Expose a documented hook (e.g., a `betas` allowlist option, or `extraHeaders` overrides) so callers can strip them themselves without forking.

Today there appears to be no public way to opt out without monkey-patching the bundled CLI.

## Impact

100% failure rate on Vertex-backed chat traffic for any agent using the SDK as-shipped. We had to disable the affected paths in CI.

## Workaround we're considering

Run an in-house proxy that strips these three tokens from `anthropic-beta` before forwarding to Vertex. This works but is fragile — every new beta the SDK adds is another token we have to discover the hard way via a 400.

Happy to provide a minimal repro repo if helpful.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.