Skip to content

🤖 fix: settle child tasks when auto-retry abandons - #3809

Open
ammar-agent wants to merge 2 commits into
mainfrom
fix/subagent-auto-retry-abandon-unblock-parent
Open

🤖 fix: settle child tasks when auto-retry abandons#3809
ammar-agent wants to merge 2 commits into
mainfrom
fix/subagent-auto-retry-abandon-unblock-parent

Conversation

@ammar-agent

Copy link
Copy Markdown
Collaborator

Summary

Unblock parent agents when a child sub-agent hits a stream error that never recovers via auto-retry, instead of leaving waitForAgentReport / workspace-turn waiters hanging until timeout.

Background

Child stream errors that schedule in-session auto-retry intentionally leave parent waiters blocked so a successful retry can complete the turn. Two failure modes left the parent blocked with no recovery path:

  1. Retry scheduled, then abandoned — e.g. missing_retry_options or retry callback failure. TaskService only listened to stream error events, not auto-retry-abandoned chat events, so abandonment never settled the handle.
  2. No recovery in flight — auto-retry disabled / immediately exhausted. Workspace-turn handles already settled in this case; agent tasks did not, so parents waited out the report timeout.

Implementation

  • Cache the last stream error per child workspace so abandon settlement can surface the original error text.
  • Listen for workspaceService chatauto-retry-abandoned and terminally settle active workspace-turn handles and agent tasks (except disabled_by_user, which remains a steerable pause).
  • For agent tasks still running, after waiting for the stream-error recovery decision, settle immediately when nothing is streaming/retrying (parity with workspace-turn handling). Keep aborted / context_exceeded non-terminal.
  • Clear the cached stream error on stream-end and on terminal settlement.

Validation

  • bun test src/node/services/taskService.test.ts -t "auto-retry abandoned|running tasks are NOT settled|running tasks settle immediately|model_refusal|awaiting_report tasks interrupt|workspace-turn auto-retry"
  • make typecheck

Risks

  • Medium: settlement timing around auto-retry races. Mitigated by waiting for the recovery decision, re-checking streaming/pending-retry under the workspace event lock, and excluding user-disabled retries and recoverable abort/context paths.

Generated with mux • Model: xai:grok-4.5 • Thinking: high

When a sub-agent hits a stream error that schedules auto-retry, the parent
stays blocked waiting for the child. If that retry is later abandoned
(missing resume options, retry callback failure) or never starts (auto-retry
disabled), settle the child terminally so the parent is not blocked forever.
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 9807881796

ℹ️ 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 src/node/services/taskService.ts Outdated
Use Record<StreamErrorType, true> so new schema values fail typecheck
instead of silently dropping the original error on auto-retry abandon.
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the P2: stream-error allowlist is now an exhaustive Record<StreamErrorType, true> so schema additions fail typecheck instead of silently losing the original error on abandon settlement.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: dfbc5893f7

ℹ️ 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant