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

MastraAgent never emits RUN_ERROR; a failed run has no terminal event

Aberta
#2,416 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
15.9k
Forks
1.4k
Merge médio
1d 17h
PRs com merge (30d)
163

Descrição

**Versions:** `@ag-ui/mastra@1.1.2` (also reproduces on 1.1.1), `@ag-ui/core` / `@ag-ui/client@0.0.58`, `@mastra/core@1.59.0`, Node 22.

## Expected

Per `concepts/events.mdx`:

> The `RunStarted` and either `RunFinished` or `RunError` events are mandatory, forming the boundaries of an agent run.

> Every run terminates with either `RunFinished` or `RunError`.

A Mastra `error` chunk should therefore surface as a terminal `RUN_ERROR` event on the stream.

## Actual

No `RUN_ERROR` is ever emitted. `handleChunk`'s `case "error"` builds an `Error` and calls `onError`, which is wired to `subscriber.error(...)` — the rxjs error channel, not `next()`. The string `RUN_ERROR` does not appear in any file of the published dist. The run ends with no terminal event of any kind.

## Repro

Drive a mock local agent:

```js
{
getMemory: async () => undefined,
listTools: async () => ({}),
stream: async () => ({ fullStream }),
}
```

whose `fullStream` yields:

```js
{ type: "start", payload: { messageId: "m1" } }
{ type: "text-delta", payload: { text: "partial" } }
{ type: "error", payload: { error: "provider exploded" } }
```

then:

```js
await agent.runAgent(input, {
onEvent: ({ event }) => seen.push(event.type),
onRunErrorEvent: () => { hookFired = true },
})
```

## Observed

```
events = [RUN_STARTED, TEXT_MESSAGE_START]
RUN_ERROR in stream = false
onRunErrorEvent fired = false
runAgent() rejected = true ("provider exploded")
```

## Impact

A client rendering from the event stream sees a run that simply stops — no error state, no terminal. `verifyEvents` cannot catch this: it rejects illegal events that are *sent*, and a stream that ends sends nothing to reject, so the violation is silent.

## Note

Judged at `runAgent()`, the documented primary API, not at the `run()` extension point.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.