Metadata-Version: 2.4
Name: minimal-agent-harness
Version: 0.1.0
Summary: Run one model-guided task with a local shell tool.
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai<3,>=2
Dynamic: license-file

# minimal-agent-harness

This project keeps an agent harness small so you can learn its core components by reading and running it. A harness is the code that connects a model to tools and manages the loop between them.

## How it works

1. The harness sends your prompt and a shell tool definition to the model through the OpenAI Responses API.
2. If the model requests a shell command, the harness runs it and sends back its output and exit code. This repeats until the model finishes or the task deadline expires.
3. On success, the harness prints a JSON summary and the total tokens reported by the API. Each invocation takes one prompt.

## Run a task

You’ll need macOS or Linux, `uv`, Python 3.11 or newer, and an OpenAI API key with access to a model that supports tool calling.

Once the package is on PyPI, install it with `uv tool install minimal-agent-harness`. If you cloned the repo, run the same example from the repo root with `uv run --locked agent-harness` in place of `agent-harness`.

Replace the API key placeholder and change `--model` if you’re using a different model.

```sh
export OPENAI_API_KEY='your-api-key-here'

task_dir=$(mktemp -d)
agent-harness --model gpt-6.2-sol --directory "$task_dir" \
  'Write HELLO to output.txt, then reopen it to verify the contents.'
cat "$task_dir/output.txt"
```

The last command should print `HELLO`. The example uses a temporary directory. `--directory` sets where shell commands start, and those commands run with your user account’s permissions.

Add `--verbose` to see shell commands and their results as the task runs. Use `agent-harness --help` to see all options.

## Run the smoke tests

From the repo root, run the tool loop and timeout tests. They need no API key.

```sh
uv run --locked python -m unittest discover -s tests -v
```

For development details, see the [iteration 1 spec](specs/iteration_1/implementation.md). Set `OPENAI_BASE_URL` if you’re using a compatible Responses endpoint.
