mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Recheck rollout budgets before starting tool work (#61578)
## Why A rollout budget can be exhausted while a tool call waits for an execution slot, approval, or a lifecycle callback. Checking only when scheduling the call can allow new work to start after the budget is exhausted. ## What changed - Recheck the budget after acquiring an execution slot, immediately before starting a handler, and immediately before handing an MCP request to the server. - Report refused calls as aborted in tool outputs, lifecycle callbacks, and dispatch traces, while allowing already-running work to complete. - Track handler start time separately from dispatch waiting and preserve terminal outcomes when cancellation arrives during completion callbacks. ## Testing Add regression coverage for queued calls and calls paused in start callbacks when the budget is exhausted. Verify MCP requests are blocked before handoff and retain successful results after handoff, and assert budget-stop state during remote compaction. GitOrigin-RevId: 573730391452256592d3512f15929a2fbdf03c57
This commit is contained in:
@@ -19,6 +19,11 @@ pub trait ToolOutput: Send {
|
||||
|
||||
fn success_for_logging(&self) -> bool;
|
||||
|
||||
/// Whether the call was refused before its underlying operation started.
|
||||
fn was_aborted(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Finalizes output using the same completed handler duration reported in tool-call logs.
|
||||
/// Called before recording model-visible history; implementations must not measure time here.
|
||||
fn set_handler_duration_ms(&mut self, _handler_duration_ms: u64) {}
|
||||
@@ -92,6 +97,10 @@ where
|
||||
(**self).success_for_logging()
|
||||
}
|
||||
|
||||
fn was_aborted(&self) -> bool {
|
||||
(**self).was_aborted()
|
||||
}
|
||||
|
||||
fn set_handler_duration_ms(&mut self, handler_duration_ms: u64) {
|
||||
(**self).set_handler_duration_ms(handler_duration_ms);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user