Skip to content

feat: strengthen delegation enforcement via three-layer reinforcement#49

Open
barkain wants to merge 3 commits into
mainfrom
strengthen-delegation-enforcement
Open

feat: strengthen delegation enforcement via three-layer reinforcement#49
barkain wants to merge 3 commits into
mainfrom
strengthen-delegation-enforcement

Conversation

@barkain

@barkain barkain commented May 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Stub rewrite: Opens with BLOCKING REQUIREMENT (proven constraint pattern from Claude Code's own system prompt). Cut from ~450 words to ~167 words — shorter but stronger.
  • Per-turn reminder: UserPromptSubmit hook now emits a one-line delegation reminder to stderr, which Claude Code wraps as <user-prompt-submit-hook> and treats as user speech. ~14 tokens/turn, subagent-safe.
  • Structured output: PreToolUse violations now emit additionalContext via stdout JSON in addition to stderr. Surfaces the nudge in conversation context, not just as a side-channel log. Zero cost when compliant.

Motivation

Since moving from hard-blocking hooks (v2.0.0) to soft stderr nudges, Claude frequently "forgets" to delegate — the ~200-token stub injected at session start gets buried as conversation grows, and stderr nudges after the fact aren't enough to prevent the first violation.

Test plan

  • All 37 existing tests pass (updated to verify structured JSON output)
  • Ruff + Pyright clean
  • Manual: start a new session, give a multi-step task, verify Claude delegates instead of executing directly
  • Manual: verify subagents don't see the per-turn reminder (no double-delegation)

🤖 Generated with Claude Code

The soft nudge system was too weak — Claude would "forget" to delegate
after the initial stub injection faded in context. Three non-blocking
layers now reinforce delegation:

1. Stub rewrite: opens with BLOCKING REQUIREMENT (proven constraint
   pattern), cut from ~450 to ~167 words
2. Per-turn reminder: UserPromptSubmit emits one-line stderr treated
   as user speech (~14 tokens/turn, subagent-safe)
3. Structured output: PreToolUse violations now emit additionalContext
   via stdout JSON (surfaces in conversation, not just stderr logs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

barkain and others added 2 commits May 12, 2026 22:57
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Nothing actually blocks — the phrasing implied technical enforcement
that doesn't exist. MANDATORY is equally strong as a prompt directive
without misrepresenting the mechanism.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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