refactor(gastown): replace gt_status with H1 header status in polecat and triage prompts#1419
refactor(gastown): replace gt_status with H1 header status in polecat and triage prompts#1419
Conversation
… updates (#1374) * feat(gastown): parse H1 headers from agent output as automatic status 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 * fix(gastown): require trailing newline in H1 status regex to avoid partial matches The H1 regex was matching incomplete headings during streaming, causing dozens of /status writes per heading as each token delta produced a different partial match. Adding a trailing newline requirement ensures status is only posted once the heading line is fully streamed.
… and triage prompts Remove all gt_status tool references from polecat-system and triage-system prompts. Agents now derive dashboard status from H1 markdown headers in their output instead of calling a tool.
| // Require a trailing newline so we only match completed headings; without it, | ||
| // every streaming delta would match the partial heading being typed and spam | ||
| // the /status endpoint with incremental fragments. | ||
| const matches = [...part.text.matchAll(/(?:^|\n)# (.+)\n/g)]; |
There was a problem hiding this comment.
WARNING: Status parsing ignores streamed delta content
message.part.updated events can stream text through properties.delta while part.text remains empty; src/lib/cloud-agent-next/processor/event-processor.test.ts:348 exercises that path. In that case this regex never sees the H1 header, so dashboard status updates silently stop working for streamed responses. Parse accumulated text (or merge in delta) before scanning for headers.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)None. Files Reviewed (5 files)
Reviewed by gpt-5.4-20260305 · 659,121 tokens |
…t status updates Remove the gt_status tool and its prompt references. Agents now report status via markdown H1 headers (e.g. "# Installing dependencies") which are automatically parsed from streaming output in broadcastEvent(). Fix the H1 parser to accumulate streaming deltas — the SDK sends part.text as empty during streaming with content in the delta field. Add diagnostic logging for status POST results. Closes #1307
| // Accumulates streaming text deltas per "agentId:partId" key so we can scan for | ||
| // H1 headers. SDK events send part.text as empty during delta streaming; the | ||
| // actual content arrives incrementally in the `delta` field. | ||
| const accumulatedPartText = new Map<string, string>(); |
There was a problem hiding this comment.
WARNING: accumulatedPartText never gets pruned for long-lived agents
This cache is only cleared when an agent stops, but mayor sessions intentionally stay alive across many batches. Every completed text part stays retained for the life of the container, so a busy mayor will keep full streamed responses in memory and grow this map without bound. Please drop entries when a part/message finishes (for example via part.time.end, message.completed, or message.part.removed).
Summary
Removes all
gt_statustool references from the polecat and triage system prompts. Both prompts now instruct agents to use H1 markdown headers (e.g.# Installing dependencies) for dashboard status updates instead of calling the removedgt_statustool.This is the companion prompt change for #1374, which added server-side parsing of H1 headers from agent output as automatic status updates.
Files changed:
cloudflare-gastown/src/prompts/polecat-system.prompt.ts— Removedgt_statusfrom Available Tools list; rewrote Status Updates section to explain H1 header convention with examples.cloudflare-gastown/src/prompts/triage-system.prompt.ts— Replacedgt_statusguideline and tool listing with H1 header instructions.Verification
gt_statusreferences removed, no stale references remainVisual Changes
N/A
Reviewer Notes
Purely prompt-text changes — no runtime code is modified. The H1 header parsing logic was landed separately in #1374. This PR just updates the agent instructions to match the new mechanism.