Skip to main content

Lightweight AI agent library. Turn Python functions/classes into AI tools instantly.

Project description

Agentlys

image image Actions status

Turn any Python class into an AI tool. Instantly.

Async-native • MCP support • Multi-providers • ~500 lines of core code

class Database:
    def __llm__(self):
        return f"Tables: {self.list_tables()}"  # AI sees this every turn

    def query(self, sql: str) -> list[dict]:
        """Execute SQL query"""
        return self.execute(sql)

    def describe(self, table: str) -> dict:
        """Get table schema"""
        return self.get_schema(table)

agent = Agentlys()
agent.add_tool(Database(conn))  # That's it. All methods are now AI tools.
agent.run("What drove revenue decline in Q3?")

Other frameworks: 50 lines of tool definitions, separate schemas, manual state management.
Agentlys: Your class IS the tool. Methods become actions. __llm__() injects state.


Why Agentlys?

If you want... Use
Graphs and state machines LangGraph
Team-based agent crews CrewAI
Your existing classes as AI tools Agentlys

~500 lines of core code. No framework lock-in. No magic.


Install

pip install 'agentlys[all]'  # OpenAI + Anthropic + MCP

The Pattern

1. Functions → Tools

def get_weather(city: str) -> str:
    """Get current weather for a city"""
    return requests.get(f"https://wttr.in/{city}?format=3").text

agent.add_function(get_weather)

2. Classes → Stateful Tools (the killer feature)

class FileSystem:
    def __init__(self, root: str):
        self.root = root

    def __llm__(self):
        """State shown to AI each turn"""
        return f"Current directory: {self.root}\nFiles: {os.listdir(self.root)}"

    def read(self, path: str) -> str:
        """Read file contents"""
        return open(f"{self.root}/{path}").read()

    def write(self, path: str, content: str):
        """Write to file"""
        open(f"{self.root}/{path}", 'w').write(content)

agent.add_tool(FileSystem("/workspace"))
# AI now sees file state, can read/write, all from one class

3. Run Conversations

for message in agent.run_conversation("Refactor config.json to use environment variables"):
    print(message.content)

Async Support

# Async conversation loop
async for message in agent.run_conversation_async("Analyze the data"):
    print(message.content)

# Single async call
response = await agent.ask_async("What tables exist?")

Real Example: agentlys-dev

A coding agent in 15 lines:

from agentlys import Agentlys
from agentlys_tools import CodeEditor, Terminal, Git

agent = Agentlys(
    instruction="You are a senior developer",
    provider="anthropic",
    model="claude-sonnet-4-20250514"
)

agent.add_tool(CodeEditor())
agent.add_tool(Terminal())
agent.add_tool(Git())

agent.run_conversation("Create a FastAPI app with tests")

Providers

# Anthropic (default)
agent = Agentlys(provider="anthropic", model="claude-sonnet-4-20250514")

# OpenAI
agent = Agentlys(model="gpt-4o")

More


Used By

  • Myriade — AI-native data platform

When NOT to use Agentlys

  • You need graph-based workflows → Use LangGraph
  • You want pre-built agent teams → Use CrewAI
  • You need sandboxed code execution → Use Smolagents

Agentlys is for: turning your existing Python code into AI tools with zero ceremony.

License

MIT

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

agentlys-1.9.0.tar.gz (57.4 kB view details)

Uploaded Source

Built Distribution

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

agentlys-1.9.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file agentlys-1.9.0.tar.gz.

File metadata

  • Download URL: agentlys-1.9.0.tar.gz
  • Upload date:
  • Size: 57.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for agentlys-1.9.0.tar.gz
Algorithm Hash digest
SHA256 89dac31af554d03b4357db9edbb7d69b00ea212bbbc50ee7d6a51d3cc13f0dd0
MD5 92c22ad88827dcbf0f1875c29437bc0b
BLAKE2b-256 ff43b9f4feaba600a969a1f4090f857f7b756fa934e4d37913aa3273a9a17f9c

See more details on using hashes here.

File details

Details for the file agentlys-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: agentlys-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for agentlys-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90f76665a85b090640b30b9e9b819ac891d011673886cab5d5992e7ac6e6e144
MD5 e8a00e3355c916a8147efa20c8252ca6
BLAKE2b-256 e2e10fecf26c55d643d758b444490f27f3c92b112cf6fb5e876c903c53f93daf

See more details on using hashes here.

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