[BUG] Main context provides incomplete/incorrect instructions to agents with Sonnet 4.5
[BUG] Main context provides incomplete/incorrect instructions to agents with Sonnet 4.5
Description
The main Claude Code context is failing to provide proper instructions when delegating to agents via the Task tool. Agents receive inadequate or incorrect task descriptions, leading them to perform wrong actions (e.g., code review instead of TDD implementation), after which the main context loses track and asks the user for next steps without any context.
Environment
- Claude Code Version: 2.0.1
- Platform: Linux (Rocky Linux, kernel 5.14.0-570.37.1.el9_6.x86_64)
- Architecture: x86_64
- Model: claude-sonnet-4-5-20250929
- Agent System: Task tool with custom agents (tdd-engineer, code-reviewer, etc.)
Symptoms
- User requests work that requires agent delegation
- Main context invokes agent via Task tool
- Agent receives incomplete/wrong instructions - prompt doesn't match intended task
- Agent performs incorrect work (e.g., code review when TDD implementation was needed)
- Agent returns results to main context
- Main context loses track of what was requested and asks user for options/next steps with no context about original request
- User is confused - expected completed implementation, got assessment and "what do you want to do?" question
Expected Behavior
When delegating to agents:
- Main context should formulate clear, complete task instructions based on user request
- Agent should receive all necessary context and specific action items
- Agent should perform the correct type of work (implementation, review, etc.)
- Main context should maintain awareness of original request and agent results
- Main context should report completion or next steps with full context
Actual Behavior
Main context appears to:
- Generate inadequate prompts for agent tasks
- Lose connection between user's original request and agent delegation
- Not verify agent performed correct type of work
- Forget what it delegated after agent returns
- Ask user vague questions ("what do you want to do?") without context
Example Scenario
User Request: "Fix this bug using TDD methodology"
Expected Flow:
- Main context → Task(tdd-engineer, prompt: "Fix [bug] by writing failing tests first, then implement fix with test coverage")
- tdd-engineer → Implements fix with tests
- Main context → Reports: "Bug fixed. Tests passing. Here are the changes..."
Actual Flow (Broken):
- Main context → Task(tdd-engineer, prompt: [inadequate/wrong instructions])
- tdd-engineer → Performs code review and assessment (wrong task type)
- Main context → "Here's an assessment. What would you like to do?" (no context, wrong completion)
Regression Information
Critical: This issue did NOT occur with previous Sonnet versions (3.5, 4.0)
- Prior to Sonnet 4.5: Agent delegation worked correctly with proper instructions
- After Sonnet 4.5 (sonnet-4-5-20250929): Agent instructions frequently inadequate/incorrect
- Timing: Issue appeared immediately after upgrading to Sonnet 4.5
Related Issues
This appears related to:
- #8548 - "Claude sonnet-4-5 instruction ignoring and assumption escalation" (Sept 30, 2025)
- #5483 - "Async Sub-Agent Delegation Breaks Context Tracking" (Aug 10, 2025)
- microsoft/vscode-copilot-release#12872 - "Agent mode ignores instructions, does opposite" (June 19, 2025)
Key Similarity: All involve Sonnet 4/4.5 failing to follow instructions or maintain context in agent/delegation scenarios.
Impact
- Agent-based workflows completely broken
- Cannot delegate TDD implementation, code reviews, or other specialized tasks
- Main context confusion creates poor user experience
- Requires manual intervention and re-explanation on every agent invocation
- Makes multi-step orchestrated workflows impossible
Reproduction Steps
- Set up custom agents using Task tool (tdd-engineer, code-reviewer, etc.)
- Request work that requires agent delegation: "Implement [feature] using TDD"
- Observe main context invoke agent with Task tool
- Observe agent performs wrong type of work (review instead of implementation)
- Observe main context loses track and asks vague follow-up questions
Additional Context
- Using custom agent definitions in
~/.claude/agents/ - Agents work correctly when proper instructions are provided manually
- Problem is specifically with main context's prompt generation for agent delegation
- Issue is consistent across multiple agent types (tdd-engineer, code-reviewer, etc.)
- Main context appears to understand user intent initially but fails to translate it into proper agent instructions
Suggested Investigation
- Prompt Generation: Check how Sonnet 4.5 generates Task tool prompts vs. previous versions
- Context Retention: Verify main context maintains awareness of delegation after agent returns
- Instruction Completeness: Compare Task tool prompts between Sonnet 4.0 and 4.5 for same user requests
- Agent Result Processing: Check if main context properly processes agent results vs. losing context
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗