Clarify realtime v2 context and handoff messages (#17896)

## Summary
- wrap realtime startup context in
`<startup_context>...</startup_context>` tags
- prefix V2 mirrored user text and relayed backend text with `[USER]` /
`[BACKEND]`
- remove the V2 progress suffix and replace the final V2 handoff output
with a short completion acknowledgement while preserving the existing V1
wrapper

## Testing
- cargo test -p codex-api
realtime_v2_session_update_includes_background_agent_tool_and_handoff_output_item
-- --exact
- cargo test -p codex-app-server webrtc_v2_background_agent_
- cargo test -p codex-app-server webrtc_v2_text_input_is_
- cargo test -p codex-core conversation_user_text_turn_is_
This commit is contained in:
bxie-openai
2026-04-15 16:26:20 -07:00
committed by GitHub
parent 18d61f6923
commit c2bdb7812c
10 changed files with 133 additions and 27 deletions

View File

@@ -1670,7 +1670,7 @@ mod tests {
);
assert_eq!(
third_json["item"]["output"],
Value::String("\"Agent Final Message\":\n\ndelegated result".to_string())
Value::String("delegated result".to_string())
);
});

View File

@@ -45,9 +45,11 @@ pub(super) fn conversation_handoff_append_message(
handoff_id: String,
output_text: String,
) -> RealtimeOutboundMessage {
let output_text = format!("{AGENT_FINAL_MESSAGE_PREFIX}{output_text}");
match event_parser {
RealtimeEventParser::V1 => v1_conversation_handoff_append_message(handoff_id, output_text),
RealtimeEventParser::V1 => v1_conversation_handoff_append_message(
handoff_id,
format!("{AGENT_FINAL_MESSAGE_PREFIX}{output_text}"),
),
RealtimeEventParser::RealtimeV2 => {
v2_conversation_handoff_append_message(handoff_id, output_text)
}