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.2

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.2
File Size Uploaded
agentlys-1.17.2.tar.gz 102.5 kB Details

Built distribution (wheel)

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

Total release size: 161.1 kB

Release files / agentlys-1.17.2.tar.gz

Download URL agentlys-1.17.2.tar.gz
Size 102.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1f70f18d7e79e3994a2a55cd9f965d9781fe30c88f2cc45f08a0bd9adc430e77
BLAKE2b-256 checksum
How to use checksums
9dc2370b420520781bd0bdeadb8c64969efe329262f09a3e9cb993795eaf0bb0
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.2-py3-none-any.whl

Download URL agentlys-1.17.2-py3-none-any.whl
Size 58.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59bc51b8a8c04f515dc304bc0958ab9ec53b29846ad15b590f107eb8028f88fd
BLAKE2b-256 checksum
How to use checksums
b26ccc0bf35db25bc30bcbb68520ab11112a417b797ca80d3cc31e2498c0378b
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

This release

1.17.2 This release

2 release files

1.17.1

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