Skip to content

🤖 Creating Agents

Agents are the core logic units of Antilogix. They combine an LLM "Brain" with specific system instructions, tools, and context management.

The Base Agent

All agents must inherit from BaseAgent. This provides them with standard methods like think(), tool execution capabilities, and automatic memory injection.

File: app/agents/support.py

from sentinel_core.agents.base import BaseAgent

class CustomerSupportAgent(BaseAgent):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def _set_system_prompt(self, context_notes=None):
        # 1. Define the persona
        self.system_prompt = """
        You are a helpful and polite Customer Support Agent for Antilogix.
        Answer queries concisely. If you don't know the answer, use a tool.
        """

        # 2. Inject Memory (Context) if available
        # 'context_notes' contains relevant facts retrieved from Mem0
        if context_notes:
            self.system_prompt += f"\n\nUser Context:\n{context_notes}"

        # 3. Initialize History
        self.history = [{"role": "system", "content": self.system_prompt}]

Using Agents

You can use an agent inside an API route or a workflow.

# app/http/routes.py
from fastapi import APIRouter
from app.agents.support import CustomerSupportAgent

router = APIRouter()

@router.post("/ask")
async def ask_agent(query: str):
    # Initialize the agent
    agent = CustomerSupportAgent(name="SupportBot")

    # Run the "think" loop
    response = await agent.think(query)

    return {"response": response}

Tools (Function Calling)

Give your agent "hands" to perform actions by registering standard Python functions.

# 1. Define a tool function
def check_order_status(order_id: str):
    """
    Fetches the status of an order from the database.
    """
    # ... logic to check DB ...
    return f"Order {order_id} is currently OUT FOR DELIVERY."

# 2. Register the tool with the agent
agent = CustomerSupportAgent(name="SupportBot")
agent.register_tool(check_order_status)

# 3. The LLM decides when to call it
# User: "Where is order #999?" -> Agent calls check_order_status("999")