GH#14964: require model escalation before BLOCKED in worker policy#15190
GH#14964: require model escalation before BLOCKED in worker policy#15190marcusquinn merged 1 commit intomainfrom
Conversation
…964) - Add rule 6 to headless continuation contract: workers must attempt model escalation (sonnet → opus) before exiting BLOCKED - Update full-loop.md headless dispatch rules with escalation requirement - Add escalation decision matrix to worker-efficiency-protocol.md - Clarify worker BLOCKED policy in model-routing.md failure-based escalation - Add regression test suite (8 tests) verifying contract content and injection Review-policy metadata, nominal GitHub states, and lower-tier model limits are not valid blockers on their own. Genuine blockers require evidence that persists after escalation. Closes #14964
WalkthroughThis pull request enforces a mandatory worker policy requiring model escalation before marking tasks as Changes
Sequence DiagramsequenceDiagram
participant W as Worker (Tier 1)
participant M1 as Model: Sonnet
participant M2 as Model: Opus
participant GH as GitHub
W->>M1: Attempt task with tier-1 model
M1->>GH: Fetch PR/issue context
GH-->>M1: Context data
M1->>M1: Detect stall/unable to proceed
alt Escalation Path
M1-->>W: Signal escalation needed
W->>M2: Re-invoke with --model opus-4-6
M2->>GH: Fetch context (retained state)
GH-->>M2: Context data
M2->>M2: Attempt with higher capacity
M2-->>W: Success or genuine blocker evidence
else Genuine Blocker
M2-->>W: Evidence persists (failing checks,<br/>missing permissions, conflicts)
W->>W: Return BLOCKED (justified)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report SonarCloud: 0 bugs, 0 vulnerabilities, 1 code smells Wed Apr 1 17:18:32 UTC 2026: Code review monitoring started 📈 Current Quality Metrics
Generated on: Wed Apr 1 17:18:35 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request implements a mandatory model escalation policy (GH#14964) requiring workers to attempt higher-tier model execution (e.g., Sonnet to Opus) before exiting with a BLOCKED status. The changes update the worker efficiency protocol, full-loop command documentation, and the headless runtime helper script to enforce this behavior. Additionally, a new regression test suite, test-headless-contract-escalation.sh, has been introduced to verify that the escalation rules are correctly injected and maintained within the headless contract. I have no feedback to provide.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.agents/scripts/tests/test-headless-contract-escalation.sh (1)
75-114: Function extraction via Python subprocess is a pragmatic testing approach.Extracting and running
append_worker_headless_contractin isolation avoids sourcing the full script with itsmain()execution. The regex relies on the function ending with\n}at the outermost level, which works because the embedded heredoc ends withEOF, not a brace.One note: if the function structure ever changes to include nested
}at line start, the regex could truncate. Consider documenting this assumption or using a more robust AST-based extraction in the future if the function grows in complexity.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.agents/scripts/tests/test-headless-contract-escalation.sh around lines 75 - 114, The current extraction in _call_append_contract uses a regex in the Python snippet to grab append_worker_headless_contract from HEADLESS_HELPER which can fail if the function contains nested braces starting at line-begin; replace the fragile regex approach by implementing a balanced-brace extractor (e.g., locate the line that starts "append_worker_headless_contract()" then read lines while counting "{" and "}" until the count returns to zero) in the Python block, or at minimum add an inline comment documenting the assumption about no nested leading "}" and why the regex is acceptable; reference the symbols append_worker_headless_contract, _call_append_contract, and HEADLESS_HELPER when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.agents/scripts/tests/test-headless-contract-escalation.sh:
- Around line 75-114: The current extraction in _call_append_contract uses a
regex in the Python snippet to grab append_worker_headless_contract from
HEADLESS_HELPER which can fail if the function contains nested braces starting
at line-begin; replace the fragile regex approach by implementing a
balanced-brace extractor (e.g., locate the line that starts
"append_worker_headless_contract()" then read lines while counting "{" and "}"
until the count returns to zero) in the Python block, or at minimum add an
inline comment documenting the assumption about no nested leading "}" and why
the regex is acceptable; reference the symbols append_worker_headless_contract,
_call_append_contract, and HEADLESS_HELPER when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 079ffa2d-1dde-4749-879c-3eb4cbf4ab9a
📒 Files selected for processing (5)
.agents/prompts/worker-efficiency-protocol.md.agents/scripts/commands/full-loop.md.agents/scripts/headless-runtime-helper.sh.agents/scripts/tests/test-headless-contract-escalation.sh.agents/tools/context/model-routing.md
Up to standards ✅🟢 Issues
|
marcusquinn
left a comment
There was a problem hiding this comment.
Auto-approved by pulse — collaborator PR (author: @alex-solovyev). All pre-merge checks passed.
|
Completed via PR #15190, merged to main. Merged by deterministic merge pass (pulse-wrapper.sh). No worker summary was available — the worker either crashed before writing one or this PR predates the merge summary convention. |



Summary
Implements the worker escalation policy required by GH#14964: workers must attempt model escalation before exiting
BLOCKEDor handing off to a human.Changes
.agents/prompts/worker-efficiency-protocol.md— Added section 4 "Model escalation before BLOCKED" with decision matrix and escalation pattern.agents/scripts/commands/full-loop.md— Added rule 9 to headless dispatch rules: BLOCKED only valid after escalation attempt.agents/scripts/headless-runtime-helper.sh— Added rule 6 to the HEADLESS_CONTINUATION_CONTRACT_V1 injected into every worker prompt.agents/tools/context/model-routing.md— Extended "Failure-Based Escalation" section with BLOCKED policy reference.agents/scripts/tests/test-headless-contract-escalation.sh— 8 regression tests verifying contract content and injection behaviorAcceptance Criteria
Runtime Testing
Risk level: Low — documentation/prompt changes only, no runtime code paths changed. The test script validates contract content statically.
Test results:
Closes #14964
aidevops.sh v3.5.555 plugin for OpenCode v1.3.13 with claude-sonnet-4-6
Summary by CodeRabbit
Documentation
Tests
Note: This release contains internal infrastructure and documentation updates with no visible changes to end-user functionality.