mirror of
https://github.com/openai/codex.git
synced 2026-05-21 19:45:26 +00:00
## Summary - rename the core codex module root to session/mod.rs without using #[path] - move the codex module directory and tests under core/src/session - remove session/mod.rs reexports so call sites use explicit child module paths ## Testing - cargo test -p codex-core --lib - cargo check -p codex-core --tests - just fmt - just fix -p codex-core - git diff --check
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
use crate::function_tool::FunctionCallError;
|
|
use crate::session::session::Session;
|
|
use crate::session::turn_context::TurnContext;
|
|
use codex_protocol::ThreadId;
|
|
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> {
|
|
register_session_root(session, turn);
|
|
if let Ok(thread_id) = ThreadId::from_string(target) {
|
|
return Ok(thread_id);
|
|
}
|
|
|
|
session
|
|
.services
|
|
.agent_control
|
|
.resolve_agent_reference(session.conversation_id, &turn.session_source, target)
|
|
.await
|
|
.map_err(|err| match err {
|
|
codex_protocol::error::CodexErr::UnsupportedOperation(message) => {
|
|
FunctionCallError::RespondToModel(message)
|
|
}
|
|
other => FunctionCallError::RespondToModel(other.to_string()),
|
|
})
|
|
}
|
|
|
|
fn register_session_root(session: &Arc<Session>, turn: &Arc<TurnContext>) {
|
|
session
|
|
.services
|
|
.agent_control
|
|
.register_session_root(session.conversation_id, &turn.session_source);
|
|
}
|