GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: nested sub-agent spawning (up to 5 levels) + multi-agent workflow orchestration by mguttmann · Pull Request #32167 · anomalyco/opencode

Conversation

@mguttmann

@mguttmann mguttmann commented Jun 13, 2026

Copy link
Copy Markdown

Issue for this PR

Proposal / design-review: #32166
Related (fixes): #23091, #13715 · (covers): #30899, #19999, #17994, #23784

Type of change

  • New feature

What does this PR do?

Adds nested sub-agent spawning and a multi-agent workflow layer on top of it. Three parts:

  1. Nested spawning (depth ≤ 5). A subagent can spawn its own subagents. Depth is derived from the existing parentID chain (Session.lineage), so no schema change is needed for the core. Spawns are bounded by four independent checks so a runaway tree can't form: a permission-deny at the limit, a resolve-time tool filter that removes task/workflow on the last level, a runtime guard in the task tool before it asks, and a config-free hard cap (depth 10) in Session.createNext. task_id resume is restricted to direct children — that's what closes the silent depth-3 hang in Nested Subagent Fails Silently in 3-Layer Deep Chain (Works Fine in 2-Layer) #23091 and the permission-ask deadlock in Permission asks from nested subagent sessions silently hang #13715 (asks are now routed to the tree root with origin metadata). The abort/cancel cascade and the TurnBudget pool both travel across the whole tree. One knob: experimental.subagent_max_depth (default 5; 2 = old behavior, 1 = off).

  2. Workflow orchestration. A deterministic layer to fan out / pipeline / synthesize work across sub-agents, with ctx.question/ctx.shell/nested ctx.workflow, event streaming, a TUI/desktop run view, headless opencode run --workflow, worktree isolation, an approval gate and a save endpoint. This is the larger and most opinionated part.

  3. Hardening/UX. Per-session fail-fast concurrency cap (deliberately not a tree-wide semaphore, which would deadlock foreground chains), experimental.subagent_tree_limit, optional depth/rootID wire fields, a TUI tree view with depth badges (Sub-agent nesting enabled #30899/[FEATURE]: Display subagent status in TUI prompt footer #23784), per-task timeout, and a display-only subtree cost rollup.

This is a large branch and most of the volume is the workflow subsystem. As noted in #32166 I'm happy to split this into focused PRs (nested spawning first, workflow layer separately) or drop the workflow part if only nesting is wanted — opening it whole here for visibility and review.

How did you verify your code works?

bun turbo typecheck passes 23/23. The nested, workflow, server, migration and TUI suites pass locally (the focused set is ~280 tests, the full opencode suite was green earlier at 3407). I also ran a real 5-level chain through the CLI (CEO → TL → L3 → L4 → L5) and confirmed the session tree in the DB shows the full parentID chain and that the task/workflow tools disappear on the last level. Migration consistency checked with the repo's script/migration.ts --check.

Screenshots / recordings

Live 5-level run, session tree from the DB:

ROOT             CEO
 └─ parent=CEO   Teamleiter (depth 2)
     └─ depth 3
         └─ depth 4
             └─ depth 5  (no task/workflow tool here)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Claude Agent and others added 30 commits June 5, 2026 15:54
Claude Agent @claude
test(opencode): failing tests for honest structured-output failures i…
d5a93d8
…n workflows

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): treat structured-output failures as step failures in w…
8d93271
…orkflows

When ctx.agent is called with a schema (structured output requested), the engine
previously ignored a session-side StructuredOutputError and silently fell back to
plaintext whenever message.info.structured was undefined, marking the step
completed. Both cases silently corrupted schema-based workflows.

The agent-result path now requires a structured result when a schema was
requested: a missing/failed structured result raises a WorkflowStructuredOutputError
(with a message naming what was expected and surfacing the session-side error) which
propagates through the existing agent-failure path — agent node failed, run failed
unless the module catches it. No plaintext fallback when a schema was requested.
Non-schema agents are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
refactor(opencode): simplify structured-output error construction
5c09cfa
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
test(opencode): failing tests for per-item pipeline semantics and par…
d84f084
…allel concurrency limit

The pipeline test fails: the current pipeline(items, steps) signature has no
per-item stage sequencing with heterogeneous types — passing variadic stages
crashes the run. The parallel concurrencyLimit test already passes and is kept
as a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): real per-item pipeline semantics with heterogeneous st…
af23e31
…age types

ctx.pipeline now runs each item through a SEQUENCE of stages (stage N+1 receives
stage N's result for that item plus the original item), while items run
concurrently against each other with NO barrier between stages — item B may
reach stage 2 while item A is still in stage 1. Stages may change the type
(I -> S1 -> S2 ...); the result is the last stage's output in item order.

Stages are passed as variadic arguments (not an array) with an optional trailing
{ concurrencyLimit } to cap how many items run at once. The public type is a
precise overloaded PipelineFn (1..4 stages, no any); internally unknown is
plumbed through the variadic impl. Cancellation checkpoints are kept: the signal
is gated before every stage so the next stage never starts after cancel.

Updates the exported plugin WorkflowContext typing and the docs pipeline example
(now typechecks against the real signature, verified via a scratch module that
imports the plugin types). parallel is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): consistent concurrencyLimit handling; pipeline docs no…
9d3f961
…te; tighten parallel test

- pipeline now clamps an explicit concurrencyLimit ≤0 to 1 (Math.max(1, …)),
  matching parallel; only an UNSET limit means unbounded.
- docs: note that single-stage pipelines must annotate the stage parameter
  (async (item: string) => …) to avoid TS7006; multi-stage pipelines infer.
- parallel test: add peak >= 2 lower bound to guard against over-clamping to 1.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
test(opencode): failing tests for workflow budget enforcement
0a277e2
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): enforce workflow budget instead of dead budgetRemainin…
d0b56cb
…g field

ctx.budgetRemaining was hardwired to Infinity, never decremented, never
enforced. Now start() accepts an optional `budget` (USD cost cap):
budgetRemaining tracks the live remaining value, is decremented after each
agent step by that step's actual cost telemetry (the same AgentRun.cost the
dashboard shows), and ctx.agent refuses to start a step once the budget is
exhausted, failing the run with a dedicated BudgetExceededError. Omitting the
budget preserves the unchanged Infinity (unlimited) default.

Plumbs `budget` through the engine StartInput, the plugin WorkflowContext type
(budgetRemaining now exported), the HTTP start payload (+ SDK regen), and the
workflow tool.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): charge budget for failed steps; reject negative budget…
88e82a8
…s; document best-effort cap

1. Move the budget decrement from the agent step's success branch into the
   existing Effect.ensuring, so a failed-but-paid step (e.g. a structured-output
   failure that still incurred model cost) and interrupted steps are charged by
   their actual telemetry cost too, not just successful ones.

2. Harden the budget schema against negative/NaN/Infinity caps: StartInput.budget,
   the HTTP StartPayload.budget, and the workflow tool param now use
   Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)). A plain Schema.Number on
   the tool param previously accepted NaN, which silently disabled the gate
   (effectively unlimited). Bad caps are now validation errors, not confusing
   runtime budget failures.

3. Document that the cap is enforced per step, best-effort: concurrent steps can
   collectively overspend by up to the cost of the steps in flight when the
   budget runs out (soft cap, not a hard mid-step limit).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
test(opencode): failing tests for declaration-aware workflow arg coer…
b25087d
…cion

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): respect declared workflow arg types in TUI arg parsing
19baab6
parseWorkflowArgs unconditionally coerced every numeric-looking value to a
number, so `version=1.0` lost its trailing zero (-> 1) and `zip=01234` lost
its leading zero (-> 1234) even when the workflow declared those args as
string. Coercion now follows the workflow's declared argument types: only
args declared `type: "number"` are coerced (and only when the value parses
as a finite number; otherwise the raw string passes through, since the engine
stores args untyped and runs no validation of its own). Undeclared args and
all non-number declarations keep their exact text. Bare flags keep the prior
string "true" behavior. The caller resolves the declaration via
listWorkflowInfos (which already drops invalid entries) so a broken file
never supplies a synthesized meta and an unknown name yields no declaration.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
fix(opencode): drop worfklow typo alias
34040ef
The PR-internal `worfklow` misspelling was wired into the workflow
autocomplete patterns/aliases and the TUI command dispatch. It is a typo,
not a legacy API alias, so remove it everywhere.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
refactor(opencode): branded WorkflowRunID
e2a1141
Run ids were raw `Schema.String`, indistinguishable from any other string
at the type level. Introduce a branded `RunID` schema following the repo's
ID convention (cf. SessionID/MessageID in session/schema.ts): a `job_`-
prefixed string carrying a `WorkflowRunID` brand, minted via `RunID.ascending()`.

Apply the brand through the engine's `Run` schema, the lookup-method
signatures (get/wait/cancel/remove), and the internal finish path. The brand
decode boundary sits at the engine/HTTP edge: `fromRow` re-brands the opaque
core `text` column (core cannot import the engine's brand), the HTTP handler
brands route params, and the workflow tool brands its `run_id` arg.

Brand is type-level only: the `isStartsWith("job")` check serializes to plain
`string` in OpenAPI (same as SessionID), so the SDK gen is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent @claude
refactor(opencode): import pipeline/context types from plugin as sing…
692e556
…le source of truth

The engine `workflow.ts` hand-duplicated the pipeline-stage / parallel-option
types that already live in `@opencode-ai/plugin/workflow` (byte-equivalent,
~34 lines). opencode depends on the plugin, so the plugin is the SSoT: the
engine now imports `WorkflowParallelOptions`/`WorkflowPipelineOptions`/
`WorkflowPipelineStage`/`WorkflowPipelineFn` and re-exports them under its
short names. Workflow modules and the engine now see the SAME types and any
drift in the plugin definitions is a compile error.

For the run-context shapes (`ContextApi` engine view vs `WorkflowContext`
plugin authoring view) a full SSoT import is not clean — they differ on
purpose (readonly producer vs consumer contract, narrower engine AgentInput)
— so a compile-time assignability assertion guards against drift instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
refactor(core): single source of truth for workflow row types; assert…
d7c8f22
… engine schemas against them

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
fix(opencode): track workflow persistRun forks in instance scope
63b3670
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
fix(opencode): accept permissionSessionID on workflow HTTP start
42b668f
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
docs(opencode): security and trust note for workflow files
99fe541
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
refactor(opencode): brand permissionSessionID at the schema boundary …
767d661
…like session endpoints

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
test(opencode): cover workflow tool create, inspect, background mode,…
4d05181
… wait timeout, permission gate

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
fix(opencode): validate workflow run id at the params schema boundary
12650ed
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
test(opencode): httpapi exercise scenarios for all six workflow endpo…
409ea79
…ints

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
fix(opencode): snapshot run state at persist execution time
b98857d
Scope-forked progress writes can execute after the awaited terminal write in
finish(); a snapshot captured at effect construction then reverts the row to a
stale 'running' state. Found by live TUI/serve smoke; building the snapshot
inside Effect.suspend makes every write carry the current state so any
ordering converges on the final row.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude
chore(opencode): merge upstream feat/workflows head (skill instructio…
021f765
…ns, temp-file loadModule, reload test)

Adopts VasyaYovbak's 8a9c3b6+024d784cd: expanded workflows-instructions,
temp-file based loadModule (reliable realtime reload), and his reload test.
Keeps all fix-branch semantics (cancel, orphan sweep, resilient list, honest
structured output, budget, SSoT types).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude Agent
Merge remote-tracking branch 'origin/dev' into feat/workflows-fixes
59340fa
@VasyaYovbak
Merge pull request #1 from mguttmann/feat/workflows-fixes
be44ff3
fix: real cancellation, crash recovery, resilience, budgets and test coverage for dynamic workflows
Claude Agent
Merge remote-tracking branch 'origin/dev' into feat/workflows-fixes
c393500
Claude Agent
Merge remote-tracking branch 'origin/dev' into feat/workflows-fixes
2f8f0f9
Claude Agent
feat(opencode): add static workflow meta reader (AST extraction, no m…
377dc75
…odule execution)

Add MetaReader.read(): extracts a workflow module's meta from its source text
via the TypeScript AST, without ever importing or executing the module. Supports
the same three shapes loadModule accepts at runtime (named `export const meta`,
default object literal `{ meta, run }`, and the `workflow({...})` plugin helper);
only literal values are understood.

Behavior change: workflow meta must be statically analyzable. A meta whose values
are dynamic (a call, identifier, member access such as process.env.X, ...) is
reported invalid with "workflow meta must be statically analyzable (literal
values only)" instead of being evaluated. The extracted object is validated by
the engine's existing Meta schema, so schema-invalid metas surface the same way.

Move `typescript` from devDependencies to dependencies: meta-reader is a runtime
src module that imports `typescript`.
Claude Agent
fix(opencode): workflow discovery no longer executes module code (sta…
653e612
…tic meta extraction)

Workflow.list()/discover() previously imported every discovered workflow module
via loadModule() (a dynamic import that runs each module's top-level code) just
to read its meta. list() runs on many ungated paths — system-prompt assembly on
every prompt turn, the workflow tool's read action, TUI /workflow autocomplete
(re-fetched while typing), and HTTP GET /workflow — so merely opening or typing
in a cloned workspace executed foreign code BEFORE any permission prompt.

list() now extracts meta statically through MetaReader (AST only, no import). A
real import() (loadModule) happens ONLY in start(), after the permission gate,
and still loads just the target module. A workflow whose meta is not statically
analyzable is reported as `valid: false` with the analyzability error text — no
throw, and it never blocks the rest of the list.

Tool start action: ctx.ask({ permission: "workflow" }) now runs BEFORE any
list/discovery, and the existence pre-check uses the now side-effect-free static
list. A denied permission therefore never imports the target module.

Behavior change: workflow meta must be statically analyzable; dynamic meta is
reported as invalid.
Claude Agent and others added 11 commits June 13, 2026 08:51
Claude Agent @claude
feat(opencode): make subagent tree limit configurable (nested-agents …
c156f3b
…Issue 2)

Promote the SUBAGENT_TREE_LIMIT=200 lifetime cap to a configurable
experimental key (experimental.subagent_tree_limit, PositiveInt). Add a
single-source-of-truth clamp helper treeLimit(cfg) in subagent-limits.ts,
exactly analogous to maxDepth(cfg): the __testHooks.treeLimit seam keeps
top precedence, then the config key (clamped to 1..HARD_MAX_TREE_LIMIT=10000,
truncated), else the 200 default. task.ts consumes the helper exclusively
instead of the bare constant/seam.

The in-memory per-process counter is unchanged (safety ceiling, no DB
priming). Clamp bounds: min 1 (at least one spawn must remain possible),
max 10000 (keeps the ceiling a sane order of magnitude, guards against
typos/overflow making it effectively unlimited).

Tests: config-parse round-trip + non-positive rejection; treeLimit clamp
(0/negative/too-large/undefined->default, NaN/Infinity->default, fractional
truncation, seam override). Docs updated in config.mdx and agents.mdx.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude Agent @claude
feat(opencode): per-task timeout for foreground subagents (nested-age…
c8101e7
…nts Issue 5)

Optional per-task timeout for foreground `task` spawns, set via the new
`timeout` tool-param (milliseconds, wins) or the `experimental.subagent_task_timeout`
config default. On expiry the subtree is aborted through the SAME cancel path as
an explicit cancel (ops.cancel seeds Session.descendants into
SessionRunState.cancel; background.cancel closes the job scope and awaits its
interrupt finalizers), so the release-race fix (5582da5) stays intact, no
orphan job survives, and the foreground parent surfaces a typed
SubagentTimeoutError in its transcript instead of hanging. Background tasks are
unaffected (decoupled, notified out-of-band). Without a timeout, behavior is
byte-identical to before.

The timeout arm only sleeps then fails: with raceFirst the loser is interrupted
the moment the winner settles, so failing first interrupts the wait arm before
background.cancel could flip the job to "cancelled" and let that branch win the
race (which would surface "Task cancelled" instead of the typed timeout); the
catchIf then runs the abort and re-fails.

Single-source clamp helper SubagentLimits.taskTimeout(cfg, override) and a typed
SubagentTimeoutError live in subagent-limits.ts alongside maxDepth/the existing
typed errors. Tests in test/session/nested-timeout.test.ts.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude Agent @claude
feat(session): add depth/rootID as additive wire fields (nested-agent…
f8ddc75
…s Issue 3)

Surface the session nesting level (depth) and tree root (rootID) as
convenience fields on the wire instead of forcing every client to walk
the parentID chain. Both are derived, never client-settable, and purely
additive — old clients that ignore them keep working.

Core/DB:
- Add `depth` (integer, default 1, not null) and `root_id` (text, nullable)
  columns plus a `session_root_idx` to the session table.
- New migration `20260613064154_session_depth_rootid` with a one-shot
  recursive-CTE backfill over the parent_id chains (root = depth 1,
  root_id = topmost ancestor; orphans treated as roots; legacy deep
  chains stamped, never truncated). Backfill UPDATE is idempotent.
- Map the fields through the projector, `SessionV1.SessionInfo` event
  payload, `SessionSchema.Info` and `info.fromRow`.

Server/wire:
- `createNext` stamps depth/rootID from the lineage walk it already does
  for the hard-cap check (root: depth 1, no rootID; child: parent chain
  length + 1, rootID = root.rootID ?? root.id). fromRow/toRow round-trip
  them and the Session.Info schema exposes them.
- `GET /session/:id/children?recursive=true` returns the whole descendant
  subtree (via Session.descendants); the default stays direct-children only.

SDK:
- Regenerated the v2 SDK (depth/rootID on Session, recursive query param).
- Patched the v1 (`src/gen`) SDK additively by hand (it is produced by a
  separate stainless pipeline not runnable in this worktree).

Tests:
- Migration backfill over a 3-level tree + orphan, with idempotency.
- createNext depth/rootID stamping (root, 3-level tree, orphaned parent).
- HTTP children recursive vs direct + depth/rootID on the wire.
- Updated existing wire-shape fixtures for the now-required depth field.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude Agent @claude
feat(opencode): fail-fast per-session subagent concurrency cap (neste…
40359d4
…d-agents Issue 1)

Phase-2 Issue 1: bound how many subagents a SINGLE session may have running
concurrently as its direct children. Implements design-final §10 variant (b)
(fail-fast breadth cap per session) — explicitly NOT a tree-wide semaphore over
foreground chains, which the design note proves deadlocks (two parallel L2
foreground parents each hold a permit and wait on an L3 child that can never get
one).

- subagent-limits.ts: SubagentConcurrencyError (TaggedErrorClass, mirrors
  SubagentTreeLimitError) + concurrencyError() with a model-directed message
  naming the limit; DEFAULT_SUBAGENT_CONCURRENCY = 8 (conservative; tree limit
  and depth limit stay the tree-wide ceilings); __testHooks.concurrency seam.
- task.ts: per-SPAWNER running counter (keyed by ctx.sessionID, independent of
  the tree-root tree cap). Synchronous fail-fast gate before sessions.create
  (coordinated with the existing tree-cap/budget gates, none weakened); slot
  reserved synchronously, released on create failure via the existing onExit and
  on child-run end via a one-shot Effect.ensuring — robust against success,
  error and abort, so the abort cascade never hangs on a permit and the counter
  never leaks. Resumes/extends reuse a still-running child and never re-reserve.
- test/session/nested-concurrency.test.ts: the deadlock counterexample (cap 2,
  two parallel L2 foreground tasks each with an L3 child → completes, no
  deadlock), fail-fast over-cap rejection, decrement-after-finish and
  decrement-on-abort (no leak), and per-spawner budget independence.
- subagent-limits.test.ts: pins the constant, the error text, and the seam.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude Agent
Merge branch 'feat/p2-depth-rootid-wire' into feat/workflows-fixes
5685c6e
Claude Agent
Merge branch 'feat/p2-tree-limit-config' into feat/workflows-fixes
e507aee
Claude Agent
Merge branch 'feat/p2-parallelism-cap' into feat/workflows-fixes
56e06a9
# Conflicts:
#	packages/opencode/src/session/subagent-limits.ts
#	packages/opencode/test/session/subagent-limits.test.ts
Claude Agent
Merge branch 'feat/p2-per-task-timeout' into feat/workflows-fixes
6426c04
# Conflicts:
#	packages/core/src/v1/config/config.ts
#	packages/opencode/src/session/subagent-limits.ts
Claude Agent
Merge branch 'feat/p2-cost-rollup' into feat/workflows-fixes
0fae2fd
# Conflicts:
#	packages/opencode/src/tool/task.ts
Claude Agent @claude
chore: drop internal phase-2 followups tracker from the public branch
4ab376d
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude Agent
Merge remote-tracking branch 'origin/dev' into feat/workflows-fixes
aa0cec9
# Conflicts:
#	packages/core/schema.json
#	packages/core/src/database/migration.gen.ts
#	packages/opencode/src/server/routes/instance/httpapi/server.ts
@mguttmann
mguttmann requested review from Brendonovich and Hona as code owners June 13, 2026 08:45
This was referenced Jun 13, 2026
Nested Subagent Fails Silently in 3-Layer Deep Chain (Works Fine in 2-Layer) #23091
Closed
Permission asks from nested subagent sessions silently hang #13715
Closed
Sub-agent nesting enabled #30899
Closed
[FEATURE]: Ephemeral Sub-Agent Teams (parallel multi-agent orchestration) #19999
Closed
[FEATURE]:Support for multi-agent orchestration in isolated workspaces #17994
Closed
[FEATURE]: Display subagent status in TUI prompt footer #23784
Closed
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found one PR that may be related to this work:

Potentially Related PR:

  • feat(opencode): add Dynamic workflows (new Claude Code feature) #29789: "feat(opencode): add Dynamic workflows (new Claude Code feature)"
    • This PR also addresses workflow functionality and may overlap with the workflow orchestration layer being added in PR feat: nested sub-agent spawning (up to 5 levels) + multi-agent workflow orchestration #32167.

However, PR #32167 is primarily focused on nested sub-agent spawning with workflow orchestration on top of it, which appears to be a distinct initiative from the dynamic workflows feature in #29789. They could be complementary or overlapping depending on their specific implementations.

The other PRs found (like background agents #15994, tool visibility #17089, and MCP search tool #12520) are related to agents and tools more generally but don't appear to directly duplicate the nested spawning + workflow orchestration work.

No direct duplicate PRs found for the specific nested sub-agent spawning feature with depth control and the new workflow layer being introduced in PR #32167.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mguttmann mguttmann mentioned this pull request Jun 13, 2026
feat(workflow): question/shell/nesting/isolation/events — full review-roadmap round VasyaYovbak/opencode#3
Closed
4 of 6 tasks
This was referenced Jun 14, 2026
[FEATURE]: Nested sub-agent spawning (up to 5 levels) + multi-agent workflow orchestration — reference implementation, requesting design review #32166
Closed
[FEATURE]: Add Dynamic workflows for repeatable multi-step automation (new Claude Code feature) #29059
Closed
[FEATURE]: Anything similar to Claude code dynamic workflows? #30308
Closed
@mguttmann mguttmann mentioned this pull request Jun 14, 2026
feat: nested sub-agent spawning (up to 5 levels) + fixes for #23091 / #13715 #32301
Closed
4 tasks done
@mguttmann

mguttmann commented Jun 14, 2026

Copy link
Copy Markdown
Author

Superseding this in favor of two focused PRs, per the review on #32166:

  • feat: nested sub-agent spawning (up to 5 levels) + fixes for #23091 / #13715 #32301 — nested sub-agent spawning only (no workflow code; fixes Nested Subagent Fails Silently in 3-Layer Deep Chain (Works Fine in 2-Layer) #23091 / Permission asks from nested subagent sessions silently hang #13715), the small reviewable piece.
  • feat(opencode): add Dynamic workflows (new Claude Code feature) #29789 (@VasyaYovbak) — the workflow/orchestration subsystem on its own line.

Closing this omnibus branch so review can happen on the split PRs instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mguttmann mguttmann closed this Jun 14, 2026
@VasyaYovbak VasyaYovbak mentioned this pull request Jun 14, 2026
feat(opencode): add Dynamic workflows (new Claude Code feature) #29789
Closed
4 of 6 tasks
thegalkin added a commit to thegalkin/opencode that referenced this pull request Jul 2, 2026
@thegalkin
feat(tui): show running subagent count in status bar
b498f6c
When a session has background subagents running, the TUI footer now
displays a count (e.g. '⏳ 2 subagents') so it's obvious the parent
session is waiting rather than idle or crashed.

- schema: add 'waiting' status variant with subagents count
- core/background-job: emit lifecycle events on start/settle/cancel
- opencode/session/run-state: track running count per parent and
  transition session status between idle/busy/waiting
- tui/footer: render '⏳ N subagent(s)' when status is waiting

Related upstream discussion: anomalyco#23784. Existing
proposal (anomalyco#32167) closed as too broad. This PR is a minimal,
focused slice of that work — schema-level waiting status + footer
indicator only.
thegalkin added a commit to thegalkin/opencode that referenced this pull request Jul 2, 2026
@thegalkin
feat(tui): subagent indicator via isolated sidecar (v2)
2d07e14
Reworks the v1 patch into an additive, dead-code-friendly sidecar:

Removes (reverts v1 modifications to existing files):
- packages/core/src/background-job.ts: drop the inline LifecycleEvent
  PubSub + subscribe() method. The sidecar now polls BackgroundJob.list()
  instead.
- packages/opencode/src/background/job.ts: drop the LifecycleEvent
  re-export and subscribe() wire-up.
- packages/opencode/src/session/run-state.ts: drop the subagentCounts
  map and the per-event fiber. SessionRunState is back to its upstream
  shape; it no longer drives SessionStatus directly.
- packages/schema/src/session-status-event.ts: drop the 'waiting'
  status variant. SessionStatus stays exactly as upstream defines it.

Adds (entirely new surface, easy to remove):
- packages/schema/src/local-subagent-indicator-event.ts: a new event
  type 'local.subagent.indicator' (note the 'local.' prefix) carrying
  { sessionID, info: { count } }. Independent of SessionStatus.
- packages/opencode/src/local/subagent-indicator.ts: a sidecar service
  gated by the new experimentalLocalSubagentIndicator flag (defaults
  off). When on, it polls BackgroundJob.list() every 1s, tracks
  per-parent running counts, and emits the local event. When off, the
  layer is a no-op.
- packages/opencode/src/effect/runtime-flags.ts: 1 new flag, following
  the existing enabledByExperimental('OPENCODE_EXPERIMENTAL_LOCAL_SUBAGENT_INDICATOR')
  convention so it can be toggled via the standard OPENCODE_EXPERIMENTAL
  umbrella or its own env var.
- packages/opencode/src/server/server.ts: 1 new Layer.provideMerge line
  to wire the sidecar into the server layer composition.
- packages/schema/src/event-manifest.ts: 1 new line in the inventory.
- packages/tui/src/context/sync.tsx: a new local_subagent_indicator
  field in the sync store and an event.on('local.subagent.indicator', ...)
  listener to populate it.
- packages/tui/src/routes/session/footer.tsx: a new <Show> block that
  renders '⏳ N subagent(s)' when count > 0.

Why this shape: if anomalyco/opencode (or any upstream) ever ships
their own subagent indicator — a 'waiting' SessionStatus variant, a
tree view, a different event — the local patch becomes inert without
conflict. The user just sets experimentalLocalSubagentIndicator: false
(or unsets OPENCODE_EXPERIMENTAL_LOCAL_SUBAGENT_INDICATOR) and our
sidecar stops; the TUI stops reading from local_subagent_indicator.
Nothing in upstream types or interfaces was touched, so a rebase
upstream is just `git rm packages/opencode/src/local packages/schema/src/local-subagent-indicator-event.ts`
plus reverting the 5 additive lines in event-manifest.ts,
runtime-flags.ts, server.ts, sync.tsx, footer.tsx.

Polling at 1s (instead of event subscription) is the cost of not
modifying BackgroundJob's interface. Acceptable for a footer counter.

Related upstream: anomalyco#23784 (existing feature request).
Anomalyco's PR anomalyco#32167 closed as too broad; this is a minimal slice
explicitly designed to be disposable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mguttmann @claude @VasyaYovbak
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.