Skip to content

feat(ai-client): send AG-UI protocolVersion in the run request body - #1934

Open
kbuschgens wants to merge 2 commits into
TanStack:mainfrom
kbuschgens:feat/run-input-protocol-version
Open

kbuschgens wants to merge 2 commits into
TanStack:mainfrom
kbuschgens:feat/run-input-protocol-version

Conversation

@kbuschgens

@kbuschgens kbuschgens commented Oct 28, 2026 •

Copy link
Copy Markdown

The chat client now sends protocolVersion: "1.0" in every AG-UI RunAgentInput POST body. AG-UI 1.0 (@ag-ui/core 1.0.0) defines this optional field for the consumer's version. The spec says to send it in-band, so a recorded exchange describes itself. Before this PR, buildRunAgentInputBody did not set it.

🎯 Changes

  • buildRunAgentInputBody in @tanstack/ai-client sets protocolVersion: PROTOCOL_VERSION. All connection adapters use this function, so all of them send the field.
  • @tanstack/ai/client re-exports PROTOCOL_VERSION from @ag-ui/core, next to EventType. @tanstack/ai-client gets the value from there.
  • One unit test and one changeset (patch for @tanstack/ai and @tanstack/ai-client).
  • No docs change. The field is part of the wire format, and users do not set it.

✅ 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.

  • The test:pr target set (nx affected with sherif, knip, docs, kiira, oxlint, lib, types, test:build, build): all 441 targets passed across 110 projects. @tanstack/ai-react:test:lib timed out once under parallel load and passed on rerun; Nx marks it flaky, and it does not touch this change.
  • testing/e2e/tests/ag-ui-compliance.spec.ts fails without the fix (Received: undefined) and passes with it.
  • ag-ui-compliance, ag-ui-foreign-client, ag-ui-old-client-rejection, and chat E2E specs: 19 passed.
  • Full E2E matrix: not run locally.

Manual test.

  1. Run pnpm --filter @tanstack/ai-e2e test:e2e -- tests/ag-ui-compliance.spec.ts.
  2. In an example app, send a chat message and look at the POST body in the browser network tab. It contains "protocolVersion": "1.0".

How this PR makes testing easy. A unit test in packages/ai-client/tests/connection-adapters.test.ts and an E2E assertion in testing/e2e/tests/ag-ui-compliance.spec.ts both check the field in the request body.

Risk / rollback

Low risk. The field is optional in the AG-UI schema, so servers that follow the spec accept it. A server with a strict schema that rejects unknown keys can reject the request. To undo, revert this PR.

Public API change

Before

import { EventType } from '@tanstack/ai/client'

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
  * Connection requests now include AG-UI protocol version 1.0.
  * The client package now makes the protocol version constant available for use in integrations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

AG-UI 1.0 RunAgentInput has an optional protocolVersion field that the
consumer sends in-band. buildRunAgentInputBody now sets it to
PROTOCOL_VERSION ("1.0") for every connection adapter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01825k3Ap3Aa2ZVUkHA9d7iV
@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7f1830e

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

This PR includes changesets to release 3 packages
Name Type
@tanstack/ai Patch
@tanstack/ai-client Patch
ag-ui Patch

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

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: TanStack/ai
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 669fd31
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7fc99a0f-2ad7-4914-a7b3-3738a43ebcdc
Commits

Reviewing files that changed from the base of the PR and between 669fd31 and 7f1830e.

Files selected for processing: 5
  • .changeset/run-input-protocol-version.md
  • packages/ai-client/src/connection-adapters.ts
  • packages/ai-client/tests/connection-adapters.test.ts
  • packages/ai/src/client.ts
  • testing/e2e/tests/ag-ui-compliance.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The connection adapter now adds protocolVersion to generated RunAgentInput request bodies. The client entry point re-exports PROTOCOL_VERSION, and tests check the request field.

Changes: AG-UI protocol version

Layer / File(s) Summary
Add and verify protocol version in client requests
packages/ai-client/src/connection-adapters.ts, packages/ai-client/tests/connection-adapters.test.ts, testing/e2e/tests/ag-ui-compliance.spec.ts, packages/ai/src/client.ts, .changeset/run-input-protocol-version.md
The connection adapter adds protocolVersion: PROTOCOL_VERSION to generated request bodies. Adapter and compliance tests check for '1.0'. The client entry point re-exports PROTOCOL_VERSION, and the changeset declares patch releases for both packages.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Possibly related PRs

  • TanStack/ai#1894: Adds a pi bridge that parses TanStack AG-UI request bodies, which now include protocolVersion.
  • TanStack/ai#1893: Adds fromChatTransport, which uses the connection adapters that now include protocolVersion in request bodies.

Suggested reviewers: alemtuzlak

Merge Risk: Minimal · up to 7f183

No concrete merge-blocking defect is established by this change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the primary change: sending the AG-UI protocolVersion in the run request body.
Description check Passed The description covers the required Changes, Checklist, and Release Impact sections. It also documents implementation details, testing, risk, rollback, and the changeset. The unfinished Public API cha…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description covers the required Changes, Checklist, and Release Impact sections. It also documents implementation details, testing, risk, rollback, and the changeset. The unfinished Public API change example is non-critical.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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.

@kbuschgens
kbuschgens marked this pull request as ready for review October 29, 2026 08:22
@github-actions
github-actions Bot requested a review from jherr October 29, 2026 10:03
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR, @kbuschgens! 🙌 @jherr will take a look.

Automated pre-review checks

  • ✅ CI passing
  • ✅ No merge conflicts
  • ✅ Changeset present
  • ✅ E2E test changes included

Automated triage — a human review follows.

@github-actions github-actions Bot added the waiting-on: maintainer The ball is in the maintainers’ court label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on: maintainer The ball is in the maintainers’ court

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants