Skip to content

fix(runner): acp_get_session_status returns empty messages for all sessions #1484

@quay-devel

Description

@quay-devel

Summary

acp_get_session_status always returns recentMessages: [] and totalMessages: 0 for every session, despite the tool description promising "the most recent text messages from the conversation."

Root Cause

The message extraction code in backend_tools.py:404-414 expects a text field on TEXT_MESSAGE_CONTENT events, but AG-UI uses streaming deltas where:

  • The actual text field is delta (not text)
  • The role is on the TEXT_MESSAGE_START event (not on content events)
# Broken (line 408):
if event_type == "TEXT_MESSAGE_CONTENT" and event.get("text"):
#                                              ^^^^^ always None — field is "delta"

Additionally, completed/stopped sessions don't have streaming delta events at all — they use MESSAGES_SNAPSHOT events containing the full conversation array, which the code never checks.

Actual AG-UI Event Structure

// Active sessions use streaming deltas:
{"type": "TEXT_MESSAGE_START", "role": "assistant", "messageId": "msg-1"}
{"type": "TEXT_MESSAGE_CONTENT", "delta": "Hello, ", "messageId": "msg-1"}
{"type": "TEXT_MESSAGE_CONTENT", "delta": "world!", "messageId": "msg-1"}
{"type": "TEXT_MESSAGE_END", "messageId": "msg-1"}

// Completed sessions use snapshots:
{"type": "MESSAGES_SNAPSHOT", "messages": [{"role": "user", "content": "..."}, ...]}

Verification

Confirmed from a live session (2026-04-30):

  • Export endpoint returns 3,796 AG-UI events for an active session with 77 TEXT_MESSAGE_CONTENT events — all have delta, none have text
  • Stopped sessions have 0 TEXT_MESSAGE_CONTENT events but MESSAGES_SNAPSHOT events contain the full conversation (135 messages in one test case)
  • After applying the fix, active sessions correctly yield reassembled messages from streaming deltas, and stopped sessions correctly yield messages from the last snapshot

Impact

  • acp_get_session_status messages are completely broken for all sessions (active and completed)
  • Blocks cross-session introspection use cases (retrospectives, monitoring, debugging)
  • The max_messages parameter has never worked since launch

Affected File

components/runners/ambient-runner/ambient_runner/bridges/claude/backend_tools.py — lines 404-414

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions