ag-ui-protocol / ag-ui-protocol/ag-ui

Zod Validation error when streaming MCP tool calls from Langgraph Agent

Open
#994 2 comments 0 reactions 0 assignees View on GitHub
bug Integration
Dominant language
Python
Stars
15.9k
Forks
1.4k
Avg merge
1d 17h
Merged PRs (30d)
163

Description

Hi Team,

I'm getting these Zod Validation errors when streaming tool calls via the @ag-ui/client & @ag-ui/core npm packages.

This specifically happens when the Langgraph Agent is leveraging tools of an MCP Server,

Attaching my npm packages - I believe they're all the latest

```
"@ag-ui/client": "^0.0.43",
"@ag-ui/langgraph": "^0.0.22",
"@copilotkit/react-core": "^1.50.1",
"@copilotkit/react-ui": "^1.50.1",
"@copilotkit/runtime": "^1.50.1",
"@copilotkit/runtime-client-gql": "^1.50.1",
"@copilotkit/shared": "^1.50.1",
"@copilotkitnext/agent": "^0.0.33",
"@copilotkitnext/core": "^0.0.33",
"@copilotkitnext/react": "^0.0.33",
"@copilotkitnext/runtime": "^0.0.33",
```

And my error that I see in the NextJS Frontend

```
Console ZodError

[
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"toolCallId"
],
"message": "Required"
},
{
"code": "invalid_type",
"expected": "string",
"received": "undefined",
"path": [
"content"
],
"message": "Required"
}
]

Call Stack
26

Hide 26 ignore-listed frame(s)
get error
node_modules/@ag-ui/core/node_modules/zod/v3/types.js (39:1)
ZodDiscriminatedUnion.parse
node_modules/@ag-ui/core/node_modules/zod/v3/types.js (114:1)
Object.next
node_modules/@ag-ui/client/dist/index.mjs (6:1180)
ConsumerObserver.next
../src/internal/Subscriber.ts (161:25)
Subscriber._next
../src/internal/Subscriber.ts (119:22)
Subscriber.next
../src/internal/Subscriber.ts (75:12)
eval
../src/internal/Subject.ts (68:20)
errorContext
../src/internal/util/errorContext.ts (29:5)
Subject.next
../src/internal/Subject.ts (61:17)
t
node_modules/@ag-ui/client/dist/index.mjs (6:20)
Object.next
node_modules/@ag-ui/client/dist/index.mjs (4:9158)
ConsumerObserver.next
../src/internal/Subscriber.ts (161:25)
Subscriber._next
../src/internal/Subscriber.ts (119:22)
Subscriber.next
../src/internal/Subscriber.ts (75:12)
eval
../src/internal/Subject.ts (68:20)
errorContext
../src/internal/util/errorContext.ts (29:5)
Subject.next
../src/internal/Subject.ts (61:17)
ReplaySubject.next
../src/internal/ReplaySubject.ts (65:15)
Object.next
node_modules/@ag-ui/client/dist/index.mjs (6:969)
ConsumerObserver.next
../src/internal/Subscriber.ts (161:25)
Subscriber._next
../src/internal/Subscriber.ts (119:22)
Subscriber.next
../src/internal/Subscriber.ts (75:12)
eval
../src/internal/operators/switchMap.ts (115:42)
OperatorSubscriber._this._next
../src/internal/operators/OperatorSubscriber.ts (70:13)
Subscriber.next
../src/internal/Subscriber.ts (75:12)
eval
node_modules/@ag-ui/client/dist/index.mjs (4:8724)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.