Skip to content

[Bug] Agent tool-chain final text segments silently dropped — invisible to user and next-turn context #76477

@WhiteGiverMa

Description

@WhiteGiverMa

Summary

When an agent turn contains multiple tool calls (text → toolCall → toolResult → text → ...), the final text segment after the last tool result is silently dropped. It is neither rendered in WebChat nor injected into the next turn's context.

Impact

Workflow paralysis. The agent cannot see its own previous reply, so it repeats work or skips conclusions. User also cannot see the missing content. Multiple occurrences in one session rendered the workflow inoperable, forcing a version rollback.

Environment

  • Version: v2026.5.2 (8b2a6e5) — primary occurrence; also suspected on v2026.4.29
  • Node: v24.14.0
  • Host: WSL2 Linux 6.6.87, 15GB RAM
  • Gateway: ws://127.0.0.1:18789, bind=loopback
  • Client: Control UI WebChat (Chrome 147, Windows 11)

Symptoms

  1. Agent enters multi-step tool chain (text + toolCall → toolResult → text + toolCall → ...)
  2. After the last tool result, agent generates final analysis text
  3. This final text segment is silently dropped: not in UI, not in next-turn context
  4. Agent in next turn cannot see its own output — workflow breaks
  5. Also observed: WebSocket disconnect during tool chain causes session split (new session ID), and tool-chain continuation writes to the new session

Gateway Log Evidence

11:24:02 long-running session age=294s queued_behind_active_work
11:24:17 toolResult written to session JSONL  
11:24:31 long-running session age=322s queued_behind_active_work
11:24:54 webchat disconnected code=1001 → webchat reconnected
11:25:18 next user message (agent had not produced follow-up text)

Session JSONL Evidence

After the tool call and its result, the expected assistant follow-up message is absent:

{"type":"message","message":{"role":"assistant","content":[
  {"type":"thinking",...},
  {"type":"text","text":"initial analysis..."},
  {"type":"toolCall",...}
]}}
{"type":"message","message":{"role":"toolResult",...}}
// Expected: another assistant message with final text
// Actual: next entry is a user message — final text never written

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions