claw-code/rust/crates/api/src
Yeachan-Heo fa72cd665e Block oversized requests before providers hard-fail
The runtime already tracked rough token estimates for compaction, but provider-bound
requests still relied on naive model output limits and could be sent upstream even
when the selected model could not fit the estimated prompt plus requested output.

This adds a small model token/context registry in the API layer, estimates request
size from the serialized prompt payload, and fails locally with a dedicated
context-window error before Anthropic or xAI calls are made. Focused integration
coverage asserts the preflight fires before any HTTP request leaves the process.

Constraint: Keep the first pass minimal and reusable across both Anthropic and OpenAI-compatible providers
Rejected: Auto-compact-and-retry in the same patch | broader control-flow change than the requested minimal preflight
Confidence: medium
Scope-risk: narrow
Reversibility: clean
Directive: Expand the model registry before enabling preflight for additional providers or aliases
Tested: cargo build -p api -p tools -p rusty-claude-cli; cargo test -p api
Not-tested: End-to-end CLI auto-compaction or retry behavior after a local context_window_blocked failure
2026-04-05 16:39:58 +00:00
..
providers Block oversized requests before providers hard-fail 2026-04-05 16:39:58 +00:00
client.rs chore: additional AI slop cleanup and enforcer wiring from sessions 1/5 2026-04-03 18:35:27 +09:00
error.rs Block oversized requests before providers hard-fail 2026-04-05 16:39:58 +00:00
lib.rs fix: restore anthropic request profile integration 2026-04-02 11:31:53 +09:00
prompt_cache.rs fix: cover merged prompt cache behavior 2026-04-02 11:31:53 +09:00
sse.rs Accept reasoning-style content blocks in the Rust API parser 2026-04-01 08:06:10 +00:00
types.rs Merge remote-tracking branch 'origin/rcc/telemetry' into integration/dori-cleanroom 2026-04-02 11:13:56 +09:00