Rename Realtime V2 tool to background_agent (#17278)

Rename the Realtime V2 delegation tool and parser constant to
background_agent, and update the tool description and fixtures to match.

Validation: just fmt; cargo check -p codex-api; git diff --check

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-04-09 22:17:55 -07:00
committed by GitHub
parent 9f2a585153
commit 60236e8c92
5 changed files with 34 additions and 32 deletions

View File

@@ -868,7 +868,7 @@ mod tests {
"item": {
"id": "item_123",
"type": "function_call",
"name": "codex",
"name": "background_agent",
"call_id": "call_123",
"arguments": "{\"prompt\":\"delegate this\"}"
}
@@ -989,7 +989,7 @@ mod tests {
"output": [{
"id": "item_123",
"type": "function_call",
"name": "codex",
"name": "background_agent",
"call_id": "call_123",
"arguments": "{\"prompt\":\"delegate from done\"}"
}]
@@ -1283,7 +1283,7 @@ mod tests {
assert_eq!(fourth_json["handoff_id"], "handoff_1");
assert_eq!(
fourth_json["output_text"],
"\"Agent Final Message\":\n\nhello from codex"
"\"Agent Final Message\":\n\nhello from background agent"
);
ws.send(Message::Text(
@@ -1407,7 +1407,7 @@ mod tests {
connection
.send_conversation_handoff_append(
"handoff_1".to_string(),
"hello from codex".to_string(),
"hello from background agent".to_string(),
)
.await
.expect("send handoff");
@@ -1493,7 +1493,7 @@ mod tests {
}
#[tokio::test]
async fn realtime_v2_session_update_includes_codex_tool_and_handoff_output_item() {
async fn realtime_v2_session_update_includes_background_agent_tool_and_handoff_output_item() {
let listener = TcpListener::bind("127.0.0.1:0").await.expect("bind");
let addr = listener.local_addr().expect("local addr");
@@ -1553,7 +1553,7 @@ mod tests {
);
assert_eq!(
first_json["session"]["tools"][0]["name"],
Value::String("codex".to_string())
Value::String("background_agent".to_string())
);
assert_eq!(
first_json["session"]["tools"][0]["parameters"]["required"],

View File

@@ -27,8 +27,8 @@ use serde_json::json;
const REALTIME_V2_OUTPUT_MODALITY_AUDIO: &str = "audio";
const REALTIME_V2_TOOL_CHOICE: &str = "auto";
const REALTIME_V2_CODEX_TOOL_NAME: &str = "codex";
const REALTIME_V2_CODEX_TOOL_DESCRIPTION: &str = "Delegate a request to Codex and return the final result to the user. Use this as the default action. If the user asks to do something next, later, after this, or once current work finishes, call this tool so the work is actually queued instead of merely promising to do it later.";
const REALTIME_V2_BACKGROUND_AGENT_TOOL_NAME: &str = "background_agent";
const REALTIME_V2_BACKGROUND_AGENT_TOOL_DESCRIPTION: &str = "Send a user request to the background agent. Use this as the default action. If the background agent is idle, this starts a new task and returns the final result to the user. If the background agent is already working on a task, this sends the request as guidance to steer that previous task. If the user asks to do something next, later, after this, or once current work finishes, call this tool so the work is actually queued instead of merely promising to do it later.";
pub(super) fn conversation_item_create_message(text: String) -> RealtimeOutboundMessage {
RealtimeOutboundMessage::ConversationItemCreate {
@@ -93,14 +93,14 @@ pub(super) fn session_update_session(
},
tools: Some(vec![SessionFunctionTool {
r#type: SessionToolType::Function,
name: REALTIME_V2_CODEX_TOOL_NAME.to_string(),
description: REALTIME_V2_CODEX_TOOL_DESCRIPTION.to_string(),
name: REALTIME_V2_BACKGROUND_AGENT_TOOL_NAME.to_string(),
description: REALTIME_V2_BACKGROUND_AGENT_TOOL_DESCRIPTION.to_string(),
parameters: json!({
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "The user request to delegate to Codex."
"description": "The user request to delegate to the background agent."
}
},
"required": ["prompt"],

View File

@@ -11,7 +11,7 @@ use serde_json::Map as JsonMap;
use serde_json::Value;
use tracing::debug;
const CODEX_TOOL_NAME: &str = "codex";
const BACKGROUND_AGENT_TOOL_NAME: &str = "background_agent";
const DEFAULT_AUDIO_SAMPLE_RATE: u32 = 24_000;
const DEFAULT_AUDIO_CHANNELS: u16 = 1;
const TOOL_ARGUMENT_KEYS: [&str; 5] = ["input_transcript", "input", "text", "prompt", "query"];
@@ -118,7 +118,7 @@ fn parse_conversation_item_done_event(parsed: &Value) -> Option<RealtimeEvent> {
fn parse_handoff_requested_event(item: &JsonMap<String, Value>) -> Option<RealtimeEvent> {
let item_type = item.get("type").and_then(Value::as_str);
let item_name = item.get("name").and_then(Value::as_str);
if item_type != Some("function_call") || item_name != Some(CODEX_TOOL_NAME) {
if item_type != Some("function_call") || item_name != Some(BACKGROUND_AGENT_TOOL_NAME) {
return None;
}

View File

@@ -493,7 +493,7 @@ async fn realtime_ws_e2e_realtime_v2_parser_emits_handoff_requested() {
"item": {
"id": "item_123",
"type": "function_call",
"name": "codex",
"name": "background_agent",
"call_id": "call_123",
"arguments": "{\"prompt\":\"delegate now\"}"
}