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.0.tar.gz (11.4 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.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agentropic-0.2.0.tar.gz
  • Upload date:
  • Size: 11.4 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.0.tar.gz
Algorithm Hash digest
SHA256 ddea44a3022cb56035effa4a2751a521783cd8eac15e0819036e83067291931f
MD5 00d742334677ae99853d1ec789a89bfa
BLAKE2b-256 7648fe46b797f126d881bd7c24796262086d9f52eb9d3999042fc25fa6706c93

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agentropic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fb9763c11cb579912c0c8c7d959d8bd4e3bccca5bfb84a569ee5b7d50914340d
MD5 f98d585809e26a296d4b7589b22f28e9
BLAKE2b-256 510e57d53a63f22d3a4d9a6a5f3bde6e0824177886bf989050eff9fa9e059978

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