Part of #612.
Enforce maxToolTokens / maxCostUsd on the streaming auto path (generateStream). Today these throw 501 at stream entry; the sync path enforces them.
Why deferred
GenerateChunk doesn't expose usage in v1, so cumulative spend isn't observable from a stream. Wiring this needs the chunk type extended plus each in-tree backend (openai / anthropic / bedrock) emitting usage on its final chunk.
Acceptance
Note: the maxToolIterations cap already applies to streaming; this closes the spend-budget gap only.
🤖 Generated with Claude Code
Part of #612.
Enforce
maxToolTokens/maxCostUsdon the streaming auto path (generateStream). Today these throw501at stream entry; the sync path enforces them.Why deferred
GenerateChunkdoesn't exposeusagein v1, so cumulative spend isn't observable from a stream. Wiring this needs the chunk type extended plus each in-tree backend (openai / anthropic / bedrock) emitting usage on its final chunk.Acceptance
GenerateChunk(or a terminal metadata chunk) carriesusage.BudgetExceededErrorlike the sync path.Note: the
maxToolIterationscap already applies to streaming; this closes the spend-budget gap only.🤖 Generated with Claude Code