Skip to main content

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 import PersonaAgent, 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)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

persona_agent-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

persona_agent-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file persona_agent-0.1.0.tar.gz.

File metadata

  • Download URL: persona_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 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

Hashes for persona_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 04755975f91a6e2d9e906a3b497854a2a1b6380f4aa4fbed511f3c400418c6fe
MD5 2c8ab2e1b0cf942fbb8e1cb50888da94
BLAKE2b-256 8c6607604f17a985e07781e295c0c23f679e6e025cf5beb1936005b935be9d0d

See more details on using hashes here.

File details

Details for the file persona_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: persona_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 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

Hashes for persona_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f4d06fd2265f6df26a3d055de4212eeb1e981231f661fd645db0f5988404419
MD5 1c3992bdeb60e90798b55e7bbc348731
BLAKE2b-256 4248d49c523ba56da37aee1138d9c5c176823a6660c16d57d0e6390ca7b20eb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page