Skip to content

[bug] RunSSEHandler writes errors as plain text instead of SSE JSON events #511

@innomon

Description

@innomon

Description

When an error occurs during SSE streaming in RunSSEHandler, it writes the error as plain text instead of a properly formatted SSE event with JSON payload.

Current behavior (runtime.go lines 109-115):

if err != nil {
    _, err := fmt.Fprintf(rw, "Error while running agent: %v\n", err)  // Plain text!
    // ...
}

This makes it difficult for the web UI to parse and display errors properly.

Related Issue

google/adk-python#4244 (same issue in Python SDK)

Expected Behavior

Errors should be sent as proper SSE events with JSON payload:

data: {"id":"...","errorCode":"EXECUTION_ERROR","errorMessage":"actual error message","author":"system"}

Suggested Fix

Create an error event and send it using flashEvent():

if err != nil {
    errorEvent := models.Event{
        ID:           uuid.NewString(),
        Time:         time.Now().Unix(),
        Author:       "system",
        ErrorCode:    "EXECUTION_ERROR",
        ErrorMessage: err.Error(),
    }
    flashEvent(flusher, rw, errorEvent)
    continue
}

Environment

  • ADK version: v0.2.0
  • Go version: 1.24

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions