anthropics / anthropics/claude-agent-sdk-typescript

Vertex AI: startup model probe ignores ANTHROPIC_DEFAULT_SONNET_MODEL pin, falls back through retired Sonnet generations

Offen
#443 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Shell
Sterne
1.8k
Forks
226
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Summary

When running via `CLAUDE_CODE_USE_VERTEX=1` with `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` all pinned to Claude 5-family model IDs, the SDK's startup model-availability probe respects the Opus and Haiku pins but ignores the Sonnet pin, instead probing a hardcoded legacy default and cascading through several retired Sonnet generations.

## Environment

- `@anthropic-ai/claude-agent-sdk`: `0.3.257`
- `@anthropic-ai/claude-agent-sdk-darwin-arm64`: `0.3.257`
- Transport: Google Vertex AI (`CLAUDE_CODE_USE_VERTEX=1`)
- Env vars set before spawning the CLI subprocess:
```
CLAUDE_CODE_USE_VERTEX=1
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5
ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5
ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
ANTHROPIC_VERTEX_PROJECT_ID=
CLOUD_ML_REGION=global
```
- The actual session model (`AGENT_MODEL`) was `claude-haiku-4-5` — no code path in the calling application ever references an Opus or Sonnet model.

## Observed behavior (Vertex Cloud Logging / Data Access logs)

At session startup, before any `StreamRawPredict` call for the actual chat model, the following `RawPredict` calls are made:

| Method | Model requested | Result |
|---|---|---|
| RawPredict | `claude-opus-5` | success |
| RawPredict | `claude-haiku-4-5@20251001` | success |
| RawPredict | `claude-sonnet-4-5@20250929` | NOT_FOUND |
| RawPredict | `claude-sonnet-4@20250514` | NOT_FOUND |
| RawPredict | `claude-3-5-sonnet-v2@20241022` | NOT_FOUND |
| RawPredict | `claude-3-7-sonnet@20250219` | NOT_FOUND |
| StreamRawPredict ×N | `claude-haiku-4-5` | success (this is the real chat traffic) |

Opus and Haiku probes use exactly the pinned env values (or the pinned value resolved to its dated catalog ID) and succeed on the first attempt. Sonnet never probes the pinned `claude-sonnet-5` at all — it starts from an older generation (`claude-sonnet-4-5@20250929`) and walks down through three further retired generations, all of which 404 in our Vertex project (these older models are not enabled there).

## What we found by inspecting the native binary

We ran `strings` against the compiled `claude` binary shipped in `@anthropic-ai/claude-agent-sdk-darwin-arm64@0.3.257` and found an embedded model catalog (`bakedCatalog`) with per-generation metadata keys:

```
fallback_chain
retirement_dates
remapped_to
deprecation
min_cli_version
```

The Sonnet family is fully represented in this catalog, including generations newer than the one being probed:

```
Sonnet 3.5 → Sonnet 3.7 → Sonnet 4 → Sonnet 4.5 → Sonnet 4.6 → Sonnet 5
```

So the SDK is clearly aware `claude-sonnet-5` exists (it's a valid, cataloged entry) — the pin is not being rejected for being unrecognized. Instead it looks like the Sonnet family's "default alias" resolution still points at the pre-5-family baked default (`sonnet-4.5`), and when that 404s it falls back through its `fallback_chain` to progressively older generations, never consulting `ANTHROPIC_DEFAULT_SONNET_MODEL` at any point in that chain. The equivalent resolution path for Opus and Haiku does consult the corresponding env override and resolves directly to the pinned generation.

## Expected behavior

The startup probe for the Sonnet family should consult `ANTHROPIC_DEFAULT_SONNET_MODEL` the same way the Opus/Haiku probes consult their respective env vars, rather than falling back to a hardcoded legacy default and cascading through multiple retired generations.

## Impact

- No functional impact on actual chat responses — all real traffic (`StreamRawPredict`) correctly uses the pinned/selected model.
- Noisy `NOT_FOUND` entries in Vertex Data Access logs on every session startup, and unnecessary extra RawPredict calls against retired model IDs.

## Repro

1. Set `CLAUDE_CODE_USE_VERTEX=1`, pin `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` to Claude 5-family IDs, and set `AGENT_MODEL`/session model to any single family (e.g. Haiku).
2. Start a session against a Vertex project that has only the pinned Claude 5-family models enabled (older generations not enabled/deployed).
3. Inspect Vertex Cloud Logging → Data Access logs around session start.
4. Observe that Opus/Haiku probes use the pinned IDs directly, while the Sonnet probe starts from `claude-sonnet-4-5@...` and cascades through older generations, never trying the pinned `claude-sonnet-5`.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.