Files
codex/codex-rs/core/src/agent/agent_resolver.rs
T
jif 0b23f365f8 Route agent lookups and V2 context through AgentControl (#47536)
## 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
2026-09-23 11:07:41 +00:00

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()),
})
}