Skip to content

core: surface terminal subagent errors to parent agents#28375

Merged
jif-oai merged 7 commits into
mainfrom
jif/mav2-error-messag
Jun 16, 2026
Merged

core: surface terminal subagent errors to parent agents#28375
jif-oai merged 7 commits into
mainfrom
jif/mav2-error-messag

Conversation

@jif-oai

@jif-oai jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Why

When a subagent exhausts its retries, it emits an Error, but the generic task lifecycle then emits TurnComplete(None). That completion used to overwrite the subagent's Errored status with Completed(None), so the parent received an empty completion notification.

This made a failed child look indistinguishable from a child that completed without an answer. In unattended or long-running multi-agent work, the root could silently continue without knowing that delegated work failed or how to restart it.

Behavior

Before, a terminal stream failure was reduced to an empty completion:

<subagent_notification>
{"agent_path":"/root/worker","status":{"completed":null}}
</subagent_notification>

Now the parent receives the actual terminal error, bounded to 1,000 tokens, together with an actionable recovery hint:

<subagent_notification>
{
  "agent_path": "/root/worker",
  "status": {
    "errored": "stream disconnected before completion: stream closed before response.completed"
  },
  "next_action": "This agent's turn failed. If you still need this agent, use `followup_task` to give it another task."
}
</subagent_notification>

The notification remains queue-only: it does not wake the root or replay the failed request. The root sees it at the next sampling boundary and can use followup_task to start a new turn for that agent.

What changed

  • Added terminal-error precedence to the agent status reducer, so a closing TurnComplete cannot erase an immediately preceding Errored status.
  • Made MultiAgentV2 completion forwarding use the retained session status instead of re-deriving Completed(None) from the final event.
  • Extended the subagent notification fragment with a next_action for terminal errors and a hard cap on model-visible error text.
  • Kept successful completions and interrupted turns unchanged.

Verification

  • Added a status-reducer test proving that Errored survives the trailing TurnComplete.
  • Added an integration test that exhausts a subagent's stream retries and verifies the exact agent_message delivered to the parent, including the error and followup_task guidance.
  • Re-ran the existing successful-completion and interrupted-turn notification tests.

@jif-oai
jif-oai requested a review from a team as a code owner June 15, 2026 18:39
@jif-oai

jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@jif-oai jif-oai changed the title feat: mav2 error message core: surface terminal subagent errors to parent agents Jun 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e95fcfe2bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/agent/status.rs Outdated
Comment thread codex-rs/core/src/context/subagent_notification.rs Outdated
Comment thread codex-rs/core/src/context/subagent_notification.rs Outdated
@jif-oai

jif-oai commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f617f452c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs Outdated
Comment thread codex-rs/core/src/session/mod.rs Outdated
@jif-oai

jif-oai commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51bb6b2724

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs
@jif-oai

jif-oai commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 012c0600b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/session/mod.rs
Comment thread codex-rs/core/src/session/mod.rs
@jif-oai
jif-oai merged commit 1b24ba9 into main Jun 16, 2026
31 checks passed
@jif-oai
jif-oai deleted the jif/mav2-error-messag branch June 16, 2026 12:34
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant