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.
The Markdown format follows a clear separation of concerns:
This ensures both human-friendly storytelling and machine-friendly structured data.
Key Benefits:
Pre-built expert personas are available in the examples/library/ directory. These represent real domain expertise that can be loaded and customized:
construction_project_manager.md
- Timeline and coordination expertisearchitectural_specialist.md
- Design buildability and code compliancevalue_engineering_specialist.md
- Cost optimization and ROI analysissenior_software_architect.md
- System design and architecturesenior_data_engineer.md
- Data pipeline and platform expertisesenior_product_manager.md
- Product strategy and roadmap planningThe 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.
See the complete example in examples/construction_team.py.
This example demonstrates the Markdown library pattern in action: