Skip to content

fix(agent): tolerate explicit null outputs in streamed conversation events - #572

Merged
hogan-yuan merged 1 commit into
mainfrom
fix/agent-workflow-outputs-null
Aug 14, 2026
Merged

fix(agent): tolerate explicit null outputs in streamed conversation events#572
hogan-yuan merged 1 commit into
mainfrom
fix/agent-workflow-outputs-null

Conversation

@hogan-yuan

Copy link
Copy Markdown
Member

Problem

A streamed AI Agent conversation aborts mid-run with:

invalid type: null, expected struct WorkflowOutputs

when the server sends an explicit "outputs": null on a workflow_finished event (observed on resumed/continued conversations).

Root cause: WorkflowFinishedPayload.outputs (and the sibling NodeToolUseFinishedPayload.outputs, SubagentFinishedPayload.outputs) were annotated #[serde(default)]. serde's default only fills a missing key — it does not accept an explicit null, so null fails to deserialize into the struct and the whole event stream errors out.

Fix

Deserialize these three fields through the existing serde_utils::null_as_default, mapping null to the type's Default. This mirrors how sibling null lists (e.g. Interrupt.questions / interactions) are already handled.

Added a unit test covering both "outputs": null and a missing outputs key.

…vents

`WorkflowFinishedPayload.outputs`, `NodeToolUseFinishedPayload.outputs`,
and `SubagentFinishedPayload.outputs` were `#[serde(default)]`, which only
applies to a missing key — not an explicit `null`. A `workflow_finished`
(or node/subagent finished) event carrying `"outputs": null`, which the
server can send on resumed/continued conversations, failed to deserialize
and aborted the whole event stream:

    invalid type: null, expected struct WorkflowOutputs

Deserialize these fields through `null_as_default` so `null` maps to the
type's default, matching how the sibling `null` lists are already handled.
@hogan-yuan
hogan-yuan merged commit 5e8c781 into main Aug 14, 2026
56 checks passed
@hogan-yuan
hogan-yuan deleted the fix/agent-workflow-outputs-null branch August 14, 2026 10:58
hogan-yuan added a commit that referenced this pull request Aug 14, 2026
…#573)

Follow-up to the `null` `outputs` fix (#572), same class of bug.

Several list-typed fields on the streamed AI Agent conversation event
payloads were `#[serde(default)]`, which only fills a **missing** key —
it does not accept an explicit `null`. An event carrying e.g.
`"tip_chips": null` failed to deserialize and aborted the whole event
stream:

```
invalid type: null, expected a sequence
```

Fixed by deserializing these through `serde_utils::null_as_default` so
`null` maps to an empty list:

- `tip_chips` — on the node / subagent / agent-tool `*_started` payloads
- `WorkflowFinishedPayload.process_data`
- `SubagentStartedPayload.tools`

Added a unit test covering `null` for each.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant