Skip to main content

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

Project description

minimal-harness

Documentation: /docs

A lightweight Python agent harness for building LLM-powered agents with tool-calling support.

Latest version: 0.2.1

What This Project Is For

Minimal-harness is a lean framework for building agents that can call tools. It provides:

  • Pluggable LLM providers - OpenAI, LiteLLM (optional), or implement your own
  • Tool system - Create tools via decorators or directly; includes built-in tools (bash, file ops, grep, glob, ask_user)
  • Interactive tools - Tools that pause execution to request user input mid-process
  • Conversation memory - Tracks token usage across interactions
  • Streaming callbacks - Real-time callbacks for chunks, tool start/end, execution start

How to Build an App

Project Structure

A typical app looks like this:

my-app/
├── cli.py          # Entry point with argparse
└── tools.py        # Your custom tools

1. Create Your Entry Point

import argparse
from minimal_harness.mhc import SimpleCli
from minimal_harness.tool.built_in import bash, read_file, ask_user
from minimal_harness.tool.registry import ToolRegistry

def main():
    parser = argparse.ArgumentParser(description="My AI agent")
    parser.add_argument("--base-url", required=True)
    parser.add_argument("--api-key", required=True)
    parser.add_argument("--model", default="qwen3.5-27b")
    args = parser.parse_args()

    # Register built-in tools
    registry = ToolRegistry.get_instance()
    registry.register(bash.bash_tool, bash.bash_handler)
    registry.register(read_file.read_file_tool, read_file.read_file_handler)
    registry.register(ask_user.ask_user_tool, ask_user.ask_user_first)

    # Run the CLI
    cli = SimpleCli(
        api_key=args.api_key,
        base_url=args.base_url,
        model=args.model,
    )
    cli.run()

if __name__ == "__main__":
    main()

2. Add Custom Tools

Use the @register_tool decorator to add your own tools:

from minimal_harness.tool.registration import register_tool

@register_tool(
    name="get_weather",
    description="Get weather for a location",
    parameters={
        "type": "object",
        "properties": {"location": {"type": "string"}},
        "required": ["location"],
    },
)
async def get_weather(location: str) -> str:
    return f"The weather in {location} is sunny."

The decorator auto-registers the tool. Just import it before cli.run().

3. Run

python cli.py --base-url https://api.openai.com/v1 --api-key sk-... --model gpt-4o

Or set environment variables:

export MH_BASE_URL=https://api.openai.com/v1
export MH_API_KEY=sk-...
export MH_MODEL=gpt-4o
python cli.py

Built-in Tools

Tool Description
bash Execute shell commands
read_file Read file contents
create_file Create new files
patch_file Patch existing files
delete_file Delete files
ask_user Request user input

Environment Variables

Variable Description
MH_BASE_URL API base URL
MH_API_KEY API key
MH_MODEL Model name (default: qwen3.5-27b)

Running the Built-in CLI

mhc --base-url https://api.openai.com/v1 --api-key sk-... --model gpt-4o

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.2.2.tar.gz (16.4 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.2.2-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: minimal_harness-0.2.2.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":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.2.2.tar.gz
Algorithm Hash digest
SHA256 ea1550ee33109b339935c8eca348c7c54c48b0f9fc33cbd19e742427f0238593
MD5 b1f67c02fcef6b181bec089e3faff095
BLAKE2b-256 b3fbac4adbfa1799b69311651b8b2a2b4b7fd2c11576129a2228cfebdc3ae024

See more details on using hashes here.

File details

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

File metadata

  • Download URL: minimal_harness-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":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.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc4d33ff8f654f6f6f6eaab7ba3a62ff31a8fec429383a9a6bbe73b7c35ff7ee
MD5 a474da3778339dcc46b790698d00080a
BLAKE2b-256 094180011441002eec371e3b65ba7afa8aa42a5a4997ab0f0eb2eb9a315d76b7

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