🤖 fix: improve orchestrator dependency sequencing #2054
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Tighten the Orchestrator built-in agent guidance so it reliably sequences dependent
execsubtasks and only parallelizes patches that can apply + verify independently.Background
We occasionally spawn a second
exectask whose implementation/verification depends on outputs from the first task. Since child workspaces snapshot at spawn time andexecagents are instructed not to expand scope, the dependent task can become blocked or forced into scope expansion.Implementation
Validation
make static-check📋 Implementation Plan
Improve Orchestrator dependency reasoning (task decomposition + sequencing)
Context / Why
The Orchestrator agent (
src/node/builtinAgents/orchestrator.md) currently encourages batching “independent” subtasks in parallel, with a brief sequential fallback note.In practice it sometimes spawns a second
exectask whose work/verification depends on artifacts produced by the first task (e.g., new schema download targets/files). Becauseexecsub-agents are instructed not to expand scope, the dependent task can become impossible to complete cleanly without either:Goal: update the Orchestrator prompt so it reliably (1) detects dependency chains, (2) sequences prerequisite tasks and integrates their patches before spawning dependents, and (3) only parallelizes truly mergeable/standalone tasks.
Evidence (repo facts consulted)
src/node/builtinAgents/orchestrator.mdrun_in_background: true.src/node/builtinAgents/exec.mdexecagents: “Take a single narrowly scoped task… Do not expand scope.”src/node/services/tools/task.ts+src/common/utils/tools/toolDefinitions.tstaskhas onlyrun_in_backgroundfor sequencing; there is no first-classdependsOnDAG concept.run_in_background:falseortask_await.Recommended approach (A): prompt-only improvements (fast + low risk)
Net LoC estimate (product code): ~+60 / -10 (mostly
src/node/builtinAgents/orchestrator.md).Implementation details
1) Strengthen Orchestrator rules for dependency analysis before batching
File:
src/node/builtinAgents/orchestrator.mdAdd an explicit “Dependency analysis (required)” section above “Patch integration loop (default)”. Make it checklist-style to reduce ambiguity.
Key rules to add:
Suggested prompt snippet (shape only; adjust wording to match file tone):
2) Make “Sequential fallback” operational (concrete steps)
Replace the current one-line “Sequential fallback” with an explicit protocol:
Rationale: queued/background tasks inherit the repo snapshot at spawn time; spawning dependents too early makes them work from the wrong base and pushes them toward scope expansion.
3) Update the Orchestrator → Exec task brief template to include dependencies/assumptions
In
src/node/builtinAgents/orchestrator.md, extend the template with a dedicated section:This gives child agents an explicit “escape hatch” aligned with
exec.md(report blockers rather than guessing/expanding scope).4) Add a short concrete example tied to the failure mode
Add a 6–10 line example showing why “schema download” must precede “generator uses schema files”. Keep it generic, but concrete enough that the model recognizes the pattern.
Example (paraphrased):
Optional follow-up (B): first-class task dependencies in code (stronger enforcement)
Net LoC estimate (product code): ~+250–450.
Only do this if prompt-only changes aren’t sufficient.
Idea
Add an explicit dependency field (e.g.,
dependsOnWorkspaceIds: string[]) to the workspace/task schema and teachTaskServiceto avoid starting tasks until prerequisites arereported.Caveat (important)
Because child workspaces are created at
taskService.create()time, “dependency-aware queueing” alone may still start tasks from the wrong repo snapshot if prerequisites land later.To fully solve this, dependency enforcement likely needs to:
Likely touchpoints
src/common/orpc/schemas/project.ts: extend workspace/task schema.src/common/utils/tools/toolDefinitions.ts: optionaldependsOnparam totasktool.src/node/services/taskService.ts: enforce dependency readiness when starting queued tasks.WorkspaceListItem.Why not jump straight to code-level dependencies?
Prompt-only updates are low-risk and align with the current tool model (
run_in_background:false+ patch-apply between steps). A code-level DAG is more correct long-term, but it’s easy to implement part of it (queueing) while still leaving the core problem (repo snapshot correctness) unsolved.Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh• Cost:$1.83