mirror of
https://github.com/openai/codex.git
synced 2026-09-10 20:26:47 +00:00
## What changed - Wrap `CodexErrorDetails` and an optional retry delay in `CodexErr`, allowing any mapped error to preserve server-provided retry timing. - Generate the payload-free `CodexErrKind` classification alongside the error details and reuse it for analytics. - Update error handling sites to inspect `CodexErr::details()` while preserving existing display, debug, protocol mapping, and retryability behavior. ## Testing - Add coverage for legacy debug formatting, error-specific retryability, and retry-delay propagation through API error mapping. GitOrigin-RevId: d3ab8a305f2a2ee21d0c0a8c8c388b06dda9c59a
38 lines
1.2 KiB
Rust
38 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 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> {
|
|
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.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()),
|
|
})
|
|
}
|
|
|
|
fn register_session_root(session: &Arc<Session>, turn: &Arc<TurnContext>) {
|
|
session
|
|
.services
|
|
.agent_control
|
|
.register_session_root(session.thread_id, turn.parent_thread_id);
|
|
}
|