> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent • AI Agent SDK

> Agent: Class reference for Agent

# Agent

> Defined in the [**agent**](../modules/agent) module.

<Badge color="blue">AI Agent</Badge>

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    input["Input Data"] --> agent["Agent: Agent"]
    agent --> output["Output Result"]
    style agent fill:#8B0000,color:#fff
    style input fill:#8B0000,color:#fff
    style output fill:#8B0000,color:#fff
```

## Constructor

<ParamField query="name" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="role" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="goal" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="backstory" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="instructions" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="llm" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="model" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="base_url" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="api_key" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="tools" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="allow_delegation" type="bool" required={false} default="False">
  ⚠️ **Deprecated** — use `handoffs=[other_agent]` instead.
</ParamField>

<ParamField query="allow_code_execution" type="Optional" required={false} default="False">
  ⚠️ **Deprecated** — use `execution=ExecutionConfig(code_execution=True)` instead.
</ParamField>

<ParamField query="code_execution_mode" type="Literal" required={false} default="'safe'">
  ⚠️ **Deprecated** — use `execution=ExecutionConfig(code_mode="safe")` instead.
</ParamField>

<ParamField query="handoffs" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="auto_save" type="Optional" required={false}>
  ⚠️ **Deprecated** — use `memory=MemoryConfig(auto_save="name")` instead.
</ParamField>

<ParamField query="rate_limiter" type="Optional" required={false}>
  ⚠️ **Deprecated** — use `execution=ExecutionConfig(rate_limiter=obj)` instead.
</ParamField>

<ParamField query="memory" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="knowledge" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="planning" type="Optional" required={false} default="False">
  No description available.
</ParamField>

<ParamField query="reflection" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="guardrails" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="web" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="context" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="autonomy" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="verification_hooks" type="Optional" required={false}>
  ⚠️ **Deprecated** — use `autonomy=AutonomyConfig(verification_hooks=[...])` instead.
</ParamField>

<ParamField query="output" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="execution" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="templates" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="caching" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="hooks" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="skills" type="Optional" required={false}>
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="from_template()" icon="function" href="../functions/Agent-from_template">
    Create an Agent from a template.
  </Card>

  <Card title="stream_emitter()" icon="function" href="../functions/Agent-stream_emitter">
    Lazy-loaded StreamEventEmitter for real-time events (zero overhead when not used).
  </Card>

  <Card title="stream_emitter()" icon="function" href="../functions/Agent-stream_emitter">
    Allow setting stream\_emitter directly.
  </Card>

  <Card title="auto_memory()" icon="function" href="../functions/Agent-auto_memory">
    AutoMemory instance for automatic memory extraction.
  </Card>

  <Card title="auto_memory()" icon="function" href="../functions/Agent-auto_memory">
    Instance method.
  </Card>

  <Card title="policy()" icon="function" href="../functions/Agent-policy">
    PolicyEngine instance for execution control.
  </Card>

  <Card title="policy()" icon="function" href="../functions/Agent-policy">
    Instance method.
  </Card>

  <Card title="background()" icon="function" href="../functions/Agent-background">
    BackgroundRunner instance for async task execution.
  </Card>

  <Card title="background()" icon="function" href="../functions/Agent-background">
    Instance method.
  </Card>

  <Card title="checkpoints()" icon="function" href="../functions/Agent-checkpoints">
    CheckpointService instance for file-level undo/restore.
  </Card>

  <Card title="checkpoints()" icon="function" href="../functions/Agent-checkpoints">
    Instance method.
  </Card>

  <Card title="output_style()" icon="function" href="../functions/Agent-output_style">
    OutputStyle instance for response formatting.
  </Card>

  <Card title="output_style()" icon="function" href="../functions/Agent-output_style">
    Instance method.
  </Card>

  <Card title="thinking_budget()" icon="function" href="../functions/Agent-thinking_budget">
    ThinkingBudget instance for extended thinking control.
  </Card>

  <Card title="thinking_budget()" icon="function" href="../functions/Agent-thinking_budget">
    Instance method.
  </Card>

  <Card title="context_manager()" icon="function" href="../functions/Agent-context_manager">
    ContextManager instance for unified context management.
  </Card>

  <Card title="context_manager()" icon="function" href="../functions/Agent-context_manager">
    Set context manager directly.
  </Card>

  <Card title="console()" icon="function" href="../functions/Agent-console">
    Lazily initialize Rich Console only when needed AND verbose is True.
  </Card>

  <Card title="skill_manager()" icon="function" href="../functions/Agent-skill_manager">
    Lazily initialize SkillManager only when skills are accessed.
  </Card>

  <Card title="get_skills_prompt()" icon="function" href="../functions/Agent-get_skills_prompt">
    Get the XML prompt for available skills.
  </Card>

  <Card title="agent_id()" icon="function" href="../functions/Agent-agent_id">
    Lazily generate agent ID when first accessed.
  </Card>

  <Card title="display_name()" icon="function" href="../functions/Agent-display_name">
    Safe display name that never returns None.
  </Card>

  <Card title="analyze_prompt()" icon="function" href="../functions/Agent-analyze_prompt">
    Analyze prompt for autonomy signals.
  </Card>

  <Card title="get_recommended_stage()" icon="function" href="../functions/Agent-get_recommended_stage">
    Get recommended execution stage for prompt.
  </Card>

  <Card title="run_autonomous()" icon="function" href="../functions/Agent-run_autonomous">
    Run an autonomous task execution loop.
  </Card>

  <Card title="run_autonomous_async()" icon="function" href="../functions/Agent-run_autonomous_async">
    Async variant of run\_autonomous() for concurrent agent execution.
  </Card>

  <Card title="handoff_to()" icon="function" href="../functions/Agent-handoff_to">
    Programmatically hand off a task to another agent.
  </Card>

  <Card title="run_until()" icon="function" href="../functions/Agent-run_until">
    Run agent iteratively until output meets quality criteria.
  </Card>

  <Card title="run_until_async()" icon="function" href="../functions/Agent-run_until_async">
    Async version of run\_until().
  </Card>

  <Card title="handoff_to_async()" icon="function" href="../functions/Agent-handoff_to_async">
    Asynchronously hand off a task to another agent.
  </Card>

  <Card title="get_available_tools()" icon="function" href="../functions/Agent-get_available_tools">
    Get tools available to this agent, filtered by plan\_mode if enabled.
  </Card>

  <Card title="rules_manager()" icon="function" href="../functions/Agent-rules_manager">
    Lazy-initialized RulesManager for persistent rules/instructions.
  </Card>

  <Card title="get_rules_context()" icon="function" href="../functions/Agent-get_rules_context">
    Get rules context for the current conversation.
  </Card>

  <Card title="get_memory_context()" icon="function" href="../functions/Agent-get_memory_context">
    Get memory context for the current conversation.
  </Card>

  <Card title="get_learn_context()" icon="function" href="../functions/Agent-get_learn_context">
    Get learning context for injection into system prompt.
  </Card>

  <Card title="store_memory()" icon="function" href="../functions/Agent-store_memory">
    Store content in memory.
  </Card>

  <Card title="llm_model()" icon="function" href="../functions/Agent-llm_model">
    Unified property to get the LLM model regardless of configuration type.
  </Card>

  <Card title="retrieval_config()" icon="function" href="../functions/Agent-retrieval_config">
    Get the unified retrieval configuration.
  </Card>

  <Card title="rag()" icon="function" href="../functions/Agent-rag">
    Lazy-loaded RAG instance for advanced retrieval with citations.
  </Card>

  <Card title="retrieve()" icon="function" href="../functions/Agent-retrieve">
    Retrieve context from knowledge without LLM generation.
  </Card>

  <Card title="query()" icon="function" href="../functions/Agent-query">
    Query knowledge and get a structured answer with citations.
  </Card>

  <Card title="rag_query()" icon="function" href="../functions/Agent-rag_query">
    Query knowledge using RAG pipeline with citations.
  </Card>

  <Card title="chat_with_context()" icon="function" href="../functions/Agent-chat_with_context">
    Chat with pre-retrieved context.
  </Card>

  <Card title="generate_task()" icon="function" href="../functions/Agent-generate_task">
    Generate a Task object from the agent's instructions
  </Card>

  <Card title="execute_tool()" icon="function" href="../functions/Agent-execute_tool">
    Execute a tool dynamically based on the function name and arguments.
  </Card>

  <Card title="clear_history()" icon="function" href="../functions/Agent-clear_history">
    Instance method.
  </Card>

  <Card title="prune_history()" icon="function" href="../functions/Agent-prune_history">
    Prune chat history to keep only the last N messages.
  </Card>

  <Card title="delete_history()" icon="function" href="../functions/Agent-delete_history">
    Delete a specific message from chat history by index.
  </Card>

  <Card title="delete_history_matching()" icon="function" href="../functions/Agent-delete_history_matching">
    Delete all messages matching a pattern.
  </Card>

  <Card title="get_history_size()" icon="function" href="../functions/Agent-get_history_size">
    Get the current number of messages in chat history.
  </Card>

  <Card title="ephemeral()" icon="function" href="../functions/Agent-ephemeral">
    Context manager for ephemeral conversations.
  </Card>

  <Card title="session_id()" icon="function" href="../functions/Agent-session_id">
    Get the current session ID.
  </Card>

  <Card title="chat()" icon="function" href="../functions/Agent-chat">
    Chat with the agent.
  </Card>

  <Card title="clean_json_output()" icon="function" href="../functions/Agent-clean_json_output">
    Clean and extract JSON from response text.
  </Card>

  <Card title="achat()" icon="function" href="../functions/Agent-achat">
    Async version of chat method with self-reflection support.
  </Card>

  <Card title="arun()" icon="function" href="../functions/Agent-arun">
    Async version of run() - silent, non-streaming, returns structured result.
  </Card>

  <Card title="astart()" icon="function" href="../functions/Agent-astart">
    Async version of start() - interactive, streaming-aware.
  </Card>

  <Card title="run()" icon="function" href="../functions/Agent-run">
    Execute agent silently and return structured result.
  </Card>

  <Card title="switch_model()" icon="function" href="../functions/Agent-switch_model">
    Switch the agent's LLM model while preserving conversation history.
  </Card>

  <Card title="start()" icon="function" href="../functions/Agent-start">
    Start the agent interactively with verbose output.
  </Card>

  <Card title="iter_stream()" icon="function" href="../functions/Agent-iter_stream">
    Stream agent response as an iterator of chunks.
  </Card>

  <Card title="execute()" icon="function" href="../functions/Agent-execute">
    Execute a task synchronously - backward compatibility method
  </Card>

  <Card title="aexecute()" icon="function" href="../functions/Agent-aexecute">
    Execute a task asynchronously - backward compatibility method
  </Card>

  <Card title="execute_tool_async()" icon="function" href="../functions/Agent-execute_tool_async">
    Async version of execute\_tool
  </Card>

  <Card title="launch()" icon="function" href="../functions/Agent-launch">
    Launch the agent as an HTTP API endpoint or an MCP server.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/agent.py#L155">
  `praisonaiagents/agent/agent.py` at line 155
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Agents Concept" icon="robot" href="/docs/concepts/agents" />

  <Card title="Single Agent Guide" icon="book-open" href="/docs/guides/single-agent" />

  <Card title="Multi-Agent Guide" icon="users" href="/docs/guides/multi-agent" />

  <Card title="Agent Configuration" icon="gear" href="/docs/configuration/agent-config" />

  <Card title="Auto Agents" icon="wand-magic-sparkles" href="/docs/features/autoagents" />
</CardGroup>
