Skip to content

fix: harden worker prompt against context compression - #57

Open
jflowers wants to merge 2 commits into
unbound-force:mainfrom
jflowers:opsx/harden-worker-prompt
Open

fix: harden worker prompt against context compression#57
jflowers wants to merge 2 commits into
unbound-force:mainfrom
jflowers:opsx/harden-worker-prompt

Conversation

@jflowers

@jflowers jflowers commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Hardens worker.md agent 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:

  • Constraints co-located with their checklist steps using MUST/NEVER language
  • Reservation failure recovery path added (STOP + comms_send to coordinator)
  • Separate ## Constraints section eliminated
  • File reduced from 27 to 20 lines

How to Test

# Run the content-verification test
go test ./internal/agentkit/ -run TestWorkerPrompt_HardenedStructure -v

# Run the full suite
make check

Verify structurally:

  • worker.md has no ## Constraints heading
  • Step 3 (comms_reserve) includes "NEVER edit unreserved files" and reservation failure recovery
  • Steps 5 and 6 use "MUST" language for progress reporting and learning storage
  • File is 20 lines (under 35-line target from design decision D4)

How to Demo

cat internal/agentkit/content/agents/worker.md

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

File Change
internal/agentkit/content/agents/worker.md Hardened prompt: constraints inline, MUST/NEVER language, reservation failure recovery, Constraints section removed (27→20 lines)
internal/agentkit/agentkit_test.go New TestWorkerPrompt_HardenedStructure — structural verification test for the hardened prompt
openspec/changes/harden-worker-prompt/ OpenSpec change artifacts: proposal, design, delta spec, tasks

This PR was generated by /uf.finale (AI-assisted).

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)
@jflowers
jflowers requested a review from a team as a code owner August 2, 2026 19:44
@jflowers
jflowers requested a review from yvonnedevlinrh August 2, 2026 20:50
@jflowers jflowers self-assigned this Aug 2, 2026
@jflowers jflowers moved this to In Review 👀 in Unbound Force Planning Aug 2, 2026

@sonupreetam sonupreetam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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

Labels

None yet

Projects

Status: In Review 🏁

Development

Successfully merging this pull request may close these issues.

bug: worker.md reservation constraint and progress reporting lost under context compression

2 participants