mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Handle partial answers in realtime routing and thread search (#51260)
## Why Messages with the `partial_answer` phase contain answer text without declaring a terminal answer. They should remain searchable and speakable without being treated as final messages. ## What changed - Preserve explicit `partial_answer` phases in streamed and completed realtime handoffs, bypassing legacy channel-prefix parsing and routing them to the `speakable` channel. - Treat partial answers as nonterminal in V1 handoffs and omit the final-message prefix. - Include partial answers in thread occurrence searches and normalize them to the final conversation channel in rollout traces. ## Testing Extend coverage for realtime phase routing, streamed and completed handoffs, partial-answer search results, and rollout normalization. Verify that turn summaries still exclude nonterminal messages. GitOrigin-RevId: aa183da783f6e7e0b78ddd51073cba533297e121
This commit is contained in:
@@ -125,7 +125,13 @@ FROM (
|
||||
ON turns.thread_id = items.thread_id
|
||||
AND turns.turn_id = items.turn_id
|
||||
WHERE items.thread_id = ?
|
||||
AND items.item_type = 'userMessage'
|
||||
AND (
|
||||
items.item_type = 'userMessage'
|
||||
OR (
|
||||
items.item_type = 'agentMessage'
|
||||
AND json_extract(items.item_json, '$.phase') = 'partial_answer'
|
||||
)
|
||||
)
|
||||
AND items.rollout_ordinal >= ?
|
||||
AND items.rollout_ordinal < ?
|
||||
AND turns.rollout_ordinal >= ?
|
||||
|
||||
@@ -1769,7 +1769,7 @@ WHERE thread_id = ? AND turn_id = ?
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn summary_items_use_final_answers_and_ignore_commentary() {
|
||||
async fn summary_items_use_final_answers_and_ignore_nonterminal_messages() {
|
||||
let home = TempDir::new().expect("temp dir");
|
||||
let config = test_config(home.path());
|
||||
let thread_id = ThreadId::default();
|
||||
@@ -1815,6 +1815,11 @@ async fn summary_items_use_final_answers_and_ignore_commentary() {
|
||||
"turn-1",
|
||||
agent_message("commentary-1", MessagePhase::Commentary),
|
||||
),
|
||||
completed_item(
|
||||
thread_id,
|
||||
"turn-1",
|
||||
agent_message("partial-1", MessagePhase::PartialAnswer),
|
||||
),
|
||||
completed_item(
|
||||
thread_id,
|
||||
"turn-1",
|
||||
@@ -1877,11 +1882,16 @@ WHERE thread_id = ? AND turn_id = ?
|
||||
"turn-2",
|
||||
agent_message("commentary-2", MessagePhase::Commentary),
|
||||
),
|
||||
completed_item(
|
||||
thread_id,
|
||||
"turn-2",
|
||||
agent_message("partial-2", MessagePhase::PartialAnswer),
|
||||
),
|
||||
turn_completed("turn-2"),
|
||||
],
|
||||
})
|
||||
.await
|
||||
.expect("append commentary-only turn");
|
||||
.expect("append turn without a final answer");
|
||||
|
||||
let summary = store
|
||||
.list_turns(ListTurnsParams {
|
||||
|
||||
Reference in New Issue
Block a user