CDX-301h · Module 3
Adaptive Workflows
3 min read
Adaptive workflows change their structure based on runtime conditions. Unlike static pipelines where every step is predetermined, adaptive workflows let the supervisor alter the plan mid-execution. If a worker discovers that the task is harder than expected, the supervisor can re-decompose. If a worker finishes early, the supervisor can assign it additional work. If a quality gate reveals a systemic issue, the supervisor can insert a remediation step that was not in the original plan.
The key mechanism for adaptive workflows is the supervisor's feedback loop. After each worker completes (or fails), the supervisor reassesses the pipeline state: what has been done, what remains, what has changed. This reassessment may trigger plan modifications — adding tasks, removing tasks, reordering tasks, or changing model assignments. The supervisor's instructions must explicitly authorize this adaptability: "You may modify the pipeline plan based on worker results."
from agents import Agent, Runner
adaptive_supervisor = Agent(
name="adaptive-supervisor",
model="o3",
instructions="""
You manage an adaptive development pipeline.
After each worker completes:
1. Review the worker's output and quality gate results
2. Reassess the remaining plan:
- Are there new tasks revealed by the worker's output?
- Should any remaining tasks be re-scoped?
- Should model assignments change based on observed complexity?
3. Update .codex/plan.json with any modifications
4. Delegate the next task (original or modified)
Adaptation triggers:
- Worker reports unexpected complexity → escalate model
- Quality gate reveals pattern violation → add remediation task
- Worker finishes early → assign bonus tasks from backlog
- Two workers produce conflicting outputs → add reconciliation task
Constraints:
- Maximum 3 plan modifications per pipeline run
- Log every modification with justification
- Never remove mandatory tasks from the plan
""",
)
Do This
- Authorize the supervisor to adapt the plan — static plans break on contact with reality
- Limit the number of adaptations per pipeline run to prevent thrashing
- Log every plan modification with the trigger event and justification
- Use structured plan files (.codex/plan.json) so modifications are auditable
Avoid This
- Allow unlimited plan modifications — the supervisor will spend more time planning than executing
- Adapt on minor variations — save adaptation budget for significant events like failures and quality violations
- Let the supervisor modify mandatory tasks — core deliverables should be immutable
- Skip the reassessment loop — a supervisor that does not adapt is just a static pipeline with extra overhead