Repository navigation
feat(ai-harness): the agent tree, with typed agent actions, limits and budgets that hold, run inheritance, shared state, durable groups, and harnessAgent as a child run - #1818
Conversation
…roup, with grouped options, for plugins and agent code
# Conflicts: # packages/ai-harness/src/agents.ts
…ents, tools, and commands, and agentRuns read from it
…rts, per-run usage, timeouts, attempts, and a budget code
… follow their parent, tool-mode children get ctx.harness and share the turn budget, and ctx.harness.state shares state by key
…yed children, and routed agents that take steers, late joins, and turn hooks
…tree, shared state, and routed agents
…g, for the parent's user and keys, with usage, budget, waits, and events in the parent run
… state, and a harnessAgent child run
|
| Name | Type |
|---|---|
| @tanstack/ai-harness | Minor |
| @tanstack/ai-acp | Patch |
| @tanstack/ai-code-mode | Patch |
| @tanstack/ai-harness-cli | Patch |
| @tanstack/ai-mcp | Patch |
| @tanstack/ai-sandbox | Patch |
| @tanstack/ai-skills | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit d75e0ce
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-harness
@tanstack/ai-harness-cli
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-e2b
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-reactor
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-blaxel
@tanstack/ai-sandbox-boxd
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-e2b
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-railway
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-typesafe
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
… slower CI coverage runs
Coverage✅ Coverage held across 30 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
Agents that code starts are now typed runs in one run tree in the log. Limits and budgets hold across the whole tree and across restarts, children follow their parent, and a group of agents can run with a concurrency limit and pick up its children after a crash.
harnessAgentruns another harness as a child run of the same session. This is PR 8 of the harness redesign stack for #1755. It targets #1817 (feat/harness-waits).🎯 Changes
ctx.harness.agents.start(worker, input, options?),run(worker, input, options?), andgroup({ concurrency?, onFailure?, key? }, (g) => [g.start(...)]). The input type comes from the worker's input schema, and the result type comes from its output.ctx.agentshas the same type.g.runandg.runSettledare gone: useg.start, andonFailure: 'collect'givesAgentSettledentries.key,limits: { timeoutMs, maxAttempts },budget: { maxTokens, maxCost },onModelError.RunNode(turn, agent, tool, command) lives in the log (harness.run.node).agentRuns()reads it instead of scanning every input (B4).maxDepthandmaxCallscount per tree.maxConcurrentcounts per session for top-level starts, and a start over the limit waits asqueued. The counts come from the log, so they survive a restart.runId, and a run keeps its usage sum. A run over its budget fails with codebudget. A timed-out run fails with codetimeout.ctx.harnessand share the turn's tree budget.ctx.harness.state({ key, initial })gives a{ get, update }handle. It is kept in the log, shared by key in one session, and copied by a fork.resume: true, children get keyed input ids, so a run that runs again after a crash binds its old children instead of starting new ones.beforeFinish, andonModelError, and each answer stays in the transcript.harnessAgentas a child run.<root>/agent/<run id>, in the root log.parentRunId.host.openrefuses a child thread id.Docs:
subagents.md(agents from code, groups, limits, budgets, the run tree, shared state, routed agents,harnessAgent),plugins.md,session-log.md,usage.md,shared-logs.md, and others. The changesets are edited in place.Decisions made while building:
resume: true. With keyed ids in every group, anonModelErrorretry would rebind the child that failed, so the retry could never succeed.maxConcurrentslot, the same as core does for children. A queued start does not survive a restart: the next host refuses it withexpired_on_restart.onModelErrorworks live only. A run that another host takes over logs one warning.harnessAgentchild's waits are live only. The root lists and routes them while the child session is open on this host. Another host andhost.observedo not see them.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Testing
Commands run:
test:typesofai,ai-harness,ai-mcp,ai-acp,ai-harness-cli,ai-code-mode,ai-skills, andai-sandbox. All pass.vitest relatedon every changedai-harnesssource file, with--maxWorkers=2: 127 files, 1,785 tests, all pass after merging the latest PR 7.test:oxlintofai-harness,pnpm test:docs,kiira checkon the changed pages, andoxfmt --checkon every changed file.Not run locally: knip, E2E (including the new
harness-agent-tree.spec.ts), and coverage. CI runs them.Manual test:
pnpm --dir packages/ai-harness exec vitest run tests/agent-group.test.ts tests/agent-limits.test.ts tests/harness-agent.test.ts.tests/agent-group.test.ts: a group stops with its host, and the run on the next host binds its old children.tests/agent-limits.test.ts: a run over its token budget fails with codebudget, and its parent sees the error.How this PR makes testing easy: the new test files pin each part:
run-tree,agent-limits,run-inheritance,shared-state,agent-group, andharness-agent.testing/e2e/tests/harness-agent-tree.spec.tscovers a group with a concurrency gate, a run budget, shared state, and aharnessAgentchild.Risk / rollback
High. This changes how agent runs start, count, inherit, and stop. Cancelling a turn now also cancels its background runs. The harness is not released yet, and all callers in this repo are moved. To undo, revert this PR.
Public API change
Before
After