mirror of
https://github.com/openai/codex.git
synced 2026-04-29 00:55:38 +00:00
Add notify to code-mode (#14842)
Allows model to send an out-of-band notification. The notification is injected as another tool call output for the same call_id.
This commit is contained in:
@@ -389,6 +389,7 @@ async fn resume_replays_legacy_js_repl_image_rollout_shapes() {
|
||||
timestamp: "2024-01-01T00:00:02.000Z".to_string(),
|
||||
item: RolloutItem::ResponseItem(ResponseItem::CustomToolCallOutput {
|
||||
call_id: "legacy-js-call".to_string(),
|
||||
name: None,
|
||||
output: FunctionCallOutputPayload::from_text("legacy js_repl stdout".to_string()),
|
||||
}),
|
||||
},
|
||||
@@ -546,6 +547,7 @@ async fn resume_replays_image_tool_outputs_with_detail() {
|
||||
timestamp: "2024-01-01T00:00:02.500Z".to_string(),
|
||||
item: RolloutItem::ResponseItem(ResponseItem::CustomToolCallOutput {
|
||||
call_id: custom_call_id.to_string(),
|
||||
name: None,
|
||||
output: FunctionCallOutputPayload::from_content_items(vec![
|
||||
FunctionCallOutputContentItem::InputImage {
|
||||
image_url: image_url.to_string(),
|
||||
@@ -1898,6 +1900,7 @@ async fn azure_responses_request_includes_store_and_reasoning_ids() {
|
||||
});
|
||||
prompt.input.push(ResponseItem::CustomToolCallOutput {
|
||||
call_id: "custom-tool-call-id".into(),
|
||||
name: None,
|
||||
output: FunctionCallOutputPayload::from_text("ok".into()),
|
||||
});
|
||||
|
||||
|
||||
@@ -1551,6 +1551,44 @@ text({ json: true });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn code_mode_notify_injects_additional_exec_tool_output_into_active_context() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = responses::start_mock_server().await;
|
||||
let (_test, second_mock) = run_code_mode_turn(
|
||||
&server,
|
||||
"use exec notify helper",
|
||||
r#"
|
||||
notify("code_mode_notify_marker");
|
||||
await tools.test_sync_tool({});
|
||||
text("done");
|
||||
"#,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let req = second_mock.single_request();
|
||||
let has_notify_output = req
|
||||
.inputs_of_type("custom_tool_call_output")
|
||||
.iter()
|
||||
.any(|item| {
|
||||
item.get("call_id").and_then(serde_json::Value::as_str) == Some("call-1")
|
||||
&& item
|
||||
.get("output")
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.is_some_and(|text| text.contains("code_mode_notify_marker"))
|
||||
&& item.get("name").and_then(serde_json::Value::as_str) == Some("exec")
|
||||
});
|
||||
assert!(
|
||||
has_notify_output,
|
||||
"expected notify marker in custom_tool_call_output item: {:?}",
|
||||
req.input()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn code_mode_exit_stops_script_immediately() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
@@ -1957,6 +1995,7 @@ text(JSON.stringify(Object.getOwnPropertyNames(globalThis).sort()));
|
||||
"isFinite",
|
||||
"isNaN",
|
||||
"load",
|
||||
"notify",
|
||||
"parseFloat",
|
||||
"parseInt",
|
||||
"store",
|
||||
|
||||
Reference in New Issue
Block a user