mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Add usage accounting for host-owned agent runtimes (#58975)
## Why Host-owned runtimes skip controller rollout-budget accounting. Give hosts an optional callback to account for inference spending and signal budget exhaustion. ## What changed - Add `AgentUsageAccounting`, `AgentUsageReport`, and `UsageAccountingDecision`, captured at startup and supported by host child spawn reservations. - Await per-response usage reports with thread and turn attribution, including provider budget units and foreground and background compaction usage. - Map host exhaustion to `SessionBudgetExceeded` and accounting failures to fatal errors without retrying inference. Preserve the original error for incomplete responses. - Keep controller accounting unchanged and leave accounting disabled for host-owned runtimes without a provider. ## Testing Add coverage for usage attribution, child accounting, budget exhaustion, nonretryable accounting failures, incomplete responses, and compaction reporting, including background usage charged once to its originating turn. GitOrigin-RevId: 887703f50fe882497e4e8cb33259072935ec82e0
This commit is contained in:
@@ -358,6 +358,7 @@ async fn run_compact_task_inner_impl(
|
||||
e.details(),
|
||||
CodexErrorDetails::SessionBudgetExceeded
|
||||
| CodexErrorDetails::ResponseIncomplete(_)
|
||||
| CodexErrorDetails::Fatal(_)
|
||||
) =>
|
||||
{
|
||||
return Err(e);
|
||||
|
||||
Reference in New Issue
Block a user