Custom "anthropic" provider does not enforce provider.max_prompt_tokens — sessions grow past the model context window until a hard 400
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Beginne beim session-create/resume-Pfad des benutzerdefinierten anthropic-Providers und verfolge, wie max_prompt_tokens und die Schwellenwerte für infinite_sessions behandelt werden, bevor Requests gesendet werden. Vergleiche diesen Pfad mit dem Copilot-Backend-Pfad, bei dem die Komprimierung funktioniert, reproduziere das wachsende Transkript und bestätige, dass Prompts innerhalb des konfigurierten Budgets bleiben und fehlgeschlagene Sessions wiederhergestellt werden können.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
When a custom provider of type: "anthropic" is configured with max_prompt_tokens, the SDK does not appear to enforce that budget. A long-running session keeps accumulating transcript until the request exceeds the model's context window and the provider rejects it with HTTP 400 -- after which the session is permanently unusable.
Configuration
The provider is created on every session create/resume with an explicit prompt budget:
{
"type": "anthropic",
"base_url": "...",
"model_id": "claude-sonnet-5",
"max_output_tokens": 32768,
"max_prompt_tokens": 967232
}
max_prompt_tokens is derived as context_window (1,000,000) - max_output_tokens (32,768) = 967,232.
Expected
The SDK compacts (or otherwise bounds the prompt) before crossing max_prompt_tokens = 967232.
Actual
The transcript grew unbounded to 1,001,142 tokens -- 33,910 past the configured budget, and past the model's 1,000,000 hard limit:
400 invalid_request_error
"prompt is too long: 1001142 tokens > 1000000 maximum"
The session had run ~18 successful turns over ~3 hours, with the serialized request growing steadily (~1.98 MB -> ~2.04 MB) before crossing the limit. Tool count was constant throughout, so the growth is accumulated conversation history rather than tool schemas.
Two additional observations
-
infinite_sessionsthresholds also appear inert on this path.background_compaction_threshold/buffer_exhaustion_thresholdare sent on every turn but appear to have no effect for theanthropicprovider (they do take effect on the Copilot backend path). So neither the threshold-based compaction nor themax_prompt_tokensbudget bounded the transcript. -
The session actively degrades after the first failure. Once over the limit, continued turns keep appending to the transcript -- request size grew from ~2.044 MB to ~2.065 MB across ~30 consecutive failed turns. There is no back-off, trim, or compaction triggered by the 400, so the session can never self-recover; every subsequent turn fails immediately (~1.5s vs. the 38s first failure).
Impact
Every turn in an affected session fails permanently. The only recovery is to start a new session, and nothing in the surfaced error indicates that to the user. Because the failure is a deterministic 400, retry suppression correctly kicks in -- but that just means the session is durably wedged.
Environment
- SDK 1.0.7 / Copilot CLI 1.0.71
- Custom
anthropicprovider over an OpenAI-incompatible relay endpoint - Model
claude-sonnet-5(1,000,000-token context window)
Ask
Should provider.max_prompt_tokens be enforced on the anthropic provider path (and/or should infinite_sessions compaction apply there)? If enforcement is intentionally backend-only today, it would help to document that clearly, since the field is accepted without warning and silently has no effect.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 10.6k
- Forks
- 1.5k
- Ø Merge
- 19 Std. 59 Min.
- Gemergte PRs (30 T.)
- 30
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/copilot-sdk
-
Clarify SDK architecture and in-process runtime transportEvtl. vergeben @KalebCole hat das vor 13 Tagen übernommen. Offendocumentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
github/copilot-sdk#2804 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Python ModelLimits drops max_output_tokens from model metadataEvtl. vergeben @HDMowri hat das vor 15 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
github/copilot-sdk#2798 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
github/copilot-sdk#2793 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agentic-workflows
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
github/copilot-sdk#2782 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agentic-workflows
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
github/copilot-sdk#2779 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in github/copilot-sdk
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
wormhole-foundation/wormhole#5062 ·
Maintainer antworten meist innerhalb von 1 Tag
-
internal os specific
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
frostney/GocciaScript#1688 ·
Maintainer antworten meist innerhalb von 1 Tag
-
integration:hermes
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
vectorize-io/hindsight#5592 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
vercel/streamdown#673 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
apache/rocketmq-dashboard#6712 ·
Maintainer antworten meist innerhalb von 3 Tagen