Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-sandbox, ai-harness): delegate to Claude Code, Codex, and other coding agents from a harness #1538

ClosedAlemTuzlakwants to merge 3 commits intofeat/harness-p8-code-mode fromfeat/harness-p9-coding-agentsopened View on GitHub

AlemTuzlakcommented

Add codingAgents(...) to a harness, and the lead model can hand coding work to Claude Code, Codex, Grok Build, or any ACP agent. Each agent works in a sandbox, keeps its own session per thread (also after a restart), and its tool calls show up in the CLI, ACP editors, and the dashboard.

Stacked on #1524 (Phase 8) → #1523 → #1522 → #1521 → #1520 → #1519 → #1518 → #1515 → #1513 → #1509. Merge those first.

🎯 Changes

  • codingAgents({ sandbox, agents, workspace? }) at @tanstack/ai-sandbox/harness: one tool per agent. Each call runs ctx.chat with withSandbox, so nobody wires the sandbox by hand.
  • Sessions: the plugin saves the <adapter>.session-id event per thread and agent, and passes it back as modelOptions.sessionId. /fresh [agent] starts over.
  • Workspaces: 'shared' (default) is one sandbox per thread, one agent at a time. 'per-agent' gives each agent its own sandbox.
  • Plan mode: the harness plan mode starts Claude Code with permissionMode: 'plan' and Codex with sandboxMode: 'read-only'. Other agents use planModelOptions.
  • @tanstack/ai-harness: plugins can contribute subagents, agents the model can call as tools.
  • Child work is visible: the CLI shows child tool calls and a finish line, ACP gets child tool calls, and the dashboard shows a block per child.
  • examples/harness-cli: CODING_AGENTS=1 adds Claude Code and Codex in ./playground with the host claude login and codex login.
  • Docs: docs/harness/coding-agents.md (new), plus plugins.md and coding-agent.md. Changeset: ai-sandbox, ai-harness, ai-harness-cli, ai-acp, ai-dashboard (minor).

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Testing

Commands run (not the full pnpm test:pr, see below):

  • vitest run: ai-harness (156), ai-sandbox (985, 3 skipped), ai-harness-cli (20), ai-acp (68), ai-dashboard (4). All pass.
  • test:types for the same five packages and tsc --noEmit for examples/harness-cli.
  • publint --strict for @tanstack/ai-sandbox, kiira check for the three docs pages, oxfmt and oxlint on the changed files, test:sherif.
  • Skipped the full pnpm test:pr because it is slow on this machine. CI runs it. No new E2E test: the flow needs the real coding-agent CLIs, so the unit tests use a fake sandbox provider and stand-in agents, and the manual run below used the real CLIs.

Manual test (done on Windows with real logins)

  1. pnpm install && pnpm build:all, then sign in once: claude login and codex login.
  2. In examples/harness-cli, set OPENAI_API_KEY, CODING_AGENTS=1, and CODEX_MODEL to the model in ~/.codex/config.toml (a ChatGPT login does not accept gpt-5.3-codex).
  3. Ask: have claude_code create delegates.md with the line "Claude Code was here.", then have codex append "Codex was here."
  4. Result on my run: Claude Code wrote the first line. Codex resumed the same session on its second call and appended the second line. On Windows the Codex workspace-write sandbox denied the folder, so this step needed CODEX_SANDBOX_MODE=danger-full-access (the README says so).

How this PR makes testing easy

  • packages/ai-sandbox/tests/coding-agents.test.ts: sandbox per thread, session resume (also after a restart), /fresh, shared lock versus per-agent, plan mode.
  • packages/ai-harness/tests/plugin-subagents.test.ts, packages/ai-harness-cli/tests/child-view.test.ts, packages/ai-acp/tests/child-updates.test.ts, packages/ai-dashboard/tests/child-agents.test.ts.
  • examples/harness-cli with CODING_AGENTS=1.

Risk / rollback

Low. A new subpath and a new plugin contribution. The CLI line mode now prints only new entries (or growing assistant text), so a changed earlier entry does not print twice. Revert the PR to undo.

Public API change

Before

defineHarness({ name: 'acme/lead', adapter: openaiText('gpt-5.6') })

After

import { codingAgents } from '@tanstack/ai-sandbox/harness'

defineHarness({
  name: 'acme/lead',
  adapter: openaiText('gpt-5.6'),
  plugins: () => [
    codingAgents({
      sandbox: defineSandbox({ id: 'repo', provider: localProcessSandbox({ dir: repo }), workspace: defineWorkspace({ source: localSource(repo) }) }),
      agents: {
        claude_code: { adapter: claudeCodeText('claude-opus-4-8'), description: 'Larger changes' },
        codex: { adapter: codexText('gpt-5.3-codex'), description: 'Quick fixes' },
      },
    }),
  ],
})

🤖 Generated with Claude Code

https://claude.ai/code/session_01APYv1qshKyjPPpkFyRZhfZ

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on base/target branches other than the default branch.

      Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository: TanStack/ai/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 48d4c64d-9653-4fb3-8a8c-4a339225af94

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit c782dc2a99ef427c826cbf2b705d32a4198cb7f9

      CommandStatusDurationResult
      nx run-many --targets=build --exclude=examples/...✅ Succeeded50sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-09-28 14:56:43 UTC

    3. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented

      Open in StackBlitz

      @tanstack/ai

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@1538

      @tanstack/ai-acp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@1538

      @tanstack/ai-angular

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@1538

      @tanstack/ai-anthropic

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@1538

      @tanstack/ai-bedrock

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@1538

      @tanstack/ai-byteplus

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@1538

      @tanstack/ai-claude-code

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@1538

      @tanstack/ai-client

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@1538

      @tanstack/ai-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@1538

      @tanstack/ai-code-mode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@1538

      @tanstack/ai-code-mode-snippets

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@1538

      @tanstack/ai-codex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@1538

      @tanstack/ai-cohere

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@1538

      @tanstack/ai-compaction

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@1538

      @tanstack/ai-dashboard

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-dashboard@1538

      @tanstack/ai-devtools-core

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@1538

      @tanstack/ai-durable-stream

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@1538

      @tanstack/ai-elevenlabs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@1538

      @tanstack/ai-event-client

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@1538

      @tanstack/ai-fal

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@1538

      @tanstack/ai-gemini

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@1538

      @tanstack/ai-grok

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@1538

      @tanstack/ai-grok-build

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@1538

      @tanstack/ai-groq

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@1538

      @tanstack/ai-harness

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@1538

      @tanstack/ai-harness-cli

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness-cli@1538

      @tanstack/ai-isolate-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@1538

      @tanstack/ai-isolate-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@1538

      @tanstack/ai-isolate-node

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@1538

      @tanstack/ai-isolate-quickjs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@1538

      @tanstack/ai-isolate-quickjs-bun

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@1538

      @tanstack/ai-llmgateway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@1538

      @tanstack/ai-lovable

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@1538

      @tanstack/ai-mcp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@1538

      @tanstack/ai-memory

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@1538

      @tanstack/ai-mistral

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@1538

      @tanstack/ai-octane

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@1538

      @tanstack/ai-ollama

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@1538

      @tanstack/ai-openai

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@1538

      @tanstack/ai-opencode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@1538

      @tanstack/ai-openrouter

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@1538

      @tanstack/ai-perplexity

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@1538

      @tanstack/ai-persistence

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@1538

      @tanstack/ai-preact

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@1538

      @tanstack/ai-react

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@1538

      @tanstack/ai-react-ui

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@1538

      @tanstack/ai-reactor

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@1538

      @tanstack/ai-remix

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@1538

      @tanstack/ai-sandbox

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@1538

      @tanstack/ai-sandbox-blaxel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@1538

      @tanstack/ai-sandbox-boxd

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@1538

      @tanstack/ai-sandbox-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@1538

      @tanstack/ai-sandbox-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@1538

      @tanstack/ai-sandbox-docker

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@1538

      @tanstack/ai-sandbox-e2b

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@1538

      @tanstack/ai-sandbox-local-process

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@1538

      @tanstack/ai-sandbox-sprites

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@1538

      @tanstack/ai-sandbox-upstash-box

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@1538

      @tanstack/ai-sandbox-vercel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@1538

      @tanstack/ai-skills

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@1538

      @tanstack/ai-solid

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@1538

      @tanstack/ai-solid-ui

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@1538

      @tanstack/ai-svelte

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@1538

      @tanstack/ai-typesafe

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@1538

      @tanstack/ai-utils

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@1538

      @tanstack/ai-vercel-gateway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@1538

      @tanstack/ai-vertex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@1538

      @tanstack/ai-vue

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@1538

      @tanstack/ai-vue-ui

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@1538

      @tanstack/ai-worldlabs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@1538

      @tanstack/openai-base

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@1538

      @tanstack/preact-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@1538

      @tanstack/react-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@1538

      @tanstack/solid-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@1538

      @tanstack/svelte-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@1538

      commit: c782dc2

    4. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

    5. AlemTuzlakcommented

      Closed in favor of the combined PR #1555, which holds this phase and every other phase of the harness (P0 to P14) on one branch against main. All further fixes go there. This PR stays as the review record of P9.

    6. AlemTuzlak closed this

Sign in to join this conversation.