Skip to content

Browser Agent: Emit SubagentProgress instead of raw strings for UI integration #21088

@gsquared94

Description

@gsquared94

Summary

BrowserAgentInvocation emits raw strings via updateOutput and only handles
THOUGHT_CHUNK events. It should emit structured SubagentProgress objects
(like LocalSubagentInvocation does) so the existing SubagentProgressDisplay
component renders browser agent activity with spinners, status icons, and
formatted tool args.

Problem

BrowserAgentInvocation.onActivity
(browserAgentInvocation.ts#L116-L126)
ignores 3 of 4 event types:

const onActivity = (activity: SubagentActivityEvent): void => {
  if (!updateOutput) return;
  if (
    activity.type === 'THOUGHT_CHUNK' &&
    typeof activity.data['text'] === 'string'
  ) {
    updateOutput(`🌐💭 ${activity.data['text']}`);
  }
};

LocalAgentExecutor already emits all 4 SubagentActivityEvent types
(TOOL_CALL_START, TOOL_CALL_END, THOUGHT_CHUNK, ERROR) during browser
agent runs — they're just silently dropped.

Meanwhile, LocalSubagentInvocation.execute.onActivity
(local-invocation.ts#L107-L221)
handles all 4 types, maintains a recentActivity array, tracks item status
(runningcompleted/error/cancelled), and emits SubagentProgress
objects that SubagentProgressDisplay renders correctly.

Result: Browser agent output appears as flat text
(🌐 Starting browser agent...) instead of the structured progress display
(spinners, ✓/✗ icons, tool names with args) that other subagents get.

Proposed Fix

In packages/core/src/agents/browser/browserAgentInvocation.ts:

  1. Replicate LocalSubagentInvocation's onActivity handler — maintain
    recentActivity: SubagentActivityItem[], handle all 4 event types, track
    status transitions
  2. Emit SubagentProgress objects via updateOutput instead of raw strings
  3. Send terminal state (completed/error/cancelled) on success and
    error paths

No changes needed to LocalAgentExecutor, SubagentProgressDisplay,
BrowserManager, or any other file — events are already emitted correctly
upstream and the UI component already renders SubagentProgress correctly.

Acceptance Criteria

  • BrowserAgentInvocation.onActivity handles TOOL_CALL_START,
    TOOL_CALL_END, THOUGHT_CHUNK, ERROR
  • updateOutput receives SubagentProgress objects, not raw strings
  • SubagentProgressDisplay renders browser agent activity with spinners,
    status icons, and formatted args
  • Initial (running) and terminal (completed/error/cancelled) states
    are emitted
  • Unit tests updated in browserAgentInvocation.test.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitystatus/need-triageIssues that need to be triaged by the triage automation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions