Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-harness): first-party plugins in @tanstack/ai-harness/plugins: permissions, agent profiles, questions, todos, titles, and usage #1759

MergedAlemTuzlakmerged 13 commits intofeat/harness-core fromrefs/pull/1759/headmerged by AlemTuzlak View on GitHub

AlemTuzlakcommented

With this PR, a harness gets ready-made plugins from @tanstack/ai-harness/plugins. The main ones are permissions(), which asks before risky tool calls, and agents(), which gives the harness a plan and a build agent and your own agent profiles. The others are question(), todos(), title(), modelPicker(), projectInstructions(), fileCommands(), compact(), usage(), and boundToolOutput().

This PR targets the core harness PR #1755 (feat/harness-core), not main. It is split out of #1555. The goal, provider keys, and code mode PRs stack on this branch.

🎯 Changes

Source (packages/ai-harness):

  • src/first-party/*: the plugins above, plus glob.ts, workspace-hooks.ts, and the index.ts of the entry. Ported from #1555 without coding/, goal, and provider-keys.
  • ./plugins subpath export and a vite.config.ts entry. No new dependencies.
  • The package root exports PermissionRules, PermissionResources, PermissionDecisionCapability, and decidePermission (and their types) again. See the decision below.

Changes from #1555 (adapted to the core branch and to main):

  1. agents() docs and tests use one tool per subagent, named after the agent. main has no single subagent tool.
  2. A subagent run of agents() uses combineStrategies([maxIterations(50), untilFinishReason(['length'])]). On main, maxIterations(50) alone retries an answer cut at the output limit. Now the cut answer ends the run, the same as the harness default.
  3. projectInstructions() reads the git branch with execFile from node:child_process. #1555 used hostBackend from first-party/coding, which is not in this PR.
  4. usage() docs and JSDoc use your own price table. @tanstack/ai-models is not on main.
  5. A todo_write call with a bad status gets the plugin's own error. main does not check a plain JSON Schema input, so the #1555 TypeBox error text does not apply (session-plugins.test.ts).

Changes from the code review:

  1. A saved always rule is stored once, and deleteSavedPermission removes every copy.
  2. /compact with keepLast never keeps a tool result without the call before it.
  3. A question that the session rejects (it closed) refuses the call. A failed save of an always answer does not fail the call: the session keeps the answer in memory.
  4. The step-limit note goes into the system prompts once, also when a model call retries.
  5. tools: a, b in an agent Markdown file is a list. Outside plan mode, a deny says A permission rule denies this tool.. Saved rules are read only when the rules give ask. isYes is removed (no user in this PR; the coding tools PR adds it back if it needs it).

Changes from the second code review:

  1. /compact throws and keeps the conversation when the summary model returns empty text. Before, the history was replaced with an empty summary.
  2. The approval question says when it cut the call arguments: ... (131 more characters not shown). A risky part after character 300 is no longer hidden without a sign.
  3. In permission rules and agent tools patterns, **/ matches whole folders only. src/**/test.ts matches src/test.ts and src/a/test.ts, not src/mytest.ts. {a,b} now matches one of the parts, so *.{pem,key} works. permissions.md lists both.

Changes from the #1779 merge (feat/harness-core now takes one object):

  1. agents(), modelPicker(), and permissions() call ctx.session.setConfig({ key, value }).
  2. The tests call session.setConfig({ key, value }) and session.answer({ questionId, value }). Prompt results in the tests have media: [].
  3. The docs use the same object shapes.
  4. Merge conflicts: docs/config.json keeps both sides (new updatedAt from #1779 and the two new pages). session-plugins.test.ts keeps the #1779 imports and this branch's first-party imports.

Changes from the #1757 merge (feat/harness-core now has the HTTP transport, the typed client, and the view):

  1. package.json exports and the vite.config.ts entries keep ./client, ./view, and ./plugins.
  2. docs/config.json keeps all five new pages: permissions and agents from this PR, and auth, shared-threads, and custom-ui from #1757.
  3. The core branch now has session.onQuestion. The permissions page answers each question with it, with no CUSTOM event filter and no list of answered ids.

Decisions:

  • Permissions re-export. The core branch does not export anything from first-party/*. This PR adds the four portable permission names back to the root, as #1555 had them. They load no Node module, so an edge-safe plugin (code mode) can read the rules without the Node-only ./plugins entry. The edge-safety test now allows Node imports only in first-party/files.ts and first-party/bound-output.ts.
  • Tests that need other PRs are left out. The two workspaceTools cases of first-party.test.ts and the read_file case of instructions.test.ts go to the coding tools PR. The startLoopbackReceiver cases of discover-tools.test.ts go to the transport PR. expose-inputs.test.ts needs both this PR and the transport PR (applyInput, createHarnessHandler), so it lands with the later of the two. The URL question case of question.test.ts reads the snapshot instead of a session view.
  • Restored cases. The core branch removed the first-party cases from agent-middleware.test.ts and session-plugins.test.ts, and left out agents.test.ts and instructions.test.ts. This PR puts them back.
  • Plan mode and tools with no rule. The review found that a tool with no rule and no kind still runs in plan mode. That is the #1555 behavior, and the docs say so under Known limits. Not changed here.

Docs. New pages docs/harness/permissions.md ("Ask before risky tool calls") and docs/harness/agents.md ("Switch between agent profiles"). A usage() section in docs/harness/usage.md, and a link from docs/harness/plugins.md. docs/config.json has the new entries (addedAt 2026-10-13) and updatedAt 2026-10-14 for each changed page. The samples use only the core harness and this entry: no CLI, client, view, or coding tools. Readers: agent builders on @tanstack/ai-harness. Tone: plain second person, short sentences.

Changeset. @tanstack/ai-harness 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. After the #1757 merge, all of these passed:

  • nx run-many --targets=test:types,test:oxlint --projects=@tanstack/ai-harness.
  • vitest run in packages/ai-harness: 80 test files, 1134 tests (after the review fixes).
  • pnpm test:docs, and kiira check docs/harness (51 snippets).
  • tsc --noEmit in testing/e2e: no errors in the files of this PR.

Before the #1757 merge, these also passed: nx run-many --targets=test:types --projects='examples/**,testing/**' (27 projects), kiira check docs/harness, pnpm test:knip, and pnpm test:sherif.

Not run: the full pnpm test:pr and the E2E suite. CI runs them.

Manual test.

  1. Run pnpm --filter @tanstack/ai-e2e test:e2e --grep "harness first-party".
  2. The agents() case switches to a steps: 1 agent and checks that the last model call has tool_choice: 'none'.
  3. The permissions() case starts a subagent in plan mode and checks that its write_file call does not run.
  4. The projectInstructions() and title() cases check the environment block and the session title.

How this PR makes testing easy.

  • Unit tests in packages/ai-harness/tests/: permissions, agents, question, title-usage, bound-output, first-party, instructions, discover-tools, plus the restored cases in agent-middleware and session-plugins.
  • E2E: testing/e2e/tests/harness-first-party.spec.ts with the route api.harness-first-party.ts and the fixture fixtures/harness-first-party/basic.json.

Risk / rollback

Low. The plugins are a new opt-in subpath, and the root gets four new exports. Revert the PR to remove them.

Public API change

Before: no first-party plugins.

After

import { defineHarness } from '@tanstack/ai-harness'
import { agents, permissions } from '@tanstack/ai-harness/plugins'

defineHarness({
  name: 'acme/coder',
  adapter,
  plugins: () => [
    permissions({ root, rules: [{ tool: 'write_file', decision: 'ask', kind: 'edit' }] }),
    agents({ adapter: () => adapter }),
  ],
})

🤖 Generated with Claude Code

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

      🦋 Changeset detected

      Latest commit: 743367cb1f46d7b77dd2695aa5f3c2d01225fa84

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 4 packages
      NameType
      @tanstack/ai-harnessMinor
      @tanstack/ai-acpPatch
      @tanstack/ai-mcpPatch
      @tanstack/ai-skillsPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. 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: 253ca3ee-3ffd-488a-9787-226920f738b8

      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
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      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.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit f2f5e247315fc9c4f6563d63d46d20d331771a80

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded5m 15sView ↗
      nx run-many --targets=test:coverage --projects=...✅ Succeeded2sView ↗
      nx run-many --targets=build --exclude=examples/...✅ Succeeded43sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-15 11:33:40 UTC

    4. 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@1759

      @tanstack/ai-acp

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

      @tanstack/ai-angular

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

      @tanstack/ai-anthropic

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

      @tanstack/ai-bedrock

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

      @tanstack/ai-byteplus

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

      @tanstack/ai-claude-code

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

      @tanstack/ai-client

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

      @tanstack/ai-cloudflare

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

      @tanstack/ai-code-mode

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

      @tanstack/ai-code-mode-snippets

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

      @tanstack/ai-codex

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

      @tanstack/ai-cohere

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

      @tanstack/ai-compaction

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

      @tanstack/ai-devtools-core

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

      @tanstack/ai-durable-stream

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

      @tanstack/ai-elevenlabs

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

      @tanstack/ai-event-client

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

      @tanstack/ai-fal

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

      @tanstack/ai-gemini

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

      @tanstack/ai-grok

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

      @tanstack/ai-grok-build

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

      @tanstack/ai-groq

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

      @tanstack/ai-harness

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

      @tanstack/ai-isolate-cloudflare

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

      @tanstack/ai-isolate-daytona

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

      @tanstack/ai-isolate-e2b

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-e2b@1759

      @tanstack/ai-isolate-node

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

      @tanstack/ai-isolate-quickjs

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

      @tanstack/ai-isolate-quickjs-bun

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

      @tanstack/ai-llmgateway

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

      @tanstack/ai-lovable

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

      @tanstack/ai-mcp

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

      @tanstack/ai-memory

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

      @tanstack/ai-mistral

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

      @tanstack/ai-octane

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

      @tanstack/ai-ollama

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

      @tanstack/ai-ollaya

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollaya@1759

      @tanstack/ai-openai

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

      @tanstack/ai-opencode

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

      @tanstack/ai-openrouter

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

      @tanstack/ai-perplexity

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

      @tanstack/ai-persistence

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

      @tanstack/ai-preact

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

      @tanstack/ai-react

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

      @tanstack/ai-react-ui

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

      @tanstack/ai-reactor

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

      @tanstack/ai-remix

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

      @tanstack/ai-sandbox

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

      @tanstack/ai-sandbox-blaxel

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

      @tanstack/ai-sandbox-boxd

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

      @tanstack/ai-sandbox-cloudflare

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

      @tanstack/ai-sandbox-daytona

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

      @tanstack/ai-sandbox-docker

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

      @tanstack/ai-sandbox-e2b

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

      @tanstack/ai-sandbox-local-process

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

      @tanstack/ai-sandbox-railway

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

      @tanstack/ai-sandbox-sprites

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

      @tanstack/ai-sandbox-upstash-box

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

      @tanstack/ai-sandbox-vercel

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

      @tanstack/ai-skills

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

      @tanstack/ai-solid

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

      @tanstack/ai-solid-ui

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

      @tanstack/ai-svelte

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

      @tanstack/ai-typesafe

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

      @tanstack/ai-utils

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

      @tanstack/ai-vercel-gateway

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

      @tanstack/ai-vertex

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

      @tanstack/ai-vue

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

      @tanstack/ai-vue-ui

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

      @tanstack/ai-worldlabs

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

      @tanstack/openai-base

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

      @tanstack/preact-ai-devtools

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

      @tanstack/react-ai-devtools

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

      @tanstack/solid-ai-devtools

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

      @tanstack/svelte-ai-devtools

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

      commit: 743367c

    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      Coverage

      ✅ Coverage held across 21 compared package(s).

      Each package is measured twice in this job — on this PR and on its merge-base with main — and compared. A metric fails only when it is at or above 60% on the merge-base and under 60% on this PR. Other drops are listed but do not fail. Packages your PR doesn't affect are not measured and not listed.

      packagestatementsbranchesfunctionslines
      ai-acp82.32% (0.00)71.27% (0.00)77.08% (0.00)83.97% (0.00)ok
      ai-claude-code88.93% (0.00)76.88% (0.00)86.88% (0.00)90.40% (0.00)ok
      ai-codex94.55% (0.00)85.10% (0.00)89.28% (0.00)95.56% (0.00)ok
      ai-durable-stream86.70% (0.00)82.25% (0.00)92.30% (0.00)88.72% (0.00)ok
      ai-grok-build79.19% (0.00)63.56% (0.00)77.39% (0.00)81.02% (0.00)ok
      ai-harness92.88% (+0.39)87.42% (+0.19)93.21% (+0.79)94.45% (+0.39)ok
      ai-mcp96.71% (0.00)91.77% (0.00)96.86% (0.00)98.66% (0.00)ok
      ai-opencode68.77% (0.00)60.82% (0.00)64.04% (0.00)70.78% (0.00)ok
      ai-sandbox77.45% (0.00)82.80% (0.00)74.47% (0.00)77.97% (0.00)ok
      ai-sandbox-blaxel87.64% (0.00)77.18% (0.00)82.26% (0.00)89.71% (0.00)ok
      ai-sandbox-boxd95.86% (0.00)87.12% (0.00)95.31% (0.00)98.17% (0.00)ok
      ai-sandbox-cloudflare67.91% (0.00)57.47% (0.00)71.79% (0.00)69.62% (0.00)ok
      ai-sandbox-daytona82.70% (0.00)81.89% (0.00)67.14% (0.00)85.18% (0.00)ok
      ai-sandbox-docker80.15% (+0.44)71.49% (+0.15)77.38% (+1.00)82.13% (+0.48)ok
      ai-sandbox-e2b94.42% (0.00)88.97% (0.00)93.24% (0.00)98.63% (0.00)ok
      ai-sandbox-local-process68.00% (0.00)53.59% (0.00)75.86% (0.00)68.88% (0.00)ok
      ai-sandbox-railway94.75% (0.00)92.68% (0.00)90.90% (0.00)97.59% (0.00)ok
      ai-sandbox-sprites73.23% (0.00)59.70% (0.00)73.83% (0.00)76.17% (0.00)ok
      ai-sandbox-upstash-box94.82% (0.00)91.52% (0.00)91.04% (0.00)97.76% (0.00)ok
      ai-sandbox-vercel44.67% (0.00)38.18% (0.00)35.18% (0.00)45.76% (0.00)ok
      ai-skills83.39% (0.00)68.53% (0.00)87.36% (0.00)85.48% (0.00)ok
    6. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

    7. AlemTuzlak merged thisd326802

    8. AlemTuzlak closed this

Sign in to join this conversation.