mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
## What changed - Store `Arc<dyn AgentControl>` in session services and route agent tools, turn admission, usage accounting, completion notifications, and shared settings through the trait. - Add `AgentControlInit` so delegated and guardian sessions inherit the parent's controller and local runtime. - Move local registry and context helpers to `LocalAgentRuntime`, keep resume, close, inspection, and status subscriptions on the local controller, and simplify synchronous and infallible trait methods. GitOrigin-RevId: ad3f213eb483ac524bde56d769f20a78f20989a0
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
use super::session::Session;
|
|
use super::turn_context::TurnContext;
|
|
use crate::context::ContextualUserFragment;
|
|
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 agent_control = &sess.services.agent_control;
|
|
let Some(reminder) = agent_control
|
|
.pending_budget_reminder(sess.thread_id(), window_id)
|
|
.await
|
|
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;
|
|
agent_control
|
|
.mark_budget_reminder_delivered(sess.thread_id(), window_id, reminder)
|
|
.await;
|
|
}
|
|
|
|
impl Session {
|
|
pub(crate) async fn record_rollout_budget_usage(&self, usage: &TokenUsage) -> CodexResult<()> {
|
|
self.services
|
|
.agent_control
|
|
.record_usage(usage.clone())
|
|
.await
|
|
}
|
|
}
|