Skip to main content

A minimal, hackable agentic framework: LLM calls via litellm, @tool-decorated functions, and MCP server support.

Project description

agentropic

A small, hackable agentic framework in ~500 lines you fully own and can read top to bottom in an afternoon:

  • LLM calls go through litellm, so you get every provider (OpenAI, Anthropic, Gemini, Ollama, Bedrock, 100+ more) for free.
  • @tool decorator turns any python function into an LLM-callable tool with an auto-generated JSON schema (from type hints + docstring).
  • MCP support — connect to any Model Context Protocol server (stdio or SSE) and its tools show up in your agent automatically, indistinguishable from local tools.
  • Agent loop handles the call → tool-call → tool-result → call cycle for you, with memory, streaming, and a max-iteration safety valve.

Install (once published)

pip install agentropic

Quick start

import asyncio
from agentropic import Agent, tool

@tool()
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"It's sunny in {city}."

async def main():
    agent = Agent(
        name="assistant",
        model="gpt-4o-mini",         # any litellm model string
        instructions="You are helpful and concise.",
        tools=[get_weather],
    )
    print(await agent.arun("What's the weather in Paris?"))

asyncio.run(main())

Sync usage: agent.run("...") (wraps arun in asyncio.run for you).

Using MCP servers

from agentropic import Agent
from agentropic.mcp import StdioServer

agent = Agent(
    name="fs-agent",
    model="gpt-4o-mini",
    mcp_servers=[
        StdioServer(command="npx", args=["-y", "@modelcontextprotocol/server-filesystem", "."]),
    ],
)
print(await agent.arun("List the files in the current directory."))

Requires the optional MCP dependency: pip install "agentropic[mcp]".

Architecture

src/agentropic/
├── __init__.py     # public API surface
├── agent.py         # the run loop: LLM <-> tools <-> memory
├── llm.py            # thin litellm wrapper (swap providers here)
├── tools.py           # @tool decorator, Tool, ToolRegistry, schema generation
├── memory.py           # in-memory conversation history (swap for your own store)
└── mcp/
    └── client.py        # MCP stdio/SSE client -> Tool adapter

Everything is a plain, editable python file — no hidden magic, no plugin registry you can't inspect. Read agent.py first; that's the whole loop.

Extending it

  • Custom memory / persistence: implement .add(), .get(), .clear() matching Memory and pass memory=YourMemory() to Agent.
  • Streaming with tool calls: astream() currently falls back to a non-streamed arun() when tools are registered — extend it if you need token-level streaming mid-tool-loop.
  • Multi-agent handoff: compose multiple Agent instances and route between them yourself, or wrap one agent's arun as a tool for another.

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

agentropic-0.2.1.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

agentropic-0.2.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file agentropic-0.2.1.tar.gz.

File metadata

  • Download URL: agentropic-0.2.1.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for agentropic-0.2.1.tar.gz
Algorithm Hash digest
SHA256 383b40f6c93e3ed20af6ad17d23a09455ea11edda3270c4618605e770f844e90
MD5 6a655bd21535c938550240fb6a9bca37
BLAKE2b-256 734d402af288a08320a7e2216756ded78f5352b2bc6003c073dd982c985568d1

See more details on using hashes here.

File details

Details for the file agentropic-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: agentropic-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for agentropic-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e3c9ee80611ecb12cd87e0cf3a8e43c37c58fc26be9e5067eb7ba52e11cdf82
MD5 b38714b92e5ea3f7d64ae0392ef5542f
BLAKE2b-256 5e09f46e8a978ce1dbb7f329f0063caa4de84b217a3c21e42fac2225c48566d5

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