Repository navigation
Implement delegated execution with worker sessions and fleet UI - #6
Merged
Merged
Conversation
…subagent list Reviewers, reference analysts and the execution reviewer used to be separate pi processes whose output was a one-shot stream, rendered as up to three stacked panes in one overlay. They now run as in-process agent sessions that stay addressable (steer, re-prompt, abort) and report into a shared fleet. - add src/agent-session.ts: session engine with a per-run abort/timeout, usage metering, errored-final-turn detection and a test seam - add src/agent-fleet.ts and src/fleet-run.ts: registry of live agents with a concurrency helper, so long reference lists queue instead of batching - add src/fleet-ui.ts: bulleted list above the editor (Down focuses it with an empty editor, Up/Down select, Enter opens one agent's overlay, Esc backs out) plus a single-agent detail overlay with scroll, follow and stop - hand reviewers a read-only code_graph tool (buildCodeGraphTool) since in-process sessions load no extensions - remove the process spawner and the three-pane overlay; port their tests
At the execution handoff the user now picks where the plan runs: the current session (same model), one delegated subagent, or several. For delegated runs the model and effort come from the same picker the reviewer uses, which is extracted into pickModelAndEffort without persistence. The last choice is offered first and stored per run in the checkpoint. Workers are in-process sessions that receive their own plans_update_task tool closed over the live execution state, so a finished task repaints the dashboard immediately while the worker's loop keeps going; completion is never inferred from a session ending. - add src/exec-delegate.ts: per-wave scheduling (tasks sharing a file go to one worker, a wave starts only after the previous one is terminal), session reuse across waves and repair rounds, stall and failure ladders, restore from the checkpoint or session snapshot - add src/exec-mode-picker.ts, src/executor-config.ts and agents/executor.md - store an executor block in the execution checkpoint and an executor_last default in the global config; the legacy v0.6.0 delegate marker stays refused - route review repair briefs to the owning worker instead of waking the main model, and block edit/write in the supervising session while delegated
…sessions Rewrite the README overlay section as "Delegated subagents", document the execution-placement question, the executor checkpoint block and the executor_last default, and replace the stale child-process wording (including the default-level row, which now says "no explicit level"). - validate: require the new modules and a write-enabled agents/executor.md that declares plans_update_task - readme-check: count defineTool literals and mandate the renamed heading - agent sessions: allowlist custom tool names, because the SDK enables only named tools; add an integration test against the real SDK that runs a custom tool mid-run and re-prompts the same session - fleet: drop finished agents from the list after ten minutes
pi-tui's Editor class can be a second module copy inside the host, which defeats instanceof and would leave the subagent list unreachable. Fall back to the editor's getText() API while still ignoring select dialogs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR implements delegated execution mode for pi-plans, allowing plan implementation to run on worker sessions while the main session supervises. Key changes:
New execution mode:
executor-config.tsto define execution choices (current-session vs. delegated workers)exec-mode-picker.tsfor the handoff UI to select execution mode and worker model/effortexec.tsto support delegated execution via a pluggableDelegateDriverinterfaceIn-process agent sessions:
agent-session.tsprovidingstartAgentSession()andrunAgentSession()for long-lived SDK sessions that can be re-prompted and steeredsubagent.tsto hold only shared types and event normalization (moved subprocess spawning to agent-session)Delegated worker orchestration:
exec-delegate.tsimplementing wave-based scheduling: groups tasks by shared files, balances across workers, reuses sessions across wavesplans_update_tasktool; completion is never inferred from session endUnified agent fleet UI:
fleet-ui.tsshowing all delegated agents (reviewers, ref analysts, execution reviewer, workers)agent-fleet.tsregistry tracking live agents across spawn sitesfleet-run.tsglue connecting spawn sites to the fleet and TUIrefine-ui.tstofleet-ui.ts; kept state management inrefine-ui-state.tsSupporting changes:
ui-language.tsto providefleetChrome(renamed fromrefineChrome)agents/executor.mddefining the execution worker agentglobal-state.tsto remember last executor choicetools/refine.tsandtools/analyze-refs.tsto use the new fleet registrationThe implementation maintains backward compatibility: current-session execution (the default) works unchanged; delegated mode is opt-in at the handoff.
Test Plan
tests/exec-delegate.test.ts(wave scheduling, worker assignment),tests/agent-session.test.ts(session lifecycle and re-prompting),tests/fleet-ui.test.ts(list rendering and overlay),tests/exec-mode-picker.test.ts(mode selection UI),tests/agent-session-sdk.test.ts(real SDK integration)tests/fleet-ui.test.tsandtests/refine-ui-state.test.tsDocs
references/state-and-config.mdto document executor choice storagereferences/pi-planning-workflow.mdto reflect new execution modestools/refine.tsandtools/analyze-refs.tsto reference the shared fleet UIhttps://claude.ai/code/session_01DLopn2G79H3ffu1ZdjGVz6