Skip to content

Extending AgenticAIΒΆ

Extend and customize the framework

Add new capabilities, integrate external systems across 400+ modules

Enterprise Extensibility

Part of 237 enterprise modules with advanced extensibility patterns. See Enterprise Documentation.


Understanding the ArchitectureΒΆ

AgenticAI is organized into modular components:

Module Purpose
core/ Agent classes and orchestration logic
memory/ Short-term and long-term memory management
llms/ LLM provider integrations
tools/ Tool registry and implementations
guardrails/ Safety and compliance checks
knowledge/ Knowledge base and retrieval
orchestration/ Workflow coordination
tracing/ Distributed tracing
evaluation/ Evaluation framework

Adding a New AgentΒΆ

  1. Create a new class inheriting from Agent
  2. Implement required methods
  3. Register the agent
Python
from agenticaiframework import Agent, AgentManager

class CustomAgent(Agent):
    """Custom agent with specialized behavior."""

    def __init__(self, name: str, **kwargs):
        super().__init__(name=name, role="custom", capabilities=["text"])

    def act(self, input_data: str) -> str:
        return f"Processed: {input_data}"

# Register and use
manager = AgentManager()
agent = CustomAgent(name="MyCustomAgent")
manager.register_agent(agent)

Adding a New ToolΒΆ

  1. Create a class inheriting from BaseTool
  2. Implement the _run method
  3. Register with the decorator
Python
from agenticaiframework.tools import BaseTool, register_tool

@register_tool()
class SentimentTool(BaseTool):
    """Analyze sentiment of text."""

    name = "sentiment_analysis"
    description = "Analyzes the sentiment of input text"

    def _run(self, input_data: dict) -> dict:
        text = input_data.get("text", "")
        # Your sentiment analysis logic here
        return {"sentiment": "positive", "confidence": 0.95}

Extending MemoryΒΆ

Add a custom memory backend:

Python
from agenticaiframework.memory import MemoryManager

class RedisMemoryBackend:
    """Redis-based memory backend."""

    def __init__(self, redis_client):
        self.client = redis_client

    def store(self, key: str, value: any) -> None:
        self.client.set(key, value)

    def retrieve(self, key: str) -> any:
        return self.client.get(key)

    def clear(self, key: str) -> None:
        self.client.delete(key)

Extending LLM IntegrationsΒΆ

Add a new LLM provider:

Python
from agenticaiframework.llms import LLMManager

def custom_llm_provider(prompt: str, **kwargs) -> str:
    """Custom LLM provider integration."""
    # Your LLM API call here
    return f"Response to: {prompt}"

# Register the provider
llm = LLMManager()
llm.register_model("custom-llm", custom_llm_provider)
llm.set_active_model("custom-llm")

Adding GuardrailsΒΆ

Implement custom safety checks:

Python
from agenticaiframework.guardrails import GuardrailManager

def content_filter(input_data: str) -> str:
    """Filter inappropriate content."""
    banned_words = ["spam", "scam"]
    for word in banned_words:
        if word in input_data.lower():
            raise ValueError(f"Content contains banned word: {word}")
    return input_data

# Register guardrail
guardrails = GuardrailManager()
guardrails.add_guardrail("content_filter", content_filter)

Custom Communication ProtocolsΒΆ

Extend communication capabilities:

Python
class WebSocketCommunication:
    """WebSocket-based communication."""

    def __init__(self, url: str):
        self.url = url
        self.connection = None

    async def connect(self):
        import websockets
        self.connection = await websockets.connect(self.url)

    async def send(self, message: str):
        await self.connection.send(message)

    async def receive(self) -> str:
        return await self.connection.recv()

Testing ExtensionsΒΆ

Write comprehensive tests for new features:

Python
import pytest
from agenticaiframework import Agent

class TestCustomAgent:
    def test_agent_creation(self):
        agent = CustomAgent(name="TestAgent")
        assert agent.name == "TestAgent"

    def test_agent_act(self):
        agent = CustomAgent(name="TestAgent")
        result = agent.act("Hello")
        assert "Processed" in result

# Run tests
# pytest tests/test_custom_agent.py -v

Packaging ExtensionsΒΆ

Structure your extension as a package:

Text Only
1
2
3
4
5
6
7
8
my_extension/
β”œβ”€β”€ __init__.py
β”œβ”€β”€ agents/
β”‚ └── custom_agent.py
β”œβ”€β”€ tools/
β”‚ └── custom_tool.py
└── tests/
    └── test_extension.py

Best PracticesΒΆ

Extension Best Practices

  • Keep extensions modular and focused
  • Write unit tests for all new features
  • Follow PEP8 coding standards
  • Document your changes
  • Use type hints for better IDE support
  • Handle errors gracefully