bobbai00 opened a new issue, #9482:
URL: https://github.com/apache/texera/issues/9482
### Task Summary
Today the agent service and the browser talk over a WebSocket protocol of
the service's own (`types/ws/client.ts` and `types/ws/server.ts`): a prompt and
a stop command one way, and snapshot, step, status and error events the other
way. Each step event carries the whole workflow before and after the step, and
the chat replaces the canvas with it (`agent-chat.component.ts:277`). The
frontend reads these events untyped, so every new kind of content is written
twice, once on each side.
AG-UI is an open, event-based protocol between an agent and the app a person
uses (MIT, `@ag-ui/core` 1.0.4). Agent frameworks such as Mastra, Google ADK,
AWS Strands and the Microsoft Agent Framework speak it, CopilotKit and
assistant-ui render it, and the Texera 2.0 prototype uses it for its chat. I
propose the agent service speaks AG-UI:
- Each prompt starts what AG-UI calls a run: `POST /api/agents/{id}/ag-ui`
with a `RunAgentInput` that carries the new message and, as `context`, what the
person is looking at (the workflow and the selected operator). The events come
back as server-sent events.
- Text streams as `TEXT_MESSAGE_START`, `TEXT_MESSAGE_CONTENT` and
`TEXT_MESSAGE_END`, a tool call as `TOOL_CALL_START`, `TOOL_CALL_ARGS`,
`TOOL_CALL_END` and `TOOL_CALL_RESULT`, each model call as `STEP_STARTED` and
`STEP_FINISHED`, and the turn ends with `RUN_FINISHED` or `RUN_ERROR`.
- Opening the chat gives `MESSAGES_SNAPSHOT`, built from the message list in
#9455. A turn keeps going when the browser leaves, as it does today, and a
browser that comes back during a turn gets the snapshot and then the rest of
the turn. Stopping stays its own request.
- Until #9464, the workflow after each step goes as a `STATE_SNAPSHOT`,
which the chat applies as it does today. #9464 removes it, since the agent's
edits then reach every canvas through the shared session.
- Both sides use the event types from `@ag-ui/core`. The service maps the AI
SDK's stream to them, and the 2.0 prototype's mapping (about 460 lines) can be
ported.
- Approvals, for review mode (#9075) and for an execution that would replace
another, can later use AG-UI's interrupt outcome on `RUN_FINISHED`.
This does not wait for the React frontend, because the protocol belongs to
the service. In the Angular app, `agent.service.ts` reads the events with
`@ag-ui/client` (MIT, built on RxJS like the app) and keeps today's chat. The
React chat later reads the same events, through the AG-UI support of
assistant-ui or CopilotKit (both MIT) or a small hook of its own, so it is
built once, against a protocol that is already settled. The trade-off is that
the React chat cannot use the AI SDK's `useChat`, which reads the AI SDK's own
stream format instead.
Done when the chat works over AG-UI as it does today, and the WebSocket
protocol and its types are deleted.
### Task Type
- [x] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [ ] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]