Dynamic Workflows: Building Custom Task Harnesses with Claude
Prompt Engineeringgo watch the original →
the gist
Instead of forcing non-coding tasks into a single, bloated coding harness, dynamic workflows allow Claude to generate task-specific execution scripts that split work into isolated contexts to prevent agentic laziness, bias, and goal drift.
The Problem with Static Harnesses
Using a single coding harness for diverse knowledge work leads to three primary failure modes: agentic laziness, where the model quits early; self-preferential bias, where the model fails to critically evaluate its own output; and goal drift, where the original objective is lost as the context window fills. These issues stem from forcing complex, multi-step tasks into a single, monolithic context window.
Dynamic Workflow Patterns
Dynamic workflows solve these issues by using a JavaScript-based harness that spawns sub-agents in clean, isolated contexts. Anthropic identifies six core patterns for these custom harnesses:
- Classify and Act: A classifier agent routes incoming tasks to specialized agents based on type, or shapes the final output.
- Fan Out and Synthesize: A task is split across multiple agents running in parallel, with a final synthesis step that merges results into a single output.
- Critic and Rubric: A worker agent generates an output, which is then evaluated by a separate, adversarial critic agent against a specific rubric.
- Generate and Filter: Multiple hypotheses are generated and then passed through a filter to remove duplicates or low-quality results.
- Tournament Bracket: Agents compete head-to-head in pairs, with a judge selecting the winner to advance until a single champion remains.
- Loop Until Done: An agent runs until a conditional gate determines no further findings exist, preventing premature termination caused by context limits.
Implementation Considerations
Dynamic workflows allow for model selection per agent and can isolate work trees to prevent contamination. While these patterns significantly improve performance on messy, non-coding tasks like résumé ranking or root-cause analysis, they are computationally expensive. Users should monitor token usage and avoid over-engineering simple tasks that do not require a full panel of reviewers.