PersonaAgent: a configurable, persona-based LLM agent wrapper with memory, skills, and adaptive behavior.
Project description
PersonaAgent
PersonaAgent is a Python library for building persona-based LLM agents - agents that:
- Are instantiated with different personalities, styles, and skills
- Maintain memory of past interactions
- Can be wired to any LLM backend (OpenAI, Anthropics, etc.)
- Are easy to compose into multi-agent systems
Concept: a PersonaAgent is "a configurable, persona-based LLM agent that can be instantiated with different skills and styles and that adapts based on its past interactions."
Features
- Persona profiles - define personality, style, goals, domain, etc.
- Memory - simple interaction history + extensible hooks for long-term memory.
- Skills - plug in Python functions the agent can call.
- Model-agnostic - you pass in how to call your LLM.
- Composable - use multiple PersonaAgents in the same app.
Installation
pip install persona-agent
Quickstart
from persona_agent.core import PersonaAgent
from persona_agent.profiles import DOCTOR_PROFILE
# 1. Define how to call your model
def dummy_model(prompt: str, **kwargs) -> str:
# Replace this with a real LLM call
return f"(Model responding to): {prompt[:80]}..."
# 2. Instantiate a PersonaAgent
agent = PersonaAgent(
name="Dr. Maple",
model=dummy_model,
persona=DOCTOR_PROFILE,
)
# 3. Interact
response = agent.react("What are common symptoms of generalized myasthenia gravis?")
print(response)
Using LiteLLM (recommended for real models)
PersonaAgent works great with LiteLLM – a unified client for 100+ LLMs (OpenAI, Anthropic, Azure, Ollama, etc.). :contentReference[oaicite:3]{index=3}
from persona_agent.core import PersonaAgent
from persona_agent.profiles import DOCTOR_PROFILE
from persona_agent.models import make_litellm_chat_model
# configure LiteLLM via env vars, e.g.
# export OPENAI_API_KEY="sk-..."
model = make_litellm_chat_model(
model_name="openai/gpt-4o-mini",
temperature=0.2,
max_tokens=512,
)
agent = PersonaAgent(
name="Dr. Maple",
model=model,
persona=DOCTOR_PROFILE,
)
print(agent.act("Explain generalized myasthenia gravis in patient-friendly language."))
Persona definition
A persona is just a Python dict:
doctor_persona = {
"role": "neurologist",
"personality": "calm, analytical, empathetic",
"style": "concise, medically accurate, patient-friendly",
"goals": [
"educate patients safely",
"avoid providing diagnosis",
"encourage consultation with physicians",
],
"domain": "neurology, autoimmune diseases",
}
You can load predefined ones from persona_agent.profiles.
Skills
You can attach Python functions as skills:
def search_literature(query: str) -> str:
# Stub: connect to your own system
return f"Search result for: {query}"
agent.add_skill("search_literature", search_literature)
# Then call inside your app:
result = agent.call_skill("search_literature", "efgartigimod gMG phase 3")
print(result)
Agent logic itself is up to you: PersonaAgent provides the structure and hooks.
Memory
By default, PersonaAgent keeps a simple in-memory history of interactions:
agent.react("Hello!")
agent.react("Tell me a joke about neurons.")
print(agent.memory.recent(5))
You can also plug in your own memory backend (e.g., vector DB, file, Redis) by subclassing Memory.
Project structure
src/persona_agent/
core.py # PersonaAgent main class
memory.py # Memory abstractions
skills.py # Skill registry and helpers
profiles.py # Predefined persona profiles
models.py # Model adapter types / helpers
Roadmap
- Built-in LLM adapters (via
litellm) - Vector-based long-term memory
- Configuration of persona specs
- Multi-agent interactions (follow MCP?)
Contributing
- Fork this repo
- Create a branch:
git checkout -b feature/my-feature - Run tests: pytest
- Open a Pull Request 🎉
License
This project is licensed under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file persona_agent-0.1.1.tar.gz.
File metadata
- Download URL: persona_agent-0.1.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f14edb4fede9edea1b01496422add0864f69c43d36d2c60c177b4e2bbcb93fa
|
|
| MD5 |
849023181bc8ba106c2013c03d5c60ad
|
|
| BLAKE2b-256 |
32ba014d5355a9cd02f12a9b6156a031a3242bfcb01d2dcd89051aef7d7aedd2
|
File details
Details for the file persona_agent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: persona_agent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83c642705a93572dc62d03ff77e139cda17b516b1030f739199fc966eac7811e
|
|
| MD5 |
b7e8c1611ae6ca1fa76e2c7648c3f1d4
|
|
| BLAKE2b-256 |
0892f517a5acdcfa7e134d14c3266731685f517ea6809684e3ede3601dad0f14
|