Add your description here
Project description
minimal-harness
A lightweight Python agent harness with tool-calling support.
Features
- Simple
Agentclass for building LLM-powered agents - Tool-calling support with concurrent execution
- Streaming response support via chunk callbacks
- Conversation history management with
Memoryinterface - Built on OpenAI's API (supports any OpenAI-compatible endpoint)
- Extensible LLM provider interface
Installation
pip install -e .
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")
llm_provider = OpenAILLMProvider(client=client, model="minimax-m2.7")
agent = Agent(llm_provider=llm_provider, tools=tools)
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)
result = await agent.run("What's the weather in Beijing?", on_chunk=on_chunk)
print(result)
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. The library includes OpenAILLMProvider for OpenAI-compatible endpoints.
OpenAILLMProvider
OpenAILLMProvider(client: AsyncOpenAI, model: str = "qwen3.5-27b")
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minimal_harness-0.1.0.tar.gz.
File metadata
- Download URL: minimal_harness-0.1.0.tar.gz
- Upload date:
- Size: 6.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb2eb37a13d14a6f02e93fcb856208c68b75830dab0ec4554b15421a0131e4e4
|
|
| MD5 |
d2f0c142625ae36f078067421171818b
|
|
| BLAKE2b-256 |
e5eb3d323abc5a752439cf6e64afaaec1ce6e1b59495bbf5bfaca7934ce916ba
|
File details
Details for the file minimal_harness-0.1.0-py3-none-any.whl.
File metadata
- Download URL: minimal_harness-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5415e73f64ec6bc9ba8458d9b43114bdbeb9ece2d7671b7c53aae065c9371d89
|
|
| MD5 |
752b1f4ccedc02cc571122bec2627a34
|
|
| BLAKE2b-256 |
019cbc3b3e1b20ab23660a584f263ff900c27ce9f147adc3c520fbb270009005
|