@vintcessun: LLMs can now write their own work scripts, decomposing tasks into a group of sub-agents that execute in parallel. A single assistant thinks sequentially, and when faced with tasks like codebase audits or large-scale refactoring, it's either slow or prone to mixing up its thoughts. pi-dynamic-workflows lets the model directly generate a JS script, using agent() and parallel() for task orchestration, runs them in a sandbox, and then aggregates the results—with real-time progress display. The essence is transforming "one person working" into "one person writing a scheduling script, while minions execute in parallel."

X AI KOLs Timeline Tools

Summary

Introducing pi-dynamic-workflows, a tool that enables LLMs to dynamically orchestrate multiple sub-agents for parallel task execution by generating JavaScript scripts, suitable for code audits, large-scale refactoring, and similar scenarios.

LLMs can now write their own work scripts, decomposing tasks into a group of sub-agents that execute in parallel. A single assistant thinks sequentially, and when faced with tasks like codebase audits or large-scale refactoring, it's either slow or prone to mixing up its thoughts. pi-dynamic-workflows lets the model directly generate a JS script, using agent() and parallel() for task orchestration, runs them in a sandbox, and then aggregates the results—with real-time progress display. The essence is transforming "one person working" into "one person writing a scheduling script, while minions execute in parallel."
Original Article
View Cached Full Text

Cached at: 05/31/26, 07:03 AM

It turns out LLMs can also write their own work scripts, distributing tasks to a group of sub-agents for parallel execution. When a single assistant thinks sequentially, tasks like codebase audits and large-scale refactors are either slow or lose coherence. pi-dynamic-workflows lets the model directly generate a JS script, using agent() and parallel() for task orchestration, running it in a sandbox and then aggregating—with real-time progress display. Essentially, it transforms “one person working” into “one person writing a scheduling script, with minions executing in parallel.”


Michaelliv/pi-dynamic-workflows

Source: https://github.com/Michaelliv/pi-dynamic-workflows

pi-dynamic-workflows

Claude-Code-style dynamic workflows for Pi (https://github.com/earendil-works/pi).

A Pi extension that adds a workflow tool. Instead of one assistant doing everything sequentially, the model writes a small JavaScript script that fans out the work across many isolated subagents, then synthesizes the results. Great for codebase audits, multi-perspective review, large refactors, and fan-out research.

Inspired by Anthropic’s dynamic workflows in Claude Code (https://claude.com/blog/introducing-dynamic-workflows-in-claude-code).

Install

pi install npm:pi-dynamic-workflows
# or from a local checkout
pi install /path/to/pi-dynamic-workflows

Then in Pi:

/reload

That’s it. The extension registers a workflow tool and activates it on session start.

Usage

Just ask Pi for a workflow in plain language:

Run a workflow to inspect this repository and summarize the main modules.

The model will write a workflow script and call the workflow tool. Live progress shows up inline:

◆ Workflow: inspect_project (3/3 done)
    ✓ Scan 1/1 #1 ✓ repo inventory
    ✓ Analyze 2/2 #2 ✓ source modules
                  #3 ✓ final summary

Press Esc to cancel a running workflow. Active subagents are aborted and surfaced as skipped.

Workflow script shape

A workflow is plain JavaScript. The first statement must export literal metadata. name and description are required; phases is optional documentation for an expected outline. The live progress view is driven by phase(...) calls at runtime:

export const meta = {
  name: 'inspect_project',
  description: 'Inspect a repository and summarize the main modules',
  phases: [
    { title: 'Scan' },
    { title: 'Analyze' },
  ],
}

phase('Scan')
const inventory = await agent('Inspect the repository structure.', {
  label: 'repo inventory',
})

phase('Analyze')
const summary = await agent(
  'Summarize the main modules from this inventory:\n' + inventory,
  { label: 'module summary' },
)

return { inventory, summary }

Phases are discovered as the script runs, so conditional and loop-created phases work naturally. If a branch is skipped, its phase does not show up as an empty progress row.

Editor IntelliSense

Reusable workflow files can opt into editor hints for workflow globals:

/// <reference types="pi-dynamic-workflows/globals" />

This declares agent, parallel, pipeline, phase, log, args, cwd, and budget for TypeScript-aware editors.

Available globals

GlobalDescription
agent(prompt, opts)Spawn an isolated subagent. Returns its final text or, with opts.schema, a validated object.
parallel(thunks)Run an array of () => agent(...) thunks concurrently. Results are returned in input order.
pipeline(items, ...stages)Run each item through sequential stages while items fan out. Each stage receives (prev, original, index).
phase(title)Mark the current phase. Used for grouping in the live progress view.
log(message)Append a workflow-level log line.
argsOptional JSON value passed in via the tool’s args parameter.
cwd, process.cwd()Current working directory for subagents.
budget{ total, spent(), remaining() } token budget tracker.

Determinism rules

Workflow scripts are evaluated inside a Node vm sandbox. The following are intentionally unavailable:

  • Date.now(), new Date()
  • Math.random()
  • require, import, fs, network APIs
  • spreads, computed keys, template interpolation, function calls inside meta

This keeps meta parseable, runs reproducible, and the surface area small.

Structured subagent output

Pass a JSON Schema via opts.schema and the subagent will return a validated object:

const finding = await agent('Find security-sensitive files.', {
  label: 'security scan',
  schema: {
    type: 'object',
    properties: {
      paths: { type: 'array', items: { type: 'string' } },
      reason: { type: 'string' },
    },
    required: ['paths', 'reason'],
  },
})

Under the hood this is a Pi structured_output tool with terminate: true, so the subagent ends on that call without an extra assistant turn.

How it works

user prompt → Pi model writes a workflow script → workflow tool parses + runs script in a vm sandbox → script calls agent(), parallel(), pipeline() → each agent() spawns an in-memory Pi subagent session → snapshots stream back as compact progress → final structured result returned to the parent assistant

Subagents run in fresh in-memory Pi sessions with the standard coding tools, so they can read files, run shell commands, and call structured output exactly like a normal Pi turn.

Library modules

FilePurpose
src/workflow.tsAST-validated parser and sandboxed workflow runtime.
src/workflow-tool.tsThe Pi workflow tool, prompt guidelines, rendering, abort handling.
src/agent.tsWorkflowAgent, an in-memory Pi subagent runner.
src/structured-output.tsTerminating structured-output tool backed by TypeBox/JSON Schema.
src/display.tsWorkflow snapshots and compact text renderers.
extensions/workflow.tsThe Pi extension entrypoint.

Development

npm install
npm test    # biome check + tsc + unit tests
npm run dev

Parser unit tests live in tests/workflow-parser.test.ts and cover both accepted and rejected script shapes.

Status

This is a prototype. It implements the core workflow primitive (script, subagents, parallel/pipeline, phases, abort, structured output) but does not yet implement persisted or resumable runs, or a /workflows manager.

License

MIT

Similar Articles

@wsl8297: Discovered a recursive multi-agent framework on GitHub: ROMA (Recursive Open Meta-Agent). It solves complex problems through a hierarchical recursive structure, decomposes tasks into parallelizable components, and enables agents to handle more intricate reasoning tasks. GitH…

X AI KOLs Timeline

ROMA is a recursive multi-agent framework built on DSPy, designed to solve complex reasoning tasks through a hierarchical recursive structure. It supports task decomposition, parallel processing, and multiple LLM providers.

@geekbb: pi-workflow is a workflow orchestration tool designed for Pi, enabling Pi to execute multi-step, reusable workflows instead of just single-turn conversations. It can be triggered with natural language, no need to write prompts every time. Four workflows ready to use: - deep-research for deep research - dee…

X AI KOLs Timeline

pi-workflow is a workflow orchestration tool designed for the Pi AI assistant, enabling it to execute multi-step, repeatable workflows, including deep research, code review, specification check, and impact assessment. It defines workflows as JSON stage graphs and supports multiple execution modes.

@Xudong07452910: The best AI coding workflow might be to let AI gradually solidify its instability into a system. The author developed a source code management system for the LLM era using Fable, and the experience is very real: the model is smart, can read large amounts of code, raise issues, and fix problems, but it also makes very low-level mistakes, such as committing the build/ directory twice…

X AI KOLs Timeline

A blog post discusses the need to complement brilliant but clumsy LLMs with deterministic tools and formal workflows, using the author's experience developing the Beagle SCM with Fable as an example.

@elliotchen100: On the surface, Claude Code can generate its own workflow; looking deeper, the control plane of agent products is changing. In the past, we stuffed complex tasks into a long context, expecting the model to remember the goal, break down steps, and judge completion; now these things are starting to be externalized into executable har…

X AI KOLs Timeline

The article points out that behind Claude Code's ability to automatically generate workflows, it reflects that the control plane of AI agent products is shifting from relying on long contexts to remember goals and decompose steps, towards externalizing into an executable harness, including task structure, permission boundaries, verification mechanisms, and stop conditions.