mirror of
https://github.com/openai/codex.git
synced 2026-11-09 20:50:33 +00:00
## Why History recording used the model captured at turn start, so switching models within a turn could apply stale image preparation and tool-output truncation rules. ## What changed Pass explicit model metadata through conversation recording. Record model responses and tool results using their originating step's settings, and capture the current model for pending input recorded during startup interruption or task completion. ## Testing Add regression coverage for tool results across a model switch, explicit model selection for plain and annotated history, and image input retained during interruption and completion. Extend model-switching tests to verify that prepared media and item identity survive switching back to a multimodal model in live, resumed, and forked threads. GitOrigin-RevId: 5bc750c30c334acb9b802cb80fdea01daffa84a1
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use super::session::Session;
|
|
use super::turn_context::TurnContext;
|
|
use crate::context::ContextualUserFragment;
|
|
use codex_protocol::error::CodexErr;
|
|
use codex_protocol::error::Result as CodexResult;
|
|
use codex_protocol::protocol::TokenUsage;
|
|
|
|
pub(super) async fn maybe_record_reminder(
|
|
sess: &Session,
|
|
turn_context: &TurnContext,
|
|
window_id: &str,
|
|
) {
|
|
let budget = sess.services.agent_control.rollout_budget();
|
|
let Some(reminder) = budget.pending_reminder(sess.thread_id(), window_id) else {
|
|
return;
|
|
};
|
|
let response_item = ContextualUserFragment::into(crate::context::RolloutBudgetContext {
|
|
remaining_tokens: reminder.remaining_tokens,
|
|
});
|
|
sess.record_conversation_items(
|
|
turn_context,
|
|
turn_context.model_info(),
|
|
std::slice::from_ref(&response_item),
|
|
)
|
|
.await;
|
|
budget.mark_reminder_delivered(sess.thread_id(), window_id, reminder);
|
|
}
|
|
|
|
impl Session {
|
|
pub(crate) fn record_rollout_budget_usage(&self, usage: &TokenUsage) -> CodexResult<()> {
|
|
if self
|
|
.services
|
|
.agent_control
|
|
.rollout_budget()
|
|
.record_usage(usage)?
|
|
{
|
|
return Err(CodexErr::SessionBudgetExceeded);
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|