fix: harden worker prompt against context compression - #57
Conversation
Restructure worker.md to make critical behavioral constraints compression-resistant by integrating them inline with checklist steps using MUST/NEVER language. Addresses unbound-force#49. - Integrate file reservation, progress reporting, and learning storage constraints directly into the checklist steps they govern - Add reservation failure recovery path (STOP + comms_send) - Remove separate Constraints section (compression-vulnerable) - Add TestWorkerPrompt_HardenedStructure content-verification test - Add OpenSpec change artifacts (proposal, design, specs, tasks) Assisted-by: claude-opus Generated with AI assistance (claude-opus)
sonupreetam
left a comment
There was a problem hiding this comment.
Review Council
Ran the review council (6 Divisor agents). Well-executed — the inline constraint approach is the right architectural choice and the test is thorough. One brittleness concern below.
Merge note: This PR inserts a test at line 152 of agentkit_test.go, same as #54 and #58. Suggest merging after #54, then rebasing.
|
|
||
| // Verify reservation failure recovery instruction is co-located | ||
| // with the comms_reserve step (STOP + comms_send on the same step). | ||
| if !strings.Contains(reserveStep, "comms_send") { |
There was a problem hiding this comment.
[MEDIUM] Single-line co-location assertion is brittle
This asserts that the line containing comms_reserve also contains comms_send. It works because step 3 is currently a single ~150-char line, but if someone reformats to use sub-bullets (like other PRs do), the test breaks even though the constraint is still co-located with the step.
Consider searching within a window of lines around comms_reserve rather than requiring everything on one line. For example, find the step and check the next 2-3 lines as well.
Summary
Hardens
worker.mdagent prompt against LLM context compression by restructuring critical behavioral constraints. Fixes #49.The worker's file reservation enforcement, progress reporting requirements, and learning storage constraints were in a separate "Constraints" section vulnerable to being summarized away by context compressors. This restructuring integrates each constraint inline with the checklist step it governs, making them atomic units that compressors must keep or drop together.
Key changes:
comms_sendto coordinator)## Constraintssection eliminatedHow to Test
Verify structurally:
worker.mdhas no## Constraintsheadingcomms_reserve) includes "NEVER edit unreserved files" and reservation failure recoveryHow to Demo
Compare the before (separate Constraints section with flat bullets) to the after (all constraints inline with numbered steps). Each step now reads as "do X — MUST/NEVER Y" rather than having the constraint in a disconnected section.
Key Files Changed
internal/agentkit/content/agents/worker.mdinternal/agentkit/agentkit_test.goTestWorkerPrompt_HardenedStructure— structural verification test for the hardened promptopenspec/changes/harden-worker-prompt/This PR was generated by /uf.finale (AI-assisted).