Skip to main content

An exploration of making an agent sdk as lean as possible while being effective.

Project description

minimal-harness

A lightweight Python agent harness for building LLM-powered agents with tool-calling support. An exploration of making an agent SDK as lean as possible while being effective.

Features

  • Simple Agent class for building LLM-powered agents
  • Tool-calling support with concurrent execution
  • Streaming response support via chunk callbacks
  • Conversation history management with Memory interface
  • Built-in tools: glob (file pattern matching) and grep (content search)
  • Multiple LLM backends: OpenAI-compatible and LiteLLM
  • Extensible LLM provider interface

Installation

pip install -e .                    # Basic install
pip install -e ".[test]"            # With test dependencies
pip install -e ".[demo]"            # With demo dependencies
pip install -e ".[dev]"             # All dev dependencies

Quick Start

import asyncio
from minimal_harness import Agent, Tool, OpenAILLMProvider
from openai import AsyncOpenAI

async def get_weather(city: str) -> dict:
    return {"city": city, "temperature": "22°C", "condition": "Sunny"}

tools = [
    Tool(
        name="get_weather",
        description="Get weather for a specified city",
        parameters={
            "type": "object",
            "properties": {"city": {"type": "string", "description": "City name"}},
            "required": ["city"],
        },
        fn=get_weather,
    ),
]

client = AsyncOpenAI(api_key="your-api-key", base_url="https://aihubmix.com/v1")

async def on_chunk(chunk, is_done):
    if is_done:
        print()
        return
    delta = chunk.choices[0].delta if chunk.choices else None
    if delta and delta.content:
        print(delta.content, end="", flush=True)

llm_provider = OpenAILLMProvider(client=client, model="minimax-m2.7", on_chunk=on_chunk)
agent = Agent(llm_provider=llm_provider, tools=tools)

result = await agent.run("What's the weather in Beijing?")
print(result)

Demo

Run an interactive TUI demo:

python demo/cli.py

Agent

The Agent class manages conversation context and tool execution.

Constructor

Agent(
    llm_provider: LLMProvider,
    tools: list[Tool] | None = None,
    max_iterations: int = 10,
    memory: Memory | None = None,
    tool_executor: ToolExecutor | None = None,
)

Methods

  • run(user_input: str, on_chunk: ChunkCallback | None = None) -> str - Run the agent with user input

LLMProvider

The LLMProvider is a protocol that defines the interface for LLM backends.

OpenAILLMProvider

OpenAILLMProvider(client: AsyncOpenAI, model: str = "qwen3.5-27b")

LiteLLMProvider

LiteLLMProvider(model: str = "qwen3.5-27b", **kwargs)

Memory

Memory classes manage conversation history.

ConversationMemory

ConversationMemory(system_prompt: str = "You are a helpful assistant.")

Tool

Define tools that the agent can call.

Tool(
    name: str,
    description: str,
    parameters: dict,  # OpenAI function parameters schema
    fn: Callable[..., Awaitable[Any]],  # Async function implementation
)

ToolExecutor

Executes tool calls concurrently and returns results as messages.

Built-in Tools

glob

File pattern matching tool.

from minimal_harness.tool import glob

tool = glob()

grep

Content search tool.

from minimal_harness.tool import grep

tool = grep()

Testing

pip install -e ".[test]"
pytest

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minimal_harness-0.1.4.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

minimal_harness-0.1.4-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file minimal_harness-0.1.4.tar.gz.

File metadata

  • Download URL: minimal_harness-0.1.4.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for minimal_harness-0.1.4.tar.gz
Algorithm Hash digest
SHA256 97037af7056cc44c06f44213bede1a45aa34ae34f65e628a7886de364eaa7ec8
MD5 916b11902fe63651b2795f74bccb6586
BLAKE2b-256 863203c988d013bce9c5ee951c87ee47fd96e3ae28e794456672e01fe08d440a

See more details on using hashes here.

File details

Details for the file minimal_harness-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: minimal_harness-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for minimal_harness-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1b4a98d135cf10bb133a37face3c3ca80f7f1026aec2662dd0d6bd43826910b1
MD5 81baf3257313c69ae6b417254ab8967f
BLAKE2b-256 42cdbdd43f5b8af9f37850f624db2bc13de5870427a52cccaaaa2b383277b6a0

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