AG UI data model incompatibility issues #311
Send to my agentTanStack AI version#
0.5.0
Framework/Library version#
react
Describe the bug and the steps to reproduce it#
I'm having a rough time pointing my tanstack ai (generated using tanstack builder) to my ag-ui compatible backend. I think this stems from possible data model incompatibility issues between tanstack ai and ag-ui
As an example, tanstack ai sends:
{ "messages": [ { "id": "msg-1771876311632-1djsf", "role": "user", "parts": [ { "type": "text", "content": "test" } ], "createdAt": "2026-02-23T19:51:51.632Z" } ], "data": { "conversationId": "_R_la_" } }
However my ag-ui backend expects:
type RunAgentInput = { threadId: string runId: string parentRunId?: string state: any messages: Message[] tools: Tool[] context: Context[] forwardedProps: any }
And message is also inaccurate:
type UserMessage = { id: string role: "user" content: string | InputContent[] name?: string }
Missing fields in RunAgentInput: threadId, runId, state?, tools, context?, forwardedProps? (adding ? as they're marked as any in spec but not as optional like parentRunId is.) Missing/misnamed fields in UserMessage: "parts": this seems quite similar to "content" from spec "parts" in tanstack contains an array of an object with fields "type" and "content", in ag-ui this object maps to "TextInputContent" which has "type" and "text" fields "createdAt": this field does not exist in the specification, not sure if it'll matter to keep/remove it
Reproducing this:
- Create a new tanstack ai app
- Check out ag-ui server-starter and run it
- Point your tanstack ai hook to your ag-ui server (should be as easy as
connection: fetchServerSentEvents('http://localhost:8000/agentic_chat'), - Try sending messages using tanstack ai chat
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)#
dont have a codesandbox
Screenshots or Videos (Optional)#
No response
Do you intend to try to help solve this bug with your own PR?#
None
Terms & Code of Conduct#
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Also have the same issue, the sent SSE from the useChat hook does not match the expected AG-UI format at all.
Current request structure (from
useChat):{ "messages": [ { "id": "msg-1772462306227-0oxdf", "role": "user", "parts": [ { "type": "text", "content": "Hello, world!" } ], "createdAt": "2026-03-02T14:38:26.227Z" } ], "data": { "conversationId": "f0d4fdc7-d36d-427f-b69f-f9d7dd6da0a0" } }Expected request structure (from ag-ui dojo):
{ "threadId": "6bc46deb-7891-43e2-ae03-ba70b4044164", "runId": "240840f4-69e6-4909-8022-5e17a830a17d", "tools": [ {} ], "context": [ {} ], "forwardedProps": {}, "state": {}, "messages": [ { "id": "961ec277-1fd6-4700-945f-773658f894ec", "content": "Hello, world!", "role": "user" } ] }hey guys, at the time of implementation we were not aware that ag-ui had a 2 way communication spec and thought it only specificed the server >client sse stream and not the client > server one, i'll be updating our client side libraries to use the proper ag-ui standard soon!
The latest releases of tanstack ai are fully spec compliant in both directions!
AlemTuzlak closed this
Sign in to join this conversation.
Digging a bit around the code; I think this PR changed the behaviour ever so slightly: https://github.com/TanStack/ai/pull/258/changes#diff-6625e2e9e512b9eb1778d530cfcbc5fb35d07339d7c8b0158df5493384e02412