feat(gastown): parse H1 headers from agent output as automatic status updates#1374
Conversation
… updates Parse markdown H1 headers from message.part.updated events in broadcastEvent() and post them to the agent status API. This provides dashboard visibility into agent activity without requiring agents to call gt_status explicitly. - Uses last H1 match (most current) when multiple exist in one text part - Deduplicates via lastStatusForAgent Map to avoid redundant API calls - Truncates status to 120 characters - Cleans up lastStatusForAgent on agent exit/stop/failure/shutdown Refs: #1307
| typeof part.text === 'string' | ||
| ) { | ||
| // Use last H1 match — most current status when agent writes multiple headers | ||
| const matches = [...part.text.matchAll(/(?:^|\n)# (.+)/g)]; |
There was a problem hiding this comment.
WARNING: This will publish partial H1 fragments while the heading is still streaming
message.part.updated is emitted for each text delta, and part.text is the accumulated content so far. As soon as the model has produced something like # A, this regex starts matching, and lastStatusForAgent will not dedupe the follow-up # An, # Ana, etc. updates because each fragment is different. That can turn one heading into dozens of /status writes and bead events before the line is complete. Please wait until the H1 line is finished (for example, require a terminating newline or emit on a completion event) before posting the status.
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)None. Files Reviewed (1 files)
Reviewed by gpt-5.4-20260305 · 395,364 tokens |
Summary
Parse markdown H1 headers from
message.part.updated/message_part.updatedevents inbroadcastEvent()and post them to the agent status API. This provides dashboard visibility into what agents are doing without requiring explicitgt_statustool calls — agents just write naturally with H1 headers at phase transitions.Key implementation details:
lastStatusForAgentMap to avoid redundant API callslastStatusForAgententries at all agent exit paths:exitAgent(), stream error handler,stopAgent(), andstopAll()Refs: #1307
Verification
Visual Changes
N/A
Reviewer Notes
agents.get(agentId)call at line 173 (agentMeta) is redundant sinceagentwas already fetched at line 114 and is still in scope. Not a bug, but a minor inefficiency.(?:^|\n)# (.+)could theoretically match code comments (e.g., Python#) in code blocks, but false positives would just produce a slightly wrong status update — low severity and self-correcting.process-manager.tshas no existing test infrastructure to extend.