mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
[codex] Steer budget-limited goal extension turns (#23718)
## What - Add a small extension capability for injecting model-visible response items into the active turn - Have the goal extension inject hidden goal-context steering when tool-finish accounting reaches `BudgetLimited` - Cover the extension backend path with an assertion on the injected steering item ## Why PR #23696 persists and emits the budget-limited goal update from tool-finish accounting, but it leaves the model unaware of that transition. The existing core runtime steers the model to wrap up in this case; the extension path should do the same through an explicit host capability. ## Testing - `just fmt` - `cargo test -p codex-goal-extension` - `cargo test -p codex-extension-api`
This commit is contained in:
1 parent
20fedafff8
commit
791b69dd53
14 files changed
+298
-34
No files matched your search
@@ -17,6 +17,7 @@ struct GoalAccountingInner {
|
||||
current_turn_id: Option<String>,
|
||||
turns: HashMap<String, GoalTurnAccounting>,
|
||||
wall_clock: GoalWallClockAccounting,
|
||||
budget_limit_reported_goal_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -102,6 +103,9 @@ impl GoalAccountingState {
|
||||
pub(crate) fn mark_turn_goal_active(&self, turn_id: &str, goal_id: impl Into<String>) {
|
||||
let mut inner = self.inner();
|
||||
let goal_id = goal_id.into();
|
||||
if inner.budget_limit_reported_goal_id.as_deref() != Some(goal_id.as_str()) {
|
||||
inner.budget_limit_reported_goal_id = None;
|
||||
}
|
||||
if let Some(turn) = inner.turns.get_mut(turn_id) {
|
||||
turn.active_goal_id = Some(goal_id.clone());
|
||||
if inner.current_turn_id.as_deref() == Some(turn_id) {
|
||||
@@ -117,6 +121,9 @@ impl GoalAccountingState {
|
||||
let mut inner = self.inner();
|
||||
let turn_id = inner.current_turn_id.clone()?;
|
||||
let goal_id = goal_id.into();
|
||||
if inner.budget_limit_reported_goal_id.as_deref() != Some(goal_id.as_str()) {
|
||||
inner.budget_limit_reported_goal_id = None;
|
||||
}
|
||||
let turn = inner.turns.get_mut(turn_id.as_str())?;
|
||||
turn.active_goal_id = Some(goal_id.clone());
|
||||
turn.reset_baseline_to_current();
|
||||
@@ -131,6 +138,7 @@ impl GoalAccountingState {
|
||||
turn.active_goal_id = None;
|
||||
}
|
||||
inner.wall_clock.clear_active_goal();
|
||||
inner.budget_limit_reported_goal_id = None;
|
||||
Some(turn_id)
|
||||
}
|
||||
|
||||
@@ -178,6 +186,9 @@ impl GoalAccountingState {
|
||||
if clear_active_goal {
|
||||
inner.wall_clock.clear_active_goal();
|
||||
}
|
||||
if status != ThreadGoalStatus::BudgetLimited {
|
||||
inner.budget_limit_reported_goal_id = None;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn finish_turn(&self, turn_id: &str) {
|
||||
@@ -188,6 +199,15 @@ impl GoalAccountingState {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn mark_budget_limit_reported_if_new(&self, goal_id: &str) -> bool {
|
||||
let mut inner = self.inner();
|
||||
if inner.budget_limit_reported_goal_id.as_deref() == Some(goal_id) {
|
||||
return false;
|
||||
}
|
||||
inner.budget_limit_reported_goal_id = Some(goal_id.to_string());
|
||||
true
|
||||
}
|
||||
|
||||
fn inner(&self) -> std::sync::MutexGuard<'_, GoalAccountingInner> {
|
||||
self.inner.lock().unwrap_or_else(PoisonError::into_inner)
|
||||
}
|
||||
@@ -221,6 +241,7 @@ impl Default for GoalAccountingInner {
|
||||
current_turn_id: None,
|
||||
turns: HashMap::new(),
|
||||
wall_clock: GoalWallClockAccounting::new(),
|
||||
budget_limit_reported_goal_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user