Skip to content

feat: add agent source tracking to messages for multi-agent support #601

Description

@avoidwork

Summary

Add agent source tracking to messages — tag each message with its originating agent (orchestrator, subagent, etc.) to enable multi-agent context support in the TUI.

Motivation

The TUI currently has no concept of agent source. All messages flow through a single linear chat with no distinction between orchestrator output and subagent output. As the system evolves to support multi-agent orchestration (DeepAgents), users need to see which agent produced which response. This enables:

  • Context switching (tabs or panels) per agent
  • Visual distinction of agent source in the chat
  • Debugging multi-agent workflows

Proposed Solution

  1. Add agentName field to the Message model (messages.js typedef)
  2. Update addMessage, updateMessage, and setMessages in messageList.js to accept/pass agentName
  3. Update MessageBubble to display agent name in the role label (or as a separate badge)
  4. Update app.js streaming handlers to pass agent name from graph events
  5. Add config for default agent display name (e.g., tui.defaultAgentName)

Alternatives Considered

  • Using the existing role field — too coarse (user/assistant/system), no subagent distinction
  • Tool call display for agent attribution — already used for tool results, not suitable
  • Separate message types per agent — over-engineered, agentName on existing model is simpler

OpenSpec Note

This project uses OpenSpec for feature development. If this request is approved, I will:

  1. Run /opsx:propose to generate a full proposal with specs and tasks
  2. Iterate on the design before any code is written
  3. Follow the task-driven implementation workflow

Additional Context

  • Message model has role/content/reasoningContent/activeToolCall/toolCallDisplay/time/streaming — agentName is a natural addition
  • No agent tracking exists at any layer currently — this is a new capability
  • The graph/streaming layer needs to be updated to pass agent names from events

Audit Findings (for Issue #601)

  • src/tui/messages.js:2-10 — Message typedef, needs agentName property
  • src/tui/messageList.js:117-135addMessage accepts options, needs agentName handling
  • src/tui/messageList.js:143-161updateMessage merges updates, agentName would flow through
  • src/tui/messageList.js:187-211setMessages loads from array, needs agentName passthrough
  • src/tui/messageList.js:354-369 — MessageBubble creation, needs agentName prop
  • src/tui/messageBubble.js:119-128 — Props destructuring, needs agentName
  • src/tui/messageBubble.js:224-229 — Role label rendering, agent name could be displayed here or as a badge
  • src/tui/app.js:684-700createStreamingHandler needs to capture agent name from events
  • src/tui/app.js:709-735finalizeStreaming needs to pass agent name to message update

Implementation scope: 4 files touched (messages.js, messageList.js, messageBubble.js, app.js). Requires graph/streaming changes to supply agent names. Medium complexity, foundational for multi-agent support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedAn identifier for Madz to take action.feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions