Skip to content

feat(ai-autopilot): add @gemstack/ai-autopilot — Supervisor orchestration#17

Merged
suleimansh merged 1 commit into
mainfrom
feat/ai-autopilot
Jun 25, 2026
Merged

feat(ai-autopilot): add @gemstack/ai-autopilot — Supervisor orchestration#17
suleimansh merged 1 commit into
mainfrom
feat/ai-autopilot

Conversation

@suleimansh

Copy link
Copy Markdown
Member

Implements #9 — the third (and most speculative) package of the GemStack AI family. The orchestration layer: runs many agent runs under a control policy, above ai-sdk's single-agent loop.

Per the issue, this ships the smallest useful first slice rather than a broad speculative API: the supervisor/worker topology.

Seed slice: Supervisor (plan → dispatch → synthesize)

  1. Plan — a planner decomposes the task into subtasks.
  2. Dispatch — each subtask runs on a worker agent, with bounded concurrency, an optional token budget, and per-subtask error isolation.
  3. Synthesize — a synthesizer combines the results into the final answer.
const supervisor = new Supervisor({
  plan: agentPlanner(plannerAgent),
  workers: { research: researchAgent, write: writerAgent },
  synthesize: agentSynthesizer(editorAgent),
  concurrency: 3,
  budget: { maxTotalTokens: 200_000 },
})
const { text, results, usage, stoppedEarly } = await supervisor.run('Draft a launch brief')

Surface

  • Supervisor — the orchestrator. Pluggable stages: plan (a Planner), workers (a single Agent / a Record<string, Agent> routed by subtask.worker / a WorkerRouter), synthesize (a Synthesizer).
  • agentPlanner(agent) — LLM decomposition via ai-sdk's Output.array (JSON subtasks).
  • agentSynthesizer(agent) / defaultSynthesize — LLM synthesis, or deterministic concatenation (no LLM call).
  • Guardrails: concurrency, maxSubtasks (trims + flags stoppedEarly), budget.maxTotalTokens (halts dispatch). Progress onEvent.

Answering the issue's open questions

  1. Smallest useful first slice? The Supervisor (plan → dispatch → synthesize) — exactly the candidate the issue named.
  2. What does it add over handoff/asTool? Those are primitives (transfer control / expose one agent as a tool). The Supervisor is a code-orchestrated topology over many runs: concurrency, budget, error isolation, result aggregation. The scope rule is enforced — if a feature just calls a primitive, it stays in ai-sdk.
  3. Durable execution? In-process first, no new peer dep. A worker that pauses (client-tool / approval) is reported as a failed subtask; durable pause/resume on ai-sdk's SubAgentRunStore + resume primitives is a deferred optional adapter, along with more topologies (pipelines, debate) and queue-backed runners.

Verification

  • pnpm build + pnpm typecheck — all packages ✓
  • 18 tests across pool (concurrency/short-circuit), supervisor (routing, error isolation, maxSubtasks trim, budget halt, paused-worker, events), planner + synthesizer (real ai-sdk prompt + Output parsing via AiFake).
  • One-directional confirmed: ai-sdk references ai-autopilot nowhere.

Changeset: @gemstack/ai-autopilot minor → 0.1.0. With this, the family's four packages (ai-sdk, ai-mcp, ai-skills, ai-autopilot) all exist.

…tion

Third package of the AI family (#9). The orchestration layer: runs many
agent runs under a control policy, above ai-sdk's single-agent loop.

Seed slice = the supervisor/worker topology (plan -> dispatch -> synthesize),
the smallest thing clearly more than the asTool/handoff primitives:

- Supervisor: planner decomposes a task into subtasks; dispatch runs each on a
  worker agent with bounded concurrency, an optional token budget, and
  per-subtask error isolation; synthesizer combines the results.
- agentPlanner(agent): LLM decomposition via ai-sdk Output.array.
- agentSynthesizer(agent) / defaultSynthesize: LLM or deterministic combine.
- Pluggable stages (plan/workers/synthesize), guardrails (concurrency,
  maxSubtasks, budget.maxTotalTokens), progress events.

Scope boundary kept sharp: if a feature just calls an ai-sdk primitive it stays
in ai-sdk; autopilot only owns topology/control/lifecycle. Autonomous workers
in v1; durable pause/resume + more topologies deferred behind optional seams.

One-directional (ai-autopilot -> ai-sdk). 18 tests across pool/supervisor/
planner/synthesizer.

Closes #9
@suleimansh suleimansh added enhancement New feature or request priority: low Nice to have / latent labels Jun 25, 2026
@suleimansh suleimansh self-assigned this Jun 25, 2026
@suleimansh suleimansh merged commit 8796ae4 into main Jun 25, 2026
1 check passed
@suleimansh suleimansh deleted the feat/ai-autopilot branch June 25, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: low Nice to have / latent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant