Skip to content

refactor(gastown): replace gt_status with H1 header status in polecat and triage prompts#1419

Open
jrf0110 wants to merge 3 commits intomainfrom
convoy/parse-agent-status-from-h1-headers-repla/52d188d7/head
Open

refactor(gastown): replace gt_status with H1 header status in polecat and triage prompts#1419
jrf0110 wants to merge 3 commits intomainfrom
convoy/parse-agent-status-from-h1-headers-repla/52d188d7/head

Conversation

@jrf0110
Copy link
Contributor

@jrf0110 jrf0110 commented Mar 23, 2026

Summary

Removes all gt_status tool 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 removed gt_status tool.

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 — Removed gt_status from Available Tools list; rewrote Status Updates section to explain H1 header convention with examples.
  • cloudflare-gastown/src/prompts/triage-system.prompt.ts — Replaced gt_status guideline and tool listing with H1 header instructions.

Verification

Visual 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.

jrf0110 added 2 commits March 23, 2026 10:44
… 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)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 23, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
cloudflare-gastown/container/src/process-manager.ts 41 accumulatedPartText is only cleared on agent shutdown, so long-lived mayor sessions retain every completed text part in memory.

Fix these issues in Kilo Cloud

Other Observations (not in diff)

None.

Files Reviewed (5 files)
  • cloudflare-gastown/container/plugin/client.ts - 0 issues
  • cloudflare-gastown/container/plugin/tools.ts - 0 issues
  • cloudflare-gastown/container/src/process-manager.ts - 1 issue
  • cloudflare-gastown/src/prompts/polecat-system.prompt.ts - 0 issues
  • cloudflare-gastown/src/prompts/triage-system.prompt.ts - 0 issues

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>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant