Summary
In src/interceptors/fetchInterceptor.ts, the original fetch call is made and the response returned before budget tracking runs. If the budget is exceeded, the error is thrown after the LLM call has already been completed and billed.
Affected File
src/interceptors/fetchInterceptor.ts
const response = await originalFetch(input, init); // call made first
// ...
await budgetManager.track(cost.totalCost); // budget checked too late
Suggested Fix
For estimated-cost enforcement, estimate the token count from the request body before making the API call, check the budget pre-flight, and block the request if it would exceed the limit.
Severity
High
Summary
In
src/interceptors/fetchInterceptor.ts, the originalfetchcall is made and the response returned before budget tracking runs. If the budget is exceeded, the error is thrown after the LLM call has already been completed and billed.Affected File
src/interceptors/fetchInterceptor.tsSuggested Fix
For estimated-cost enforcement, estimate the token count from the request body before making the API call, check the budget pre-flight, and block the request if it would exceed the limit.
Severity
High