-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Browser Agent: Emit SubagentProgress instead of raw strings for UI integration #21088
Description
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
(running → completed/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:
- Replicate
LocalSubagentInvocation'sonActivityhandler — maintain
recentActivity: SubagentActivityItem[], handle all 4 event types, track
status transitions - Emit
SubagentProgressobjects viaupdateOutputinstead of raw strings - 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.onActivityhandlesTOOL_CALL_START,
TOOL_CALL_END,THOUGHT_CHUNK,ERROR -
updateOutputreceivesSubagentProgressobjects, not raw strings -
SubagentProgressDisplayrenders 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