Repository navigation
feat(ai-harness): give routing.handoffTool the shared session state - #2253
Conversation
HandoffToolContext gets state, the same function as ctx.harness.state. A custom handoff tool can now read and update the work that agents keep in harness state, for example to put it in the handoff note.
🦋 Changeset detectedLatest commit: 0e8183a The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
|
View your CI Pipeline Execution ↗ for commit 0e8183a
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-cartesia
@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-computer-local
@tanstack/ai-computer-playwright
@tanstack/ai-computer-sandbox
@tanstack/ai-computer-use
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-effect
@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-meshy
@tanstack/ai-mistral
@tanstack/ai-muse
@tanstack/ai-neon
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-optimize
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@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-svelte
@tanstack/ai-tripo
@tanstack/ai-typesafe
@tanstack/ai-uthana
@tanstack/ai-utils
@tanstack/ai-vercel-compat
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
Coverage✅ Coverage held across 35 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
A custom
routing.handoffToolcan now read and updatectx.harness.state.HandoffToolContextgetsstate, the same function that agents use. A routed agent that keeps its work in harness state can put that work in the handoff note. It no longer has to copy it into aplacement: 'context'prompt, which sits before the history and re-caches the whole history on each change.🎯 Changes
HandoffToolContext.stateis typed asHarnessAgentContext['state'], so there is no new type.TurnHandoffsgets thestateoption from the turn (this.sharedState).tool()puts it on the context.get()reads the log when the tool runs, so the tool sees the latest value.docs/harness/handoffs.md).@tanstack/ai-harness.✅ 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
vitest run tests/handoff-tool.test.ts tests/handoff.test.ts --maxWorkers=2inpackages/ai-harness: 27 tests pass.tsc --noEmitinpackages/ai-harness: clean.testing/e2e: no errors in the two changed files.pnpm test:docsand oxfmt check: clean.pnpm test:pr, the full suites and the E2E suite. CI runs them.Manual test
packages/ai-harness/tests/handoff.test.tsand find "routing.handoffTool reads and updates the shared state".pnpm --dir packages/ai-harness exec vitest run tests/handoff.test.ts --maxWorkers=2.0, updates the count to1, and the handoff note ismain #1: order 42.How this PR makes testing easy
packages/ai-harness/tests/handoff.test.ts.custom-toolscenario ofharness-handoff.spec.tsnow expects the notefrom main #1: Refund for order 42., so the count comes from the shared state over the harness protocol.Risk / rollback
Low. The change adds one field to the context and changes no existing behavior. To undo, revert the PR.
Public API change
Before
After
Summary by CodeRabbit