Skip to content

ag-ui protocol error - payload is not compliant with RunAgentInputSchema #613

@ksachdeva

Description

@ksachdeva

I came across your work today and it does make sense to me to avoid using json and having a custom DSL is the right approach. Thanks for this great effort!

Bug - A server using ag-ui protocol rejects the message sent by openui

My setup:

  • A FastAPI backend that has an endpoint that uses RunAgentInput type for the input_data
  • An openui based application that uses apiUrl and not custom adapters/messageformats etc

Below is the zod definition from https://github.com/ag-ui-protocol/ag-ui/blob/88ce4bca9f6fec6d778367fc7c197c262ffbcf61/sdks/typescript/packages/core/src/types.ts#L209-L219

export const RunAgentInputSchema = z.object({
  threadId: z.string(),
  runId: z.string(),
  parentRunId: z.string().optional(),
  state: z.any(),
  messages: z.array(MessageSchema),
  tools: z.array(ToolSchema),
  context: z.array(ContextSchema),
  forwardedProps: z.any(),
  resume: z.array(ResumeEntrySchema).optional(),
});

Here is a sample payload received by my FastAPI server from OpenUI client

{'threadId': 'ephemeral', 'messages': [{'role': 'user', 'content': 'Hi', 'id': '5ac6b8f0-a17d-4208-a30b-65f8b2637086'}]}

As you can see the payload is missing many required fields (e.g. state, tools, context, forwardedProps)


All the samples in the repo, have following use case

<FullScreen
        processMessage={async ({ messages, abortController }) => {
          return fetch("/api/chat", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
              messages: openAIMessageFormat.toApi(messages),
            }),
            signal: abortController.signal,
          });
        }}

The documentation says you can use either apiUrl or processMessage

Use apiUrl when your server is compliant with ag-ui

Mine is

<FullScreen
        apiUrl="/simple_agent"
      />

I believe processMessage in createChatStore here

processMessage: async (message) => {

is not respecting the ag-ui protocol and hence the issue


I am just few hours old with your framework (and even with ag-ui as such) so chances of misunderstanding are there.

Thanks again!

Regards
Kapil

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions