← Home

pi-realtime-workflows

Claude-Code-style realtime workflow orchestration for Pi


Links

Date

2026

Built a Pi extension that gives coding agents a realtime workflow system. Instead of asking one assistant to inspect, plan, execute, and review everything sequentially, the model can write a small JavaScript workflow that fans work out across isolated subagents and then synthesizes the results.

It is useful for codebase audits, multi-perspective reviews, broad refactors, and research tasks where the work naturally splits into independent branches.

How it feels

Ask Pi for a workflow in plain language:

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

The model writes a workflow script and calls the workflow tool. Progress streams inline while the subagents run:

Workflow: inspect_project (3/3 done)
  [x] Scan 1/1
    #1 [x] repo inventory
  [x] Analyze 2/2
    #2 [x] source modules
    #3 [x] final summary

Workflow scripts

Workflows are plain JavaScript evaluated inside a sandbox. The script declares metadata, marks phases, spawns agents, and returns a final result.

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:\n' + inventory, {
  label: 'module summary',
})

return { inventory, summary }

The runtime exposes agent, parallel, pipeline, phase, log, args, cwd, and budget. Each agent() call runs in its own fresh Pi subagent session with normal coding tools, structured output support, and its own usage accounting.

Realtime manager

The extension adds a /workflows manager: a focus-capturing, two-pane overlay for inspecting runs, phases, agents, and a single agent's detail view. The detail pane updates live while an agent runs, including current tool calls, elapsed time, model, token usage, cache reads, and cost.

+- Phases -------------------+- verify /users -------------------------------+
|  [x] Scan  1/1             |  > Running - Sonnet 4.6                       |
|> [ ] Verify  0/2 - running |  12.4k in - 5.2k out - 480.0k cached - $0.21  |
|                            |                                                |
|                            |  Activity - 4 tool calls so far                |
|                            |    Read(routes/users.ts)                       |
|                            |    Grep(requireAuth)                           |
|                            |    > Bash(rg -n "export const" routes/ ...)    |
+----------------------------+------------------------------------------------+

Runs can be paused, resumed, restarted, stopped, and inspected during the same Pi session. Completed agent results are journaled by deterministic call index, so resuming a workflow replays finished work and runs only the missing branch.

What changed from the base primitive

This fork builds on pi-dynamic-workflows and pushes the experience closer to Claude Code's dynamic workflows:

  • A /workflows manager with run, phase, agent, and detail navigation
  • Live agent activity instead of static prompts
  • Honest per-agent token and cost breakdown from each subagent session
  • Session-scoped pause, resume, restart, and stop controls
  • Structured output for subagents through JSON Schema
  • Deterministic sandbox rules for reproducible workflow scripts

Install

pi install git:github.com/sudodaksh/pi-realtime-workflows

Then reload Pi:

/reload