Skip to content

🤖 fix: resume parents directly from sub-agent reports - #3816

Merged
ammario merged 4 commits into
mainfrom
fix/prompt-free-subagent-resume
Aug 7, 2026
Merged

🤖 fix: resume parents directly from sub-agent reports#3816
ammario merged 4 commits into
mainfrom
fix/prompt-free-subagent-resume

Conversation

@ammar-agent

@ammar-agent ammar-agent commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Removes the redundant synthetic “Background sub-agent task(s) have completed…” handoff turn. Completed sub-agent reports and failures now resume the parent directly from the durable report rows already in conversation history.

The refactor also removes 1,001 net lines by collapsing terminal-attention branching and deleting tests coupled to the old prompt/output state machine.

Background

Sub-agent completion previously used a two-message handoff:

  1. persist the real report/failure into parent history
  2. start another visible synthetic user turn that only told the model the report was already present

That second turn surfaced as an AUTO chat bubble and forced a generic instruction into the transcript. Recent suppression logic only handled the narrow case where the parent had answered an incremental progress update, so normal background completions still showed the prompt.

Implementation

  • resume parent streams directly from existing terminal sub-agent report/failure rows instead of sending a second handoff message
  • make terminal report and failure rows visible, ordered append-only messages
  • reconstruct a missing terminal row from durable success/failure artifacts before resuming, preserving self-healing after failed history appends
  • correlate assistant responses with the highest history sequence included in their provider request, so a concurrently appended report is not incorrectly treated as consumed
  • supersede orphaned agent notifications without blocking valid workspace-turn or workflow notifications for the same owner
  • reduce active terminal-attention behavior to source identity plus delivery state while retaining the legacy output/outcome fields on disk for downgrade compatibility
  • retain explicit prompts only for sources whose output is not already in history (workspace-turn handles and workflow results)

Validation

  • bun test src/node/services/taskService.test.ts src/node/services/terminalAttentionStore.test.ts --timeout 30000 — 337 passing
  • bun test src/node/services/agentSession.startupAutoRetry.test.ts — 30 passing
  • bun test src/node/services/aiService.test.ts -t 'uses the latest durable boundary slice'
  • make typecheck
  • make static-check
  • verified production no longer contains or sends the completed/failed sub-agent handoff prompt; legacy prompt openings remain only for persisted timeline classification compatibility
  • diff: 665 insertions, 1,666 deletions (1,001 net lines removed)

Risks

Moderate, scoped to terminal background-work delivery. Workspace-turn and workflow wake prompts retain their existing behavior. Sub-agent completion now depends on resumeStream over durable history, with provider-request correlation, artifact-backed repair, orphan isolation, and upgrade/downgrade-compatible outbox records covering concurrency and restart cases.


Generated with mux • Model: openai:gpt-5.6-sol • Thinking: xhigh • Cost: $91.81

Remove the redundant synthetic completion handoff prompt and collapse terminal
attention records to source identity plus delivery state. Terminal reports and
failures now resume the parent directly from durable history, with artifact-backed
repair for missing rows and compatibility for legacy attention records.

---

_Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$48.40`_

<!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=48.40 -->
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the prompt-free terminal sub-agent resume refactor, especially crash recovery and mixed background-work delivery.

@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: c169080572

ℹ️ 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
Comment thread src/node/services/taskService.ts Outdated
Comment thread src/node/services/terminalAttentionStore.ts
Correlate assistant responses with the provider history snapshot, isolate orphaned
agent attention from unrelated work, and retain downgrade-compatible terminal
attention fields on disk.

---

_Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$91.81`_

<!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=91.81 -->
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Addressed all three Codex findings:

  • PRRT_kwDOPxxmWM6XHxVN (P1): assistant messages now persist the highest history sequence actually included in their provider request. Terminal attention is consumed only when that request sequence includes the report/failure row, so a concurrently appended report remains pending and triggers a follow-up resume.
  • PRRT_kwDOPxxmWM6XHxVR (P2): orphaned agent notifications are superseded independently. Valid workspace-turn/workflow notifications in the same drain continue normally, while transient report-row repair failures remain pending without blocking unrelated work.
  • PRRT_kwDOPxxmWM6XHxVT (P2): new outbox records continue writing the legacy outputDelivery and terminalOutcome fields. Current logic ignores those derived fields, but older strict readers can still process pending notifications after a downgrade.

Added regression coverage for each case and pushed the fixes in 47b14bcff.

@ammar-agent

Copy link
Copy Markdown
Collaborator Author

@codex review

Please take another look at the provider-request correlation, orphan isolation, and downgrade-compatible outbox fixes in 47b14bcff.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 47b14bcff8

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

The automatic pull_request workflow did not dispatch for the prior pushes; create
a new synchronize event after the manually dispatched full PR workflow passed.

---

_Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$91.81`_

<!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=91.81 -->
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

@codex review

The latest commit only retriggers CI after GitHub's Actions webhook outage; please confirm the reviewed code remains approved at the current head.

@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: 736b392a32

ℹ️ 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
Leave terminal attention pending after persistent prompt-free resume failures instead
of immediately waiting for idle and retrying forever. Busy no-op resumes still retry
when the workspace becomes idle.

---

_Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$91.81`_

<!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=91.81 -->
@ammar-agent

Copy link
Copy Markdown
Collaborator Author

Addressed PRRT_kwDOPxxmWM6XINr_ (P1) in f183c00a1:

  • persistent resumeStream errors now leave terminal attention pending without scheduling an immediate idle retry
  • only the successful started: false busy/no-op case waits for the owner to become idle and retries
  • added regression coverage proving a persistent budget/model-style error performs one resume attempt, does not register an idle waiter, and keeps the notification pending

Local task tests, typecheck, and make static-check pass.

@ammar-agent

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the final persistent-resume-error fix in f183c00a1.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: f183c00a10

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

@ammario
ammario merged commit 75b1412 into main Aug 7, 2026
39 of 40 checks passed
@ammario
ammario deleted the fix/prompt-free-subagent-resume branch August 7, 2026 01:15
@mux-bot mux-bot Bot mentioned this pull request Aug 7, 2026
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.

2 participants