ag2-persona

Examples

The Power of Markdown Persona Libraries

PersonaAgent’s strength lies in separating expertise definition from runtime configuration. Domain experts can define agent personas in Markdown files, while developers handle the technical integration.

Design Philosophy: Spec vs Character

The Markdown format follows a clear separation of concerns:

  1. Frontmatter = Structure (what the system needs)
  2. Markdown = Narrative (what makes the character real)

This ensures both human-friendly storytelling and machine-friendly structured data.

Key Benefits:

Persona Library

Pre-built expert personas are available in the examples/library/ directory. These represent real domain expertise that can be loaded and customized:

Construction Team

Software Development

Loading Expert Personas

The power of PersonaBuilder shines when loading domain expert personas from the library:

from ag2_persona import PersonaBuilder, AsyncPersonaBuilder

# Sync version - blocks during file I/O
architect = (PersonaBuilder.from_markdown("examples/library/senior_software_architect.md")
            .set_name("architect")
            .llm_config({"model": "gpt-4", "temperature": 0.7})
            .build())

# Async version - non-blocking I/O for high-performance apps
async def load_architect():
    return await (AsyncPersonaBuilder("architect")
                 .from_markdown("examples/library/senior_software_architect.md")
                 .llm_config({"model": "gpt-4", "temperature": 0.7})
                 .build())

# Domain experts can edit the Markdown files
# Developers handle runtime LLM configuration
# Perfect separation of concerns!

When to use async:

Why this pattern works so well:

For complete documentation of available personas, see examples/README.md.

Multi-Agent Construction Team

See the complete example in examples/construction_team.py.

This example demonstrates the Markdown library pattern in action: