xenonstack-logo

Decision Intelligence

Enterprise AI

XenonStack BlogDynamic Workflow Harness: A Runtime That Builds a Workflow for Every Task

| Published

Key takeaway

  • Dynamic workflows build a task-specific workflow at run time and discard it afterwards. Reference architecture, six patterns and governance for enterprises.

What is a dynamic workflow harness? It is a runtime that compiles a task-specific workflow at execution time from governed building blocks, executes it durably, verifies the result and records every decision along the way. The workflow is no longer designed up front: a runtime builds one for each task, then throws it away. For enterprises, the value and the risk sit in what surrounds that runtime: context, a governed capability registry and decision traces.

TL;DR for leaders

  • The shift: the workflow is no longer designed up front. A runtime builds one for each task, then throws it away.
  • The proof: a 750,000-line Zig-to-Rust port finished in 11 days with 99.8% of tests passing, using this pattern.
  • The enterprise gap: context, a governed capability registry and decision traces. That is where the value, and the risk, now sits.

Claude Code's dynamic workflows make a new idea practical: instead of one agent carrying a whole job, Claude writes a custom orchestration script for each task, spawns a team of fresh-context subagents in parallel, and throws the harness away when the job is done. For enterprises, the lesson goes beyond coding: every task deserves a workflow built for it, running inside guardrails that never move.

The Problem: Two Architectures, Two Failure Modes

Enterprises built automation in two waves, and each fails in a predictable place.

Static workflows (BPM, RPA, DAG pipelines) are designed once and run many times. They are auditable and cheap, but they only cover the paths someone anticipated. The long tail of exceptions, which is where the real work and cost live, falls back to people.

Free-roaming agents handle the long tail in demos. In production, nobody can say in advance what the agent will do, nobody can say afterwards why it did it, cost varies by an order of magnitude between runs, and one bad tool call can write to a system of record.

Static workflows are governable but brittle. Autonomous agents are adaptive but ungovernable. The resolution is the dynamic workflow harness.

The Reference Implementation: Dynamic Workflows in Claude Code

Dynamic workflows in Claude Code are self-authored, ephemeral, multi-agent harnesses. Claude writes a JavaScript orchestration script on the fly, and a runtime executes it in the background to spawn, route and coordinate isolated subagents in parallel.

Why one context window is not enough

When a single context carries a long task end to end, three failure modes appear:

  • Agentic laziness: the agent starts thoroughly, then skips files or assumes the rest is similar, and reports the whole job done.
  • Self-preferential bias: asked to judge its own output, the agent gives itself the benefit of the doubt.
  • Goal drift: over many steps, constraints such as "do not skip any file" quietly fall away.

How workflows fix it

The plan moves out of the model's head and into code. The script holds the loop, the branching and the intermediate results. Each subagent holds only its own slice in a fresh context. Claude receives only the final answer.

A workflow can run dozens to hundreds of agents per run, the orchestration itself is repeatable, and runs are resumable. The script is small and readable:

const found = await agent('List every .ts file under src/routes/.')
const audits = await pipeline(found.files, file =>
  agent(`Audit ${file} for missing authentication checks.`))
return audits.filter(Boolean)

The proof point

Jarred Sumner, creator of Bun, used this pattern (one unit of work, an adversarial review, then apply) to port roughly 750,000 lines of Zig to Rust, with 99.8% of the existing test suite passing, 11 days from first commit to merge.

What Is a Dynamic Workflow Harness?

A harness is everything around the model that turns reasoning into reliable work. The model decides; the harness plans, binds, executes, checks and remembers. Agent = Model + Harness.

A dynamic harness adds one property: the workflow is an output of the run, not an input to it. Three properties separate it from earlier waves:

  • Plans are artifacts. The workflow is a structured object that can be validated, diffed, approved and replayed.
  • Freedom is bounded by the registry. The planner can only compose capabilities that exist in a governed registry, each with an owner, schema and risk tier.
  • Every run leaves a decision trace. Inputs, context, policies evaluated, alternatives rejected and approvals given are recorded as data.

Reference Architecture: Seven Layers

Only one layer, the planner, changes from task to task. The other six make that flexibility safe.

LayerWhat it does
1. Intake and intentTurns an email, ticket or event into a task contract (objective, constraints, risk tier, SLA)
2. Context assemblyResolves entities and fetches the policies, data and precedents this task needs, just in time
3. PlannerCompiles the contract and context into an explicit task graph with budgets and gates
4. Capability registryThe governed catalogue of tools, skills, sub-agents and connectors
5. Durable executorRuns the graph in parallel, with checkpoints, retries and human gates
6. VerifierChecks every output against its contract and source data; a failed check replans from the last checkpoint
7. Governance and decision traceWraps every layer, enforcing policy and recording why each decision was made

Mapped to Claude Code: Claude is the planner, the script is the task graph, the workflow runtime is the executor, and verifier agents are the verification layer. What an enterprise must add is the context layer, the governed registry and the decision trace. That is the layer ElixirData builds with Context OS.

Six Composable Patterns

Most real tasks chain two or three of these:

PatternHow it worksExample
Classify-and-actA classifier routes each item to a specialised subagentSort an inbound backlog into billing, technical and legal
Fan-out-and-synthesizeSplit the job across clean contexts, then mergeQuery ERP, CRM and the contract store at once, then reconcile
Adversarial verificationEvery finding gets a critic whose only job is to disprove itA skeptic tries to refute each compliance gap before it reaches the report
Generate-and-filterProduce many candidates, keep only those that pass a strict rubricTwenty remediation options, three survive policy and cost checks
TournamentPairwise comparisons advance winners through a bracketRank 400 resumes or vendor bids head to head
Loop-until-doneKeep running until a programmatic gate confirms zero new findingsScan for policy violations until two rounds find nothing new

Operating Dynamic Workflows: Triggers, Budgets and Limits

  • Manual trigger: ask for "a workflow", include the keyword ultracode in a prompt, or run a bundled command such as /deep-research.
  • Ultracode mode: /effort ultracode makes Claude plan a workflow for every substantive task in the session.
  • Budget and size: state a token budget in the prompt and set a workflow size guideline. Claude Code flags runs above 25 agents or 1.5M projected tokens.
  • Reuse: save a good run as a team command or ship it in a plugin.

Three practices that keep runs disciplined

  1. Review the script before it runs. Narrowing scope up front removes whole categories of noise.
  2. Put the strongest model on orchestration, not everywhere. A cheaper worker model can burn its price advantage in extra tokens.
  3. Write specific prompts. Isolated agents still inherit a vague brief.

When not to use them

Workflows consume substantially more tokens than a single-agent session. Avoid them for:

  • Simple or routine tasks that fit in one context window
  • Deep, sequential tasks where nothing runs in parallel
  • Work with no measurable correctness bar
  • Tasks that need human sign-off mid-run

Use them when the task is wide, too large for one context, and expensive to get wrong.

Context, Memory and Decision Traces

Models rarely fail on enterprise tasks because they reason poorly. They fail because they reason over the wrong, stale or incomplete facts. A production harness manages three tiers:

TierLifetimeWhat it holds
Working contextOne stepThe exact facts the model needs now
Run stateOne taskPlan, step outputs, checkpoints, open approvals
Institutional memoryYearsEntities, policies, precedents, decision traces

The most undervalued asset is the decision trace. A log tells you what happened; a trace tells you why: inputs used, policy version evaluated, alternatives rejected, who approved. Traces compound. They make runs auditable, become precedents for the next plan, and turn into evaluation datasets.

Governance Inside the Harness, Not Around It

Governance bolted on afterwards produces reports. Governance built in prevents incidents. It acts at three moments:

  • Plan time: policy-as-code validates the whole graph before anything runs.
  • Action time: every tool call is checked with its live arguments.
  • After the outcome: evaluators score the result and the trace is written.

Every capability carries a risk tier:

Risk tierControl
ReadScoped credentials, data-residency check
Reversible writePolicy check, logged with trace
Financial or customer-facing writeThreshold-based human approval
Irreversible or regulatedMandatory approval and dual control

A regulator does not ask whether the model is accurate. They ask who decided, on what basis, under which policy, and whether you can prove it.

Worked Example: One Disputed Invoice, End to End

  1. Intake: a customer disputes being billed for 1,200 units when only 1,000 arrived.
  2. Context: the harness resolves the customer across ERP, CRM and contracts, and pulls precedent decisions.
  3. Plan: a precedent plan is adapted and validated against policy.
  4. Execute: three workers fetch invoice, delivery and contract terms in parallel.
  5. Verify: a verifier catches two partial shipments and replans only that step.
  6. Decide: the variance exceeds the auto-approval limit, so a finance approver gets a one-page summary.
  7. Act and record: a credit note posts through a run-scoped credential; the trace becomes the next precedent.

No one designed this workflow in advance. No one would accept it if it were improvised invisibly either. The harness made it explicit, checked it, ran it, repaired it and proved it.

Maturity: Where Are You Today?

LevelDescription
Level 0 · Scripts and botsStatic automations; exceptions go to humans
Level 1 · Assisted agentsCopilots suggest; humans execute
Level 2 · Governed single-task agentsFixed workflows with approvals
Level 3 · Dynamic workflow harnessPlans compiled per task, validated, traced
Level 4 · Self-improving decision infrastructureTraces feed precedents and evals; the harness improves every week

On build versus buy: the model is a commodity you should be able to swap; your skills, policies and context are yours to build; the executor, policy engine and trace store are infrastructure. Insist on plans as inspectable artifacts, action-time policy enforcement, model portability, and decision traces you own.

What Should Leaders Do Next?

  1. Pick one high-volume, exception-heavy process and measure how much falls outside today's static workflows.
  2. Stand up a capability registry before adding more agents.
  3. Write your top ten policies as code and enforce them at plan time and action time.
  4. Make decision traces a data product with a schema and an owner.
  5. Measure tasks completed without escalation, cost per decision and audit findings, not prompt accuracy.

This is the layer XenonStack calls Decision Infrastructure: context, policy, orchestration and memory working together so that every task runs on a workflow built for it and accountable for its outcome.

The question for leadership teams is no longer whether agents can do the work. It is whether your organisation has the harness to let them do it safely, every time.

Scope Your First Dynamic Workflow

In a Context Workshop, XenonStack works with your process and platform owners to pick one exception-heavy process, define its task contract, context and risk tiers, and scope the harness on ElixirData with agents running on ElixirClaw. Related reading: Harness Engineering for Enterprise AI.

Book a Context Workshop  |  Explore ElixirClaw Agentic OS

Frequently Asked Questions

How is a dynamic workflow different from a static workflow?

A static workflow is designed once and run many times, so it only covers anticipated paths. A dynamic workflow is compiled for each task at run time from governed building blocks, then discarded.

Why not let one autonomous agent handle the whole task?

A single context carrying a long task tends to skip work, judge its own output too kindly and lose constraints over many steps. Splitting the work across fresh-context subagents with separate verifiers addresses all three.

What must an enterprise add to a dynamic workflow runtime?

A context layer, a governed capability registry and decision traces. These decide what the planner may compose, on which facts, and what evidence is kept.

When should dynamic workflows be avoided?

For simple tasks that fit in one context window, deep sequential work with no parallelism, work with no measurable correctness bar, and tasks that need human sign-off mid-run.

What is a decision trace?

A record of why a decision was made: the inputs used, the policy version evaluated, the alternatives rejected and who approved. It makes runs auditable and becomes a precedent for later plans.

Sources and further reading

  • Orchestrate subagents at scale with dynamic workflows, Claude Code documentation
  • A Harness for Every Task: Putting a Team of Claudes on One Job, Towards Data Science
  • A harness for every task: dynamic workflows in Claude Code, Thariq Shihipar, Anthropic

This article first appeared in Navdeep Singh Gill's LinkedIn newsletter, AI + Human = Human Squared.

Explore the XenonStack Platform and Agent Network

Platforms: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AutonomousOps · CohortIQ · AI Aviator · SAIF Aviator

AI agents: AgentAnalyst · AgentEvaluation · AgentForce · AgentGRC · AgentHR · AgentInstruct · AgentLabel · AgentPixel · AgentQA · AgentRAI · AgentScrum · AgentSearch · AgentSketch · AgentSRE

XenonStack: xenonstack.com · xenonstack.ai · xenonstack.ae · xenonstack.jobs

Table of Contents

navdeep-singh-gill

Navdeep Singh Gill

Global CEO and Founder of XenonStack

LinkedIn profile

Navdeep Singh Gill is serving as Chief Executive Officer and Product Architect at XenonStack. He holds expertise in building SaaS Platform for Decentralised Big Data management and Governance, AI Marketplace for Operationalising and Scaling. His incredible experience in AI Technologies and Big Data Engineering thrills him to write about different use cases and its approach to solutions.

Get the latest articles in your inbox

Subscribe Now

Interested in Solving your Challenges with XenonStack Team

Get Started

Get Started with your requirements and primary focus, that will help us to make your solution

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Proceed Next