Skip to content

fix: harden worker prompt against context compression - #57

Merged
jflowers merged 2 commits into
unbound-force:mainfrom
jflowers:opsx/harden-worker-prompt
Aug 10, 2026
Merged

fix: harden worker prompt against context compression#57
jflowers merged 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).

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

Comment thread internal/agentkit/agentkit_test.go Outdated
jflowers added a commit to jflowers/replicator that referenced this pull request Aug 7, 2026
Refactor TestWorkerPrompt_HardenedStructure to search within a window
of lines (current + next 3) for STOP and comms_send assertions instead
of requiring single-line co-location. This makes the test resilient to
sub-bullet reformatting of step 3 in worker.md.

Addresses review feedback from @sonupreetam on PR unbound-force#57.
@jflowers
jflowers requested a review from sonupreetam August 7, 2026 19:22
jflowers added a commit to jflowers/replicator that referenced this pull request Aug 10, 2026
Refactor TestWorkerPrompt_HardenedStructure to search within a window
of lines (current + next 3) for STOP and comms_send assertions instead
of requiring single-line co-location. This makes the test resilient to
sub-bullet reformatting of step 3 in worker.md.

Addresses review feedback from @sonupreetam on PR unbound-force#57.
@jflowers
jflowers force-pushed the opsx/harden-worker-prompt branch from 1e1d338 to 571c85f Compare August 10, 2026 16:40
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)
Refactor TestWorkerPrompt_HardenedStructure to search within a window
of lines (current + next 3) for STOP and comms_send assertions instead
of requiring single-line co-location. This makes the test resilient to
sub-bullet reformatting of step 3 in worker.md.

Addresses review feedback from @sonupreetam on PR unbound-force#57.
@jflowers
jflowers force-pushed the opsx/harden-worker-prompt branch from 571c85f to 2ff616e Compare August 10, 2026 16:50

@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 (6 Divisor agents)

Verdict: APPROVE (conditional on rebase)

Cleanest PR in the series. No blocking findings from any of the 6 Divisor agents. The windowed line search pattern (commit 571c85f) is a good solution for the brittleness concern from the prior review.

Mechanical blocker

  • Needs rebase onto main (PR #54 merged, test file has shifted)

Merge order recommendation

Merge 3rd (#54 already merged → #55#57#56#59). Rebase before merge.

@jflowers
jflowers removed the request for review from yvonnedevlinrh August 10, 2026 17:56
@jflowers
jflowers merged commit 49bc679 into unbound-force:main Aug 10, 2026
1 check passed
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

3 participants