mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
## Why V2 tools and model context need to use the controller's agent tree even when the session's local runtime has no registry entries. ## What changed - Add target resolution and direct-child path lookup to `AgentControl`. - Move lazy root registration into the controller's resolution and listing methods. - Build V2 subagent context from controller-provided paths, keeping formatting and size limits in the session layer and preserving loaded-first ordering. ## Testing Extend the V2 spawn and messaging test with an empty session-local registry to cover relative-path resolution, message delivery, and subagent environment context through the controller. GitOrigin-RevId: c935b34a6d3314e968ba451ff981cf2a223bbfa8
31 lines
940 B
Rust
31 lines
940 B
Rust
use crate::function_tool::FunctionCallError;
|
|
use crate::session::session::Session;
|
|
use crate::session::turn_context::TurnContext;
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::error::CodexErrorDetails;
|
|
use std::sync::Arc;
|
|
|
|
/// Resolves a single tool-facing agent target to a thread id.
|
|
pub(crate) async fn resolve_agent_target(
|
|
session: &Arc<Session>,
|
|
turn: &Arc<TurnContext>,
|
|
target: &str,
|
|
) -> Result<ThreadId, FunctionCallError> {
|
|
session
|
|
.services
|
|
.agent_control
|
|
.resolve(
|
|
session.thread_id,
|
|
turn.parent_thread_id,
|
|
&turn.session_source,
|
|
target,
|
|
)
|
|
.await
|
|
.map_err(|err| match err.details() {
|
|
CodexErrorDetails::UnsupportedOperation(message) => {
|
|
FunctionCallError::RespondToModel(message.clone())
|
|
}
|
|
_ => FunctionCallError::RespondToModel(err.to_string()),
|
|
})
|
|
}
|