Problem
When chatting with Archon in the main chat view (not invoking a workflow), tool calls always appear at the bottom of the message, below all text output. They are not interleaved with the text as the agent produces them.
Current Behavior
During streaming, the tool call cards stack at the bottom of the conversation instead of being rendered inline between the text segments that precede and follow them. The correct interleaving only appears after navigating away and returning to the conversation (i.e., when messages are loaded from the database rather than streamed via SSE).
Expected Behavior
Tool calls should be interleaved with text output in real-time during streaming, matching the order the agent produces them — just as they appear when the conversation is loaded from history.
Reproduction Steps
- Open the Archon web UI
- Select a project
- Send a message that triggers tool use (e.g., "What files are in the .archon directory?")
- Observe that during streaming, all tool call cards appear at the bottom
- Navigate away from the conversation and return — tool calls now appear interleaved correctly
Technical Context
- The SSE stream emits
text, tool_call, and tool_result events in the correct order
- The issue is likely in how
ChatInterface.tsx or useSSE.ts accumulates and batches these events during streaming
useSSE.ts batches text events on a 50ms flush timer and flushes before tool_call events, but the message model may not support mid-message interleaving during streaming
- When loaded from DB via the messages API, the interleaving is correct because each message has its
toolCalls array properly associated
Affected Components
packages/web/src/hooks/useSSE.ts — SSE event handling and batching
packages/web/src/components/chat/ChatInterface.tsx — message state management during streaming
packages/web/src/components/chat/MessageList.tsx — message rendering
Problem
When chatting with Archon in the main chat view (not invoking a workflow), tool calls always appear at the bottom of the message, below all text output. They are not interleaved with the text as the agent produces them.
Current Behavior
During streaming, the tool call cards stack at the bottom of the conversation instead of being rendered inline between the text segments that precede and follow them. The correct interleaving only appears after navigating away and returning to the conversation (i.e., when messages are loaded from the database rather than streamed via SSE).
Expected Behavior
Tool calls should be interleaved with text output in real-time during streaming, matching the order the agent produces them — just as they appear when the conversation is loaded from history.
Reproduction Steps
Technical Context
text,tool_call, andtool_resultevents in the correct orderChatInterface.tsxoruseSSE.tsaccumulates and batches these events during streaminguseSSE.tsbatches text events on a 50ms flush timer and flushes beforetool_callevents, but the message model may not support mid-message interleaving during streamingtoolCallsarray properly associatedAffected Components
packages/web/src/hooks/useSSE.ts— SSE event handling and batchingpackages/web/src/components/chat/ChatInterface.tsx— message state management during streamingpackages/web/src/components/chat/MessageList.tsx— message rendering