Sub-agents ignore explicit rules embedded in their own prompt
Bug Report
Category: logic-error
Severity: Major
Claude Code Version: 2.1.84
OS: Windows 11 Pro
Description
When Claude spawns sub-agents with detailed rules in the prompt, the agents frequently violate those exact rules. The rules are present in the prompt text that the agent receives, yet the agent generates output that contradicts them.
Examples (all from today)
Rule in prompt: "Width maxim pe campuri text din header: MAX 300px!"
Agent output: Generated textField with width=434px, which covered all fields below it making them invisible.
Rule in prompt: "Padding pe celule tabel: OBLIGATORIU leftPadding=2 rightPadding=2"
Agent output: Generated cells without any padding, causing text from adjacent columns to appear visually merged.
Rule in prompt: "Header tabel: Background #D0D0D0 (gri), text #000000"
Agent output: 5 out of 26 reports had header background #008B8B (teal) or no background at all.
Rule in prompt: "Crosstab in DETAIL band, not summary"
Agent output: All 7 crosstab reports placed the crosstab in summary band, causing blank first page.
Expected Behavior
When rules are explicitly stated in the agent's prompt, the agent should follow them. These are not subtle guidelines — they are explicit, bold, capitalized rules with examples of WRONG vs CORRECT.
Impact
- Every rule violation required a follow-up fix cycle (agent + render + verify)
- 16 out of 26 reports needed post-generation fixes
- Multiple hours of rework
- Rules had to be added repeatedly because agents kept ignoring them
Possible Causes
- Long prompts with many rules — attention may focus on early rules and miss later ones
- Agent uses cached patterns from training data that conflict with prompt rules
- Rules are stated as constraints but agent optimizes for "complete the task" over "follow all rules"
Suggested Fix
- Move critical rules to the TOP of the prompt (not buried in the middle)
- Add a post-generation self-check: "Before returning, verify these 5 critical rules..."
- Use structured validation (JSON schema?) rather than prose rules
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗