Skip to main content

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")

# Any OpenAI-compatible API (Ollama, vLLM, LiteLLM, OpenRouter, ...)
agent = Agentlys(model="llama3.1", base_url="http://localhost:11434/v1")

See the Provider Guide for details.


4. Tool Search (defer loading)

When you have many tools, defer most of them and let the LLM discover what it needs:

agent.add_tool(Database(conn), "db")
agent.add_tool(Charts(), "charts")
agent.add_tool(Documents(), "docs")
agent.add_function(answer)

agent.enable_tool_search(always_loaded=["answer", "Database-db__query"])
# Charts and Documents tools are hidden until the LLM searches for them

Reduces context usage by 50-85% with large tool sets. See API Reference.


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

Metadata

Release files for agentlys 1.17.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentlys 1.17.1
File Size Uploaded
agentlys-1.17.1.tar.gz 101.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentlys 1.17.1
File Interpreter ABI Platform
agentlys-1.17.1-py3-none-any.whl Python 3 none any Details

Total release size: 159.3 kB

Release files / agentlys-1.17.1.tar.gz

Download URL agentlys-1.17.1.tar.gz
Size 101.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6faeb4c484dd66041cf3400e8b2a21e6e2591bc9e05501d2cd5f5c975de33135
BLAKE2b-256 checksum
How to use checksums
754d909fab5f6ab94eb9548d6d978a288c837dd11b525eb5dc22170ff8d4f116
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.16

Release files / agentlys-1.17.1-py3-none-any.whl

Download URL agentlys-1.17.1-py3-none-any.whl
Size 58.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4edd06cc8dde162ebc0c04eb145335dee506d38107d40915b55566112f15142d
BLAKE2b-256 checksum
How to use checksums
84310455e53916a477a8c1b5aaf9920eed8ee5afa61e040dc2bc2925bb31eed3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.16

Release history Release notifications | RSS feed

1.21.0

2 release files

1.20.1

2 release files

1.20.0

2 release files

1.19.5

2 release files

1.19.4

2 release files

1.19.3

2 release files

1.17.2

2 release files

This release

1.17.1 This release

2 release files

1.17.0

2 release files

1.16.3

2 release files

1.16.1

2 release files

1.16.0

2 release files

1.14.0

2 release files

1.13.0

2 release files

1.12.2

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.10.0

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.20.0

2 release files

0.19.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page