Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions codex-rs/app-server-protocol/schema/json/ClientRequest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions codex-rs/core/src/codex_delegate_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async fn forward_events_cancelled_while_send_blocked_shuts_down_delegate() {
status: None,
call_id: "call-1".to_string(),
name: "tool".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down
9 changes: 9 additions & 0 deletions codex-rs/core/src/context_manager/history_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
status: None,
call_id: "tool-1".to_string(),
name: "js_repl".to_string(),
namespace: None,
input: "view_image".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down Expand Up @@ -582,6 +583,7 @@ fn for_prompt_strips_images_when_model_does_not_support_images() {
status: None,
call_id: "tool-1".to_string(),
name: "js_repl".to_string(),
namespace: None,
input: "view_image".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down Expand Up @@ -1090,6 +1092,7 @@ fn remove_first_item_handles_custom_tool_pair() {
status: None,
call_id: "tool-1".to_string(),
name: "my_tool".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down Expand Up @@ -1378,6 +1381,7 @@ fn normalize_adds_missing_output_for_custom_tool_call() {
status: None,
call_id: "tool-x".to_string(),
name: "custom".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
}];
Expand All @@ -1393,6 +1397,7 @@ fn normalize_adds_missing_output_for_custom_tool_call() {
status: None,
call_id: "tool-x".to_string(),
name: "custom".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down Expand Up @@ -1512,6 +1517,7 @@ fn normalize_mixed_inserts_and_removals() {
status: None,
call_id: "t1".to_string(),
name: "tool".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down Expand Up @@ -1556,6 +1562,7 @@ fn normalize_mixed_inserts_and_removals() {
status: None,
call_id: "t1".to_string(),
name: "tool".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down Expand Up @@ -1668,6 +1675,7 @@ fn normalize_adds_missing_output_for_custom_tool_call_panics_in_debug() {
status: None,
call_id: "tool-x".to_string(),
name: "custom".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
}];
Expand Down Expand Up @@ -1810,6 +1818,7 @@ fn normalize_mixed_inserts_and_removals_panics_in_debug() {
status: None,
call_id: "t1".to_string(),
name: "tool".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/session/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10482,6 +10482,7 @@ async fn fatal_tool_error_stops_turn_and_reports_error() {
status: None,
call_id: "call-1".to_string(),
name: "shell_command".to_string(),
namespace: None,
input: "{}".to_string(),
internal_chat_message_metadata_passthrough: None,
};
Expand Down
10 changes: 8 additions & 2 deletions codex-rs/core/src/session/turn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2080,8 +2080,14 @@ async fn try_run_sampling_request(
}
}
ResponseEvent::OutputItemAdded(item) => {
if let ResponseItem::CustomToolCall { call_id, name, .. } = &item {
let tool_name = ToolName::plain(name.as_str());
if let ResponseItem::CustomToolCall {
call_id,
name,
namespace,
..
} = &item
{
let tool_name = ToolName::new(namespace.clone(), name.as_str());
active_tool_argument_diff_consumer = tool_runtime
.create_diff_consumer(&tool_name)
.map(|consumer| (call_id.clone(), consumer));
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/stream_events_utils_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ fn external_context_pollution_items_exclude_local_tool_calls() {
status: None,
call_id: "custom-1".to_string(),
name: "apply_patch".to_string(),
namespace: None,
input: "*** Begin Patch\n*** End Patch\n".to_string(),
internal_chat_message_metadata_passthrough: None,
},
Expand Down
5 changes: 3 additions & 2 deletions codex-rs/core/src/tools/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use tracing::instrument;

pub use crate::tools::context::ToolCallSource;

#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct ToolCall {
pub tool_name: ToolName,
pub call_id: String,
Expand Down Expand Up @@ -147,11 +147,12 @@ impl ToolRouter {
ResponseItem::ToolSearchCall { .. } => Ok(None),
ResponseItem::CustomToolCall {
name,
namespace,
input,
call_id,
..
} => Ok(Some(ToolCall {
tool_name: ToolName::plain(name),
tool_name: ToolName::new(namespace, name),
Comment thread
nhamidi-oai marked this conversation as resolved.
call_id,
payload: ToolPayload::Custom { input },
})),
Expand Down
29 changes: 29 additions & 0 deletions codex-rs/core/src/tools/router_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,35 @@ async fn build_tool_call_uses_namespace_for_registry_name() -> anyhow::Result<()
Ok(())
}

#[tokio::test]
async fn build_custom_tool_call_uses_namespace_for_registry_name() -> anyhow::Result<()> {
Comment thread
nhamidi-oai marked this conversation as resolved.
let tool_name = "exec".to_string();

let call = ToolRouter::build_tool_call(ResponseItem::CustomToolCall {
id: None,
status: None,
call_id: "call-namespace".to_string(),
name: tool_name.clone(),
namespace: Some("mcp__python".to_string()),
input: "print('hello')".to_string(),
internal_chat_message_metadata_passthrough: None,
})?
.expect("custom_tool_call should produce a tool call");

assert_eq!(
call,
ToolCall {
tool_name: ToolName::namespaced("mcp__python", tool_name),
call_id: "call-namespace".to_string(),
payload: ToolPayload::Custom {
input: "print('hello')".to_string(),
},
}
);

Ok(())
}

#[tokio::test]
async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
let (_, turn) = make_session_and_context().await;
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/turn_timing_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ fn response_item_records_turn_ttft_for_first_output_signals() {
status: None,
call_id: "call-2".to_string(),
name: "custom".to_string(),
namespace: None,
input: "echo hi".to_string(),
internal_chat_message_metadata_passthrough: None,
}
Expand Down
Loading
Loading