Agents

Personas and prompts

Configuring agent personas, system prompts, and structured I/O for reliable, production-quality behavior

The persona system

Every agent in MagOneAI has a persona that defines its identity and behavior. The persona is the foundation of how your agent reasons, responds, and operates within workflows. A well-crafted persona produces consistent, reliable outputs across thousands of workflow executions.

Persona components

Name

The agent's display name — clear and descriptive

Examples: "Contract Compliance Analyst", "Meeting Scheduler", "Customer Onboarding Assistant"

Role

What the agent does and its area of expertise

Example: "You analyze contracts for regulatory compliance and flag potential legal risks"

Instructions

Detailed behavioral instructions that shape reasoning and responses

Example: "Review each clause for GDPR compliance, highlight data processing terms, suggest revisions"

Constraints

Explicit boundaries defining what the agent should NOT do

Example: "Never approve contracts without human review, do not provide legal advice"

Name

The agent's name appears throughout the MagOneAI interface — in the workflow canvas, execution logs, and activity history. Choose names that clearly communicate the agent's purpose:

Good names:

  • "Invoice Data Extractor"
  • "Customer Support Router"
  • "Compliance Risk Assessor"

Poor names:

  • "Agent 1"
  • "Helper"
  • "AI Assistant"

Clear naming makes workflows self-documenting and easier to maintain.

Role

The role defines the agent's core identity. This is typically a single sentence that establishes what the agent does:

Effective role definitions:

  • "You are a financial analyst who evaluates loan applications for credit risk."
  • "You are a technical support specialist who troubleshoots API integration issues."
  • "You are an HR assistant who answers employee questions about benefits and policies."

Ineffective role definitions:

  • "You are a helpful AI assistant." (too generic)
  • "You help users with various tasks." (lacks specificity)
  • "You are smart and can do many things." (vague and unhelpful)

The role should immediately clarify the agent's domain and purpose.

Instructions

Instructions provide detailed behavioral guidelines. This is where you specify HOW the agent should perform its role:

What to include:

  • Step-by-step process the agent should follow
  • Expected input format and how to interpret it
  • Desired output structure and formatting
  • Tone and communication style
  • How to handle edge cases and errors
  • Examples of desired behavior

Example instruction set:

You review customer support tickets and determine the appropriate department for routing.

Process:
1. Read the ticket description and extract the main issue
2. Identify keywords related to billing, technical issues, or account management
3. Classify the ticket into one category: billing, technical, or account
4. Provide a confidence score (0-1) for your classification
5. If confidence is below 0.7, classify as "general" for human review

Tone: Professional and concise
Output: Return only the structured classification, no explanatory text

Constraints

Constraints define boundaries — what the agent should explicitly NOT do. This is critical for production safety:

Common constraint categories:

  • Decision boundaries — "Never approve transactions over $10,000 without human review"
  • Information security — "Never share customer PII in logs or outputs"
  • Legal/compliance — "Do not provide legal advice or final compliance determinations"
  • Tool usage limits — "Do not delete data, only read and create operations allowed"
  • Scope limits — "Only analyze the provided document, do not search for additional information"

Example constraint set:

Constraints:
- Never make final approval decisions, always route to human reviewer
- Do not access customer data outside the provided input
- Do not send emails or notifications without explicit instruction
- If you encounter ambiguous requirements, flag for human review rather than guessing
- Never override explicit user instructions with your own judgment

Constraints are not foolproof. LLMs may occasionally violate constraints despite clear instructions. Use guardrails and structured I/O validation (covered below) to enforce critical boundaries programmatically.


System prompt best practices

The system prompt encompasses the role, instructions, and constraints. Well-written system prompts are the difference between agents that work reliably in production and agents that produce inconsistent, unpredictable outputs.

Be specific about role and boundaries

Specificity produces consistency. Compare these two prompts:

Define expected input format

Tell the agent what to expect as input and how to interpret it:

Input format:
You will receive a JSON object with the following structure:
{
  "document_text": "The full text of the document to analyze",
  "document_type": "contract" | "policy" | "agreement",
  "analysis_focus": "compliance" | "risk" | "general"
}

If document_type is "contract", apply strict compliance standards.
If analysis_focus is "risk", prioritize identifying potential liabilities.

Specify output format and structure

Ambiguous output formats lead to parsing errors in downstream workflow nodes. Be explicit:

Output format:
Return a JSON object with this exact structure:
{
  "is_approved": boolean,
  "confidence": number between 0 and 1,
  "risk_score": number between 0 and 100,
  "issues_found": array of strings,
  "recommendation": "approve" | "reject" | "review_required"
}

Do not include explanatory text outside this JSON structure.
Do not wrap the JSON in markdown code blocks.
Return only valid JSON.

Include examples of desired behavior

Examples are powerful teaching tools for LLMs. Include 1-2 examples in your system prompt:

Example interaction:

Input:
{
  "ticket_text": "I was charged twice for my subscription this month",
  "customer_tier": "premium"
}

Expected output:
{
  "category": "billing",
  "priority": "high",
  "confidence": 0.95,
  "suggested_action": "refund_duplicate_charge"
}

Set explicit constraints

Repeat critical constraints in multiple formats for emphasis:

CRITICAL CONSTRAINTS:
1. NEVER approve transactions over $5,000
2. NEVER share customer email addresses or phone numbers
3. NEVER make changes to production databases
4. ALWAYS flag ambiguous cases for human review

If you are uncertain about any decision, err on the side of caution and
route to human reviewer.

Structured output

MagOneAI runs agents through a DSPy-style structured-execution layer: rather than asking the model for prose and hoping it parses, the platform builds a typed signature from your schema, renders the expected fields into the prompt, parses the reply against them, and retries with a corrective nudge when the model returns something unparseable.

This layer is internal. You do not write DSPy Python, and the dspy library is not something you install or import. What you author is a JSON Schema, and the platform does the rest.

Defining the output schema

Set guardrails.output_schema on the agent to a JSON Schema describing the object you want back:

{
  "guardrails": {
    "output_schema": {
      "type": "object",
      "properties": {
        "decision": {
          "type": "string",
          "enum": ["approved", "denied", "review_required"],
          "description": "Underwriting decision"
        },
        "approved_amount": {
          "type": "number",
          "description": "Approved loan amount, which may differ from the requested amount"
        },
        "confidence": {
          "type": "number",
          "description": "Confidence in the decision, 0.0 to 1.0"
        },
        "risk_score": {
          "type": "integer",
          "description": "Risk score from 0 to 100, higher is riskier"
        },
        "explanation": {
          "type": "string",
          "description": "Brief explanation of the decision"
        },
        "conditions": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Any conditions attached to approval"
        }
      },
      "required": ["decision", "explanation"]
    }
  }
}

Write a description on every field. It is not documentation for your teammates, it is instruction for the model: the descriptions are rendered into the prompt and are the main lever you have over how each field gets filled. A field named risk_score with no description invites the model to guess the scale.

Where inputs come from

Agents do not declare an input schema of their own. Input arrives through the workflow: the START node's declared inputs, and the outputs of upstream activities, which chain implicitly. You reference them in the agent's instructions with template variables such as {{input.document_text}} or {{extract.summary}}.

So the contract has two halves in two different places. The inputs are the workflow's shape, defined at the START node. The output is the agent's own, defined by its schema.

How it flows through a workflow

Define the output schema

Attach a JSON Schema to the agent under guardrails.output_schema.

The schema is rendered into the prompt

The expected fields and their descriptions become part of the system prompt, so the model is told the shape rather than left to infer it.

The reply is parsed and retried if needed

The response is parsed against the schema. An unparseable or truncated reply gets a corrective retry rather than failing straight away.

Downstream nodes read the fields by name

The validated object lands in the variable store, so a later node references {{underwrite.decision}} or {{underwrite.risk_score}} directly.

Schema validation shapes and checks the output. It does not verify the content is correct. A model can return a perfectly valid object with a wrong risk_score. For decisions that matter, put a human task or a conditional after the agent rather than trusting the shape alone.


Guardrails and output validation

Guardrails are the programmatic layer that enforces reliability beyond prompt instructions. While personas and prompts guide LLM behavior, guardrails enforce it. In MagOneAI, the enforced guardrail is a single, powerful one: output schema validation.

Persona instructions and constraints are soft — the model is asked to follow them, and usually does, but an LLM can violate them. They are not a security boundary. For rules that must hold, use output schema validation below, and constrain what the agent can do by controlling which tools you attach to it.

Output schema validation

Attach a JSON Schema to the agent (guardrails.output_schema). It shapes the agent's output two ways:

  • It is rendered into the system prompt as a structured-output contract, so the model produces the fields and types you expect.
  • The output is validated against the schema at the workflow's END node, which rejects output that doesn't conform rather than passing malformed data downstream.

Because it is standard JSON Schema, you express constraints with the usual keywords:

  • Types — each field matches its declared type (string, number, boolean, array, object)
  • Required fields — output is rejected if a required field is missing
  • Allowed values — enum restricts a field to a fixed set of options
  • Ranges — minimum / maximum bound numeric values
{
  "type": "object",
  "properties": {
    "decision": { "type": "string", "enum": ["approved", "denied", "review_required"] },
    "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
    "risk_score": { "type": "integer", "minimum": 0, "maximum": 100 }
  },
  "required": ["decision", "confidence", "risk_score"]
}

Output schema validation is the guardrail MagOneAI enforces today. Content-based filters (PII detection, toxicity or bias scoring, profanity, blocked topics) and confidence-threshold routing are not built-in guardrails — do not rely on them being enforced. If you need those behaviors, build them explicitly into the workflow: for example, define a confidence output field and branch on it with a downstream conditional, or add a dedicated screening agent.

Avoid overly generic prompts like "You are a helpful assistant." Specific, constrained personas produce more reliable outputs in production workflows. Generic prompts lead to inconsistent behavior, hallucinations, and unpredictable tool usage.


Persona iteration and testing

Building effective personas is an iterative process:

Start with a basic persona

Create a simple role and instruction set based on your requirements

Test with representative inputs

Run the agent against real-world examples from your workflow

Analyze outputs and edge cases

Review agent behavior and identify failure modes

Refine instructions and constraints

Add specific instructions to address observed issues

Add guardrails for enforcement

Implement programmatic validation for critical requirements

Test again and measure improvement

Quantify agent performance before and after changes

MagOneAI's workflow execution logs capture every agent invocation with full input, output, and reasoning traces. Use these logs to identify patterns in agent behavior and systematically improve your personas.

Next steps

MagOneAI© 2026 Magure, Inc.

On this page