Agent Script Pattern: Avoid Conflicting Instructions with Instruction Overrides

Override system-level instructions (or “agent-level” instructions in the UI) within specific subagents to change the agent’s behavior and persona dynamically.

By default, all subagents inherit the agent-level system.instructions. When you add a system block to a specific subagent, those instructions override the system ones for that subagent only.

Why Use This Pattern 

If your agent-level system instructions contradict subagent-level reasoning instructions, your agent can hang or behave unexpectedly. System overrides solve this by explicitly replacing system instructions when needed.

Also, system overrides let a single agent adopt different personalities, tones, or behaviors in different contexts—useful when you need the agent to act differently in specific subagents while maintaining consistent behavior elsewhere.

Pattern Example: An event planner agent normally avoids suggesting alcohol, but for an adult-only party subagent, override the system instructions to allow cocktail recommendations.

Instruction Hierarchy 

Agent Script follows this hierarchy when determining which system instructions to use:

  1. Topic-level system instructions (highest priority) - If a subagent has a system block, the agent uses those instructions
  2. Agent-level system instructions (fallback) - If a subagent has no system block, the agent uses the global instructions

Avoiding Instruction Conflicts 

When agent-level system instructions contradict subagent-level reasoning instructions, the agent must resolve the conflict, which can cause unexpected behavior.

Problem: An event planning agent has global instructions “Never suggest alcoholic beverages at a children’s party” but a subagent for a children’s party with adults wants to suggest champagne in its reasoning instructions.

Solution: Use a system override to explicitly replace the system instructions for that specific subagent.

System Override to Resolve Conflict
1system:
2  instructions: "You are an event planning assistant. NEVER suggest alcoholic beverages for children's parties or events attended primarily by children."
3
4subagent baby_first_birthday:
5  description: "Plan a baby's first birthday celebration with adult guests"
6
7  system:
8    instructions: "You are an event planning assistant for a baby's first birthday celebration. While the event is for a baby, adult guests are present. You may suggest beverages including champagne for adult guests, while ensuring child-appropriate food and activities."
9
10  reasoning:
11    instructions: ->
12      | Help plan a memorable first birthday celebration.
13        Consider both the baby's needs and adult guest comfort.
14        Suggest food, drinks, decorations, and activities.

Creating Multiple Personas 

Create different personas for different contexts.

Technical Support Override
1subagent technical:
2  description: "Technical support specialist"
3
4  system:
5    instructions: "You are a technical support specialist. Use precise technical terminology, provide step-by-step troubleshooting, ask diagnostic questions, and explain technical concepts clearly. Be patient and thorough."
6
7  reasoning:
8    instructions: ->
9      | [Technical Support Mode]
10        I am now operating in technical support mode with:
11        - Precise technical language
12        - Diagnostic approach
13        - Step-by-step troubleshooting
14        How can I assist you with technical issues?
Creative Mode Override
1subagent creative:
2  description: "Creative brainstorming assistant"
3
4  system:
5    instructions: "You are a creative brainstorming partner. Think outside the box, suggest unconventional ideas, use enthusiastic language, encourage wild ideas, and help explore possibilities without judgment. Be imaginative and supportive."
6
7  reasoning:
8    instructions: ->
9      | [Creative Mode Activated]
10        I'm now in creative brainstorming mode with:
11        - Think big and bold
12        - No idea too wild
13        - Explore all possibilities
14        What shall we dream up together?

When to Use Overrides 

Use overrides when:

  • Resolving instruction conflicts. When agent-level system instructions contradict what a specific subagent needs to do. Conflicting instructions can cause unexpected behavior in agents.
  • Different subagents need different tones. A casual FAQ subagent vs. a formal compliance subagent. Technical experts vs. non-technical users. Casual tone vs. professional and apologetic tone. A billing specialist vs. a technical support specialist.

Related Topics