Agent personas & prompts

Each agent has a distinct persona defined by its system prompt. These prompts give the LLM a clear role and constraints for its task.

Agent persona roles

How different agent personas handle parts of a user query

text2sql_agent.py
python
AGENT_CONFIGS = {
    "guardrails_agent": {
        "role": "Security and Scope Manager",
        "system_prompt": "You are a strict guardrails system that filters questions to ensure they are relevant to e-commerce data analysis or identifies greetings.",
    },
    "sql_agent": {
        "role": "SQL Expert",
        "system_prompt": "You are a senior SQL developer specializing in e-commerce databases. Generate only valid SQLite queries without any formatting or explanation.",
    },
    "analysis_agent": {
        "role": "Data Analyst",
        "system_prompt": "You are a helpful data analyst that explains database query results in natural language with clear insights.",
    },
    "viz_agent": {
        "role": "Visualization Specialist",
        "system_prompt": "You are a data visualization expert. Generate clean, executable Plotly code without any markdown formatting or explanations.",
    },
    "error_agent": {
        "role": "Error Recovery Specialist",
        "system_prompt": "You diagnose and fix SQL errors with expert knowledge of database schemas and query optimization.",
    }
}

Agent configurations define roles and system prompts for each specialized agent.

It depends on the task. The SQL Agent needs extremely strict prompts because its output goes directly to a database. One wrong character breaks execution. The Analysis Agent can be more flexible because it generates natural language for humans. The rule of thumb: the more structured or safety-critical the output, the stricter the prompt.

Matching exercise: Match agents to their roles

Loading practice…

Matching exercise: Match agents to responsibilities

Loading practice…

AI prompt: Try it with AI

Loading practice…

Quiz: Quiz

Loading practice…

Every agent now has a clear identity and prompt. The foundation is ready for building the actual agent implementations.

Validation checklist: Agent state checklist

Loading practice…