Skip to main content

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 typing import List
from persona_agent.core import PersonaAgent, ChatMessage

# 1. Define how to call your model
def echo_model(messages: List[ChatMessage], **_) -> str:
  # Replace with real LLM call.
  if not messages or not messages[-1].content.strip():
    return "(nothing to echo)\n"
  return f"{messages[-1].content}"

# 2. Instantiate a PersonaAgent
agent = PersonaAgent(
  name="EchoBot",
  model=echo_model,
)

# 3. Interact
response = agent.react("how r u doing?")
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.lite_llm import make_litellm_chat_model
from persona_agent.profiles import DOCTOR_PROFILE

# 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.react("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

  1. Fork this repo
  2. Create a branch: git checkout -b feature/my-feature
  3. Run tests: pytest
  4. Open a Pull Request 🎉

License

This project is licensed under the MIT license.

Metadata

Release files for persona-agent 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for persona-agent 0.1.2
File Size Uploaded Provenance Actions
persona_agent-0.1.2.tar.gz 5.4 kB Without provenance Details for persona_agent-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for persona-agent 0.1.2
File Interpreter ABI Platform Actions
persona_agent-0.1.2-py3-none-any.whl Python 3 none any Details for persona_agent-0.1.2-py3-none-any.whl

Total release size: 13.0 kB

Release files / persona_agent-0.1.2.tar.gz

Download URL persona_agent-0.1.2.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e8bada4d14e3ead3f2582f7c31bec4717d31bcf86c5b4fc23bbdcf021a207456
BLAKE2b-256 checksum
How to use checksums
10ba0a30d13b088f03c7e20623f08b04841293b5f638db43d21eac7450d13abd
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / persona_agent-0.1.2-py3-none-any.whl

Download URL persona_agent-0.1.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dbd4c4d85f621051e94ac4c1be26ca1cac018921d677718f2af21e655385ef8
BLAKE2b-256 checksum
How to use checksums
dbd9d2c389258540c10399abc706ec9668584fe0c8300790c3ca1beb223a066b
Upload date
Uploaded using Trusted Publishing?
What is 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}

Security for persona-agent 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page