Include terminal errors in turn completion events (#32280)

## What changed

- Add an optional `error` payload to `TurnCompleteEvent` and omit it when a turn completes without an error.
- Preserve the full terminal `ErrorEvent` through the turn lifecycle so the completion event includes the same error details emitted separately by `EventMsg::Error`.

## Testing

- Extend the stream-error integration test to verify that `TurnCompleteEvent` contains the emitted error and that the next turn can still proceed.

GitOrigin-RevId: 8d32942a44132763076130102d8b89ab356d59d0
This commit is contained in:
Owen Lin authored and copyberry committed 2026-07-10 22:04:03 +00:00
1 parent 09ccae2c07
commit c4318c386d
19 files changed
+92 -6

No files matched your search

@@ -1560,6 +1560,7 @@ async fn multi_agent_v2_list_agents_returns_completed_status_without_encrypted_s
turn_id: child_turn.sub_id.clone(),
started_at: None,
last_agent_message: Some("done".to_string()),
error: None,
completed_at: None,
duration_ms: None,
time_to_first_token_ms: None,
@@ -2010,6 +2011,7 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
turn_id: first_turn.sub_id.clone(),
started_at: None,
last_agent_message: Some("first done".to_string()),
error: None,
completed_at: None,
duration_ms: None,
time_to_first_token_ms: None,
@@ -2052,6 +2054,7 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
turn_id: second_turn.sub_id.clone(),
started_at: None,
last_agent_message: Some("second done".to_string()),
error: None,
completed_at: None,
duration_ms: None,
time_to_first_token_ms: None,