mirror of
https://github.com/openai/codex.git
synced 2026-04-28 08:34:54 +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:
@@ -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