Skip to main content

LLM Agent Framework with tool execution capabilities

Project description

Acton Agent

Acton Agent

A lightweight, flexible Python framework for building LLM agents with tool execution capabilities

⚠️ Experimental Project: This is a personal project currently in an experimental phase. The API may change without notice, and features may be incomplete or unstable. Use at your own discretion.

PyPI version Python 3.10+ License: MIT

Acton Agent enables you to build AI agents that can interact with external APIs, execute custom Python functions, and maintain conversation context. With minimal configuration, you can create agents that reason through complex tasks, call tools, and stream responses in real-time.

Quick Start

pip install acton-agent[openai]
from acton_agent import Agent
from acton_agent.client import OpenAIClient
from acton_agent.agent import FunctionTool

# Create a simple calculator tool
def calculate(a: float, b: float, operation: str) -> float:
    ops = {"add": a + b, "subtract": a - b, "multiply": a * b, "divide": a / b}
    return ops.get(operation, 0)

# Initialize agent with OpenAI
client = OpenAIClient(api_key="your-key", model="gpt-4o")
agent = Agent(llm_client=client)

# Register the tool
agent.register_tool(FunctionTool(
    name="calculator",
    description="Perform basic arithmetic operations",
    func=calculate,
    schema={
        "type": "object",
        "properties": {
            "a": {"type": "number"},
            "b": {"type": "number"},
            "operation": {"type": "string", "enum": ["add", "subtract", "multiply", "divide"]}
        },
        "required": ["a", "b", "operation"]
    }
))

# Run the agent
result = agent.run("What is 25 multiplied by 4?")
print(result)  # "The result of 25 multiplied by 4 is 100."

Key Features

🔧 Flexible Tool System

Create tools from Python functions, HTTP APIs, or custom classes. Organize related tools with ToolSets and shared configuration.

from acton_agent import ToolSet, FunctionTool

# Define tools that use an API key
def get_weather(city: str, api_key: str) -> str:
    # api_key will be automatically injected from toolset_params
    return f"Weather in {city}: Sunny, 72°F"

def get_forecast(city: str, days: int, api_key: str) -> str:
    return f"{days}-day forecast for {city}"

# Group related tools with shared parameters
weather_tools = ToolSet(
    name="weather",
    description="Weather data tools",
    tools=[
        FunctionTool(
            name="current_weather",
            description="Get current weather for a city",
            func=get_weather,
            schema={
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"]
            }
        ),
        FunctionTool(
            name="forecast",
            description="Get weather forecast",
            func=get_forecast,
            schema={
                "type": "object",
                "properties": {
                    "city": {"type": "string"},
                    "days": {"type": "integer"}
                },
                "required": ["city", "days"]
            }
        )
    ],
    toolset_params={"api_key": "secret-api-key"}  # Hidden from LLM, auto-injected
)
agent.register_toolset(weather_tools)

🔄 Automatic Retry & Error Handling

Built-in retry logic with exponential backoff for both LLM calls and tool execution.

from acton_agent.agent import RetryConfig

agent = Agent(llm_client=client, retry_config=RetryConfig(max_attempts=5))

💬 Conversation Memory Management

Automatic token-based history truncation to stay within context limits.

from acton_agent import SimpleAgentMemory

agent = Agent(llm_client=client, memory=SimpleAgentMemory(max_history_tokens=8000))

🌊 Streaming Support

Stream agent responses token-by-token for real-time feedback.

from acton_agent.agent import AgentToken

for event in agent.run_stream("Tell me a story"):
    if isinstance(event, AgentToken):
        print(event.content, end="", flush=True)

🔌 Multi-Provider Support

Works with OpenAI, OpenRouter, and any OpenAI-compatible API.

from acton_agent import OpenRouterClient

client = OpenRouterClient(api_key="your-key", model="anthropic/claude-3-opus")

Documentation

Examples

Explore complete examples in the examples/ directory:

License

MIT License - see LICENSE file for details.


Disclaimer: This is an experimental project. Use at your own risk. No guarantees about stability, security, or fitness for any particular purpose.

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

acton_agent-0.0.11.tar.gz (63.3 kB view details)

Uploaded Source

Built Distribution

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

acton_agent-0.0.11-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

Details for the file acton_agent-0.0.11.tar.gz.

File metadata

  • Download URL: acton_agent-0.0.11.tar.gz
  • Upload date:
  • Size: 63.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for acton_agent-0.0.11.tar.gz
Algorithm Hash digest
SHA256 d21046dadf2e9ca75f0ab49b8c607a83097b628b7c4a93db20be22cc66e66cb8
MD5 68820b35387967a55fd99f3622a70e89
BLAKE2b-256 9ed1fce4b2d2f91ec1cf2f6f59603b9ca79f09a311f9d7ed49ca6c807c39fd0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for acton_agent-0.0.11.tar.gz:

Publisher: python-publish.yml on akstspace/acton-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file acton_agent-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: acton_agent-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 41.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for acton_agent-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 8427a676557ecd69d60925f69104e15e36f0cf88afda4fa2a9d67a9117bfd11f
MD5 b6c8eb6ae104832c20c518210a598c47
BLAKE2b-256 5d33fc5b967408e5f829c6f848243e8b3b57279706e3e1198f97e86c9e14bd1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for acton_agent-0.0.11-py3-none-any.whl:

Publisher: python-publish.yml on akstspace/acton-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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