Agent
A self-contained AI agent bundling persona, memory, and conversation history.
Usage
Agent()An Agent wraps a ChatBot, a PersonaDefinition, a MemoryStore, and a ConversationCapture into a single entity that can participate in multi-agent workflows.
The agent configures its ChatBot automatically from the persona (system prompt, temperature, tools, guardrails) and applies retention policies after each response when a RetentionPolicy is attached.
Parameters
name: str-
Unique identifier for this agent (e.g.,
"triage_bot"). persona: PersonaDefinition-
The persona definition that drives the agent’s behavior.
memory: MemoryStore = (lambda: MemoryStore(long_term_path=":memory:"))()-
The agent’s memory store. Defaults to an in-memory store.
chatbot: ChatBot = None-
A pre-configured ChatBot. If
None, one is built from the persona automatically. capture: ConversationCapture = ConversationCapture()-
Conversation capture for recording events. Created automatically if not provided.
instructions: str = ""-
Additional instructions appended to the persona’s system prompt.
metadata: dict[str, Any] = dict()- Arbitrary metadata for the agent (e.g., team, version, owner).
Examples
Create an agent from a built-in persona:
import talk_box as tb
agent = tb.Agent.from_persona("code_reviewer")
agent.name # "code_reviewer"
agent.persona.display_name # "Code Reviewer"Create a custom agent with memory and retention:
import talk_box as tb
policy = tb.RetentionPolicy(
remember_tags=["identity", "preference"],
forget_tags=["scratch"],
)
agent = tb.Agent(
name="support_agent",
persona=tb.create_persona(
"support",
persona_role="customer support specialist",
retention=policy,
),
memory=tb.MemoryStore(long_term_path="support.db"),
)Respond to a user message:
conversation = agent.respond("How do I reset my password?")