fix(orchestrator): Expose pending delegated child work - #4793
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR adds new orchestrator capability to expose pending child work state through multiple new fields. An unresolved high-severity comment identifies a potential logic bug in You can customize Macroscope's approvability policy. Learn more. |
e1056de to
4df5866
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4df5866. Configure here.
a6f4edd to
e87ea74
Compare

Summary
Expose whether a delegated child thread has later work pending without changing
the established meaning of the original delegation fields.
childRunId,status,summary, andresultContextTransferIdstay tied tothe original
delegate_taskrun. NewhasPendingChildRunsandlatestTerminal*fields let callers avoid treating a busy child as idle andinspect its newest meaningful terminal result.
This replaces the earlier broader implementation. The branch no longer changes
current-run selection, per-follow-up result finalization, wake policy, or
task_cancelbehavior.Problem and Fix
task_statusintentionally reported the original delegated run, but provided no indication that the same child thread had a queued or executing follow-up. A caller could seecompletedand act on a workspace the child was still changing.hasPendingChildRuns, derived from nonterminal runs with a later ordinal than the delegated run, while preserving the original delegation fields.latestTerminalRunId,latestTerminalStatus,latestTerminalSummary, andlatestTerminalResultContextTransferId. Rolled-back runs and never-started later cancellations do not displace a meaningful result.subagent_spawntransfer selected the latest child run as the delegated run, which could hide later active work.Validation
passes: cancelling a completed original task does not interrupt a later child
run.
STATUS_FIRST_DONE.hasPendingChildRunswas true, and the latest terminal result stayed onordinal 1.
STATUS_SECOND_DONE, pending became falseand
latestTerminalRunIdadvanced to ordinal 2 while primary fieldsremained unchanged.
Bugbot, and Macroscope Effect Service Conventions pass.
newer
t3code/codex-turn-mappingmerge result. Check is separately red fromthe known Vite+ stdout panic while printing warnings.
Checklist
Note
Medium Risk
Extends the orchestrator MCP result schema and changes legacy delegated-run selection; callers relying on old semantics or latest-run fallback could misread status, though primary fields are intentionally preserved and cancel/wake behavior is unchanged.
Overview
Delegated task MCP responses now report follow-up child activity without changing what the original delegation fields mean.
childRunId,status,summary, andresultContextTransferIdstill describe the firstdelegate_taskrun.task_statusanddelegate_taskresults addhasPendingChildRuns(true when any later child run is still queued or executing) andlatestTerminal*fields that surface the highest-ordinal meaningful terminal run that actually started, including summary andsubagent_resulttransfer id. Rolled-back runs and never-started cancellations are excluded from that “latest” view. Context transfer resolution now prefers transfers whosesourcePoint.runIdmatches the run in question.For legacy child projections without a
subagent_spawntransfer,delegatedTaskRunnow uses the first run inchildProjection.runsinstead of the latest run, so primary status stays on the original delegation.Contracts, orchestrator MCP tool descriptions, and the orchestration reference doc are updated; integration and contract tests cover follow-ups, pending state, and cancellation isolation.
Reviewed by Cursor Bugbot for commit e87ea74. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Expose pending delegated child work in orchestrator
task_statusresponseshasPendingChildRunsandlatestTerminal*fields (latestTerminalRunId,latestTerminalStatus,latestTerminalSummary,latestTerminalResultContextTransferId) toOrchestratorMcpDelegateTaskResultso callers can distinguish follow-up child runs from the original delegated run.hasPendingChildRunshelper returns true when the child projection contains non-terminal runs with a higher ordinal than the delegated run, signaling that additional work is in progress.latestTerminal*fields reflect the highest-ordinal meaningful terminal run, excludingrolled_backand never-started cancellations;resultContextTransferIdresolution now prefers transfers whosesourcePoint.runIdmatches the run.delegatedTaskRunnow returns the first run inchildProjection.runsfor legacy projections without asubagent_spawntransfer, instead of the previously computed latest run.Macroscope summarized e87ea74.