mirror of
https://github.com/openai/codex.git
synced 2026-11-10 21:00:47 +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
38 lines
1.4 KiB
Rust
38 lines
1.4 KiB
Rust
//! Reopens an agent only when its runtime is absent, then returns its effective state.
|
|
//! Rollout and descendant restoration remain in the existing local startup path.
|
|
|
|
use super::LocalAgentControl;
|
|
use crate::agent::types::LiveAgent;
|
|
use crate::codex_thread::ThreadConfigSnapshot;
|
|
use crate::config::Config;
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::error::CodexErrorDetails;
|
|
use codex_protocol::error::Result as CodexResult;
|
|
use codex_protocol::protocol::SessionSource;
|
|
|
|
impl LocalAgentControl {
|
|
pub(crate) async fn resume_agent(
|
|
&self,
|
|
config: Config,
|
|
thread_id: ThreadId,
|
|
source: SessionSource,
|
|
) -> CodexResult<(LiveAgent, ThreadConfigSnapshot)> {
|
|
let manager = self.runtime.upgrade()?;
|
|
let thread = match manager.get_thread(thread_id).await {
|
|
Ok(thread) => thread,
|
|
Err(err) if matches!(err.details(), CodexErrorDetails::ThreadNotFound(_)) => {
|
|
Box::pin(self.resume_agent_from_rollout(config, thread_id, source)).await?;
|
|
manager.get_thread(thread_id).await?
|
|
}
|
|
Err(err) => return Err(err),
|
|
};
|
|
let agent = LiveAgent {
|
|
thread_id,
|
|
metadata: self.get_agent_metadata(thread_id).unwrap_or_default(),
|
|
status: thread.agent_status().await,
|
|
};
|
|
let config = thread.config_snapshot().await;
|
|
Ok((agent, config))
|
|
}
|
|
}
|