Repository navigation
feat(ai-pi-stream): put TanStack useChat in front of a pi agent - #1911
tombeckenham wants to merge 1 commit into
Conversation
runPiAgent runs the pi agent loop for a useChat request and streams AG-UI events, with tool approvals and client tools. fromPiAgentEvents and toPiMessages cover a hand-run agentLoop(). Adds the /pi-agent e2e route and the guide and compatibility docs.
🦋 Changeset detectedLatest commit: 485b6bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Caution Review failedThe pull request is closed. Finishing Touches
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 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Closing: no one is asking for a pi bridge. The branch stays if that changes. |
Coverage✅ Coverage held across 75 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
Put TanStack AI
useChatin front of a pi agent. The new package@tanstack/ai-pi-streamhasrunPiAgent, which runs the pi agent loop for auseChatrequest and streams AG-UI events. pi tools inneedsApprovalpause for auseChatapproval, and the client tools ofuseChatrun in the browser.This PR replaces the useChat-to-pi half of #1894. The comparison of the two toolkits is in #1910.
🎯 Changes
@tanstack/ai-pi-stream:runPiAgent(params, { config, streamFn, tools, needsApproval, systemPrompts })serves a pi agent touseChat, with approvals, client tools and resume.fromPiAgentEventsandtoPiMessagescover a hand-runagentLoop().mainnow.@tanstack/aiand the other packages do not change.docs/migration/pi-agent-tanstack-client.md, the tabledocs/migration/pi-compatibility.md, and their nav entries (addedAt2026-10-26). The pi part of thetanstack-ai-migrationskill./pi-agentpage and API route intesting/e2e, andtests/pi-stream.spec.ts.@earendil-works/pi-aipulls in.tsconfig.docs.jsonresolve the pi packages for the doc samples.@tanstack/ai-pi-streamminor.✅ 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
@tanstack/ai-pi-stream:test:types,vitest run(17 passed),test:oxlint,buildandtest:build(publint). All pass.pnpm test:knip,pnpm test:sherifandpnpm test:docspass. sherif has one old warning aboutexamples/react.kiira checkon the two pages and the package README: 5 snippets pass.@tanstack/ai-e2e:test:typespasses.playwright test pi-stream.spec.ts: 14 passed.pnpm test:prand the full e2e suite. CI runs them.Manual test
pnpm build:all, thenpnpm --filter @tanstack/ai-e2e dev. No API keys are necessary./pi-agent. Click each scenario link. The page shows the expected result next to each link.Delete a.txt, then Approve. The pi tool runs and the reply continues. Do it again and click Deny. The model sees the denial.Locate me. The client tool runs in the browser, and pi continues from its result.?raw=links. Each one sends a request thatuseChatnever sends, and ends with aRUN_ERRORcode, not an HTTP 500.How this PR makes testing easy
packages/ai-pi-stream/tests/, with the faux pi model and no network.testing/e2e/tests/pi-stream.spec.tshas 14 tests, one for each scenario link on/pi-agent.Risk / rollback
Low. The PR adds a new package and changes no published package. Revert the PR to remove it.
Public API change
Before
// No way to serve a pi agent to TanStack useChat.After