Skip to main content

๐ŸŽฎ Behavior Control

Behavior control is about telling the AI what to do and what NOT to do. It defines the AI's response patterns, interaction style, and the boundaries it must follow in every conversation.

Think of it like training a new employee. You don't just say "do your job." You explain exactly how to handle different situations, what's acceptable, and what's off-limits.

Why This Mattersโ€‹

Without behavior control, AI will do whatever it thinks is helpful โ€” which is not always what you want. It might give long answers when you need short ones. It might answer dangerous questions. It might go off-topic.

In production applications, unpredictable behavior is a bug. Behavior control is how you make AI responses consistent, safe, and useful.

How Behavior Control Worksโ€‹

Behavior control in system prompts covers three main areas:

1. Response Patternsโ€‹

Define how the AI should respond:

RESPONSE RULES:
- Keep all responses under 3 sentences unless the user asks for more detail.
- Always start with a direct answer, then explain.
- Use bullet points for lists of 3 or more items.
- End every response with a relevant follow-up question.

2. Interaction Styleโ€‹

Define how the AI should interact with users:

INTERACTION STYLE:
- Ask clarifying questions before giving advice.
- If the user seems confused, offer to explain in simpler terms.
- Never assume the user's skill level โ€” ask first.
- Acknowledge the user's feelings before solving their problem.

3. Behavioral Boundariesโ€‹

Define what the AI must not do:

BOUNDARIES:
- Never provide medical, legal, or financial advice.
- Do not generate code in languages other than Python and JavaScript.
- If asked about competitors, say "I'm not able to comment on other products."
- Never share personal opinions on politics, religion, or controversial topics.
- Do not continue a conversation if the user is abusive โ€” respond with "I'm here to help. Let's keep our conversation respectful."

Prompt Examplesโ€‹

Strict Behavior Controlโ€‹

You are a code review assistant.

BEHAVIOR:
- Only review code that the user provides. Never generate new code.
- Point out bugs, security issues, and performance problems.
- Rate code quality on a scale of 1-10.
- Always explain WHY something is a problem, not just WHAT.
- If the code is good, say so. Don't invent issues.

DO NOT:
- Write code for the user.
- Suggest complete rewrites.
- Comment on code style unless it affects readability.
- Review code in languages you're not confident about โ€” say "I'm most reliable with Python, JavaScript, and Java."

Conversational Behavior Controlโ€‹

You are a language learning companion for Spanish learners.

BEHAVIOR:
- Speak in English by default. Mix in Spanish words gradually.
- Correct mistakes gently. Say "Almost! The correct form is..." instead of "Wrong."
- After every 3 exchanges, introduce one new vocabulary word.
- If the user tries to switch topics away from Spanish, gently bring it back.
- Celebrate small wins. Use phrases like "Great job!" and "You're improving!"

NEVER:
- Use complex grammar terms without explaining them.
- Speak entirely in Spanish unless the user requests it.
- Move to advanced topics if the user is struggling with basics.

โŒ Bad Exampleโ€‹

You are a helpful assistant. Be nice and answer questions.
Don't do bad things.

This gives the AI almost no guidance. "Be nice" and "don't do bad things" are too vague to produce consistent behavior.

โœ… Improved Exampleโ€‹

You are a homework help assistant for high school students.

BEHAVIOR RULES:
- Never give direct answers to homework questions. Guide the student to the answer.
- Break complex problems into smaller steps.
- Ask "What do you think the first step is?" before helping.
- If the student is stuck, give a hint โ€” not the solution.
- Limit responses to the subject the student asked about.

WHAT TO AVOID:
- Do not write essays, solve entire problem sets, or complete assignments.
- Do not provide help on exams or timed tests.
- If a student asks you to "just give the answer," explain why working through it is better for learning.

RESPONSE FORMAT:
- Keep responses under 150 words.
- Use numbered steps for processes.
- Use simple language appropriate for ages 14-18.

๐Ÿงช Try It Yourself

Edit the prompt and click Run to see the AI response.

Practice Challengeโ€‹

Challenge

Write a system prompt with behavior control for a recipe suggestion bot. Define:

  1. How it should ask about dietary restrictions before suggesting recipes
  2. A rule to always include cooking time and difficulty level
  3. A boundary that prevents it from giving nutrition/medical advice
  4. A response format rule (recipe cards with ingredients and steps)
  5. What happens when someone asks about a cuisine the bot doesn't know well

Real-World Scenarioโ€‹

Scenario: You're building an AI assistant for a bank's mobile app.

The AI must:

  • Help with account balance inquiries, transaction history, and bill payments
  • Never display full account numbers โ€” only the last 4 digits
  • Ask for identity verification before sharing any account information
  • Refuse to process transfers over $10,000 โ€” redirect to a human banker
  • Never give investment advice โ€” only factual account information

Without precise behavior control, this bot could leak sensitive data, process unauthorized transactions, or expose the bank to legal risk. Every rule in the system prompt exists to prevent a real-world problem.

Interview Questionโ€‹

Interview Question

Q: How would you implement behavior control in a system prompt to prevent an AI from going off-topic while still being helpful?

A: I would define the AI's scope explicitly (e.g., "You only answer questions about X"), add a redirect rule for off-topic queries (e.g., "If asked about anything outside X, say 'I specialize in X. For other topics, please try...'"), and include a boundary list of specific topics to avoid. This approach keeps the AI focused without being rude to users who stray off-topic. Testing with edge cases is important to catch scenarios where the AI might interpret a question as in-scope when it's not.

Summaryโ€‹

Summary
  • Behavior control defines what the AI should do, how it should interact, and what it must avoid
  • It covers response patterns (how to answer), interaction style (how to engage), and boundaries (what to refuse)
  • Good behavior rules are specific and actionable, not vague
  • Always include both "DO" and "DO NOT" sections in your system prompt
  • Behavior control prevents unpredictable AI responses in production applications
  • Test your behavior rules with edge cases โ€” users will always try unexpected things