Skip to main content

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 descriptiveExamples: “Contract Compliance Analyst”, “Meeting Scheduler”, “Customer Onboarding Assistant”

Role

What the agent does and its area of expertiseExample: “You analyze contracts for regulatory compliance and flag potential legal risks”

Instructions

Detailed behavioral instructions that shape reasoning and responsesExample: “Review each clause for GDPR compliance, highlight data processing terms, suggest revisions”

Constraints

Explicit boundaries defining what the agent should NOT doExample: “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:

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 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:
Problems:
  • No defined role or expertise area
  • Vague instructions like “try to be accurate”
  • No constraints or boundaries
  • No output format specification
  • Will produce inconsistent behavior across executions
Why this works:
  • Clear domain expertise (GDPR compliance)
  • Step-by-step process
  • Structured output format
  • Explicit constraints and boundaries
  • Handles edge cases (out of scope scenarios)

Define expected input format

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

Specify output format and structure

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

Include examples of desired behavior

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

Set explicit constraints

Repeat critical constraints in multiple formats for emphasis:

DSPy structured I/O

MagOneAI uses DSPy (Declarative Self-improving Python) to define and enforce structured input and output schemas for agents. This ensures type safety and predictable data flow through your workflows.

What is DSPy?

DSPy is a framework for programming with language models using structured signatures. Instead of relying on prompt engineering alone, you define input/output contracts that the system optimizes and enforces.

Defining input schemas

Input schemas specify what data the agent expects and in what format:
When you attach this schema to an agent, MagOneAI validates incoming data before execution and provides clear error messages if the input doesn’t match the expected structure.

Defining output schemas

Output schemas ensure the agent produces data in the exact format your workflow expects:

Integration with workflow variable mapping

Structured I/O schemas integrate directly with MagOneAI’s workflow variable system:
1

Define schemas

Create input and output schemas for your agent using DSPy signatures
2

Map workflow variables to input schema

In the workflow canvas, map variables from previous nodes or workflow parameters to the agent’s input fields
3

Agent executes with validated input

MagOneAI validates the input against the schema before agent execution
4

Output is validated and stored

Agent output is validated against the output schema and stored in the workflow variable store
5

Downstream nodes access structured output

Subsequent workflow nodes access the agent’s output fields by name with guaranteed type safety

Example: Full schema definition

Here’s a complete example of input and output schemas for a loan underwriting agent:
When this agent executes in a workflow, you have guaranteed type safety and structure for both input and output.

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 valuesenum restricts a field to a fixed set of options
  • Rangesminimum / maximum bound numeric values
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:
1

Start with a basic persona

Create a simple role and instruction set based on your requirements
2

Test with representative inputs

Run the agent against real-world examples from your workflow
3

Analyze outputs and edge cases

Review agent behavior and identify failure modes
4

Refine instructions and constraints

Add specific instructions to address observed issues
5

Add guardrails for enforcement

Implement programmatic validation for critical requirements
6

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

Knowledge bases and RAG

Add knowledge bases to ground agent responses in your documents

MCP tools

Connect tools to enable agent actions in external systems

Testing workflows

Learn how to test agents within workflow executions