Metadata-Version: 2.5
Name: prap
Version: 0.0.1
Summary: A lightweight agent harness.
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# prap

A lightweight agent harness.

```sh
pip install prap
```

```python
import asyncio
from prap import run


def model(messages):
    if messages[-1]["role"] == "tool":
        return {"content": "The answer is " + messages[-1]["content"]}
    return {
        "tool_calls": [
            {"id": "sum-1", "name": "add", "arguments": {"a": 2, "b": 3}}
        ]
    }


transcript = asyncio.run(run(
    model,
    [{"role": "user", "content": "What is 2 + 3?"}],
    {"add": lambda args: args["a"] + args["b"]},
))
print(transcript[-1]["content"])
```

Supply your own model callback or API adapter. Callbacks may be synchronous or
asynchronous. The model receives a copy of the transcript and returns an object
with a string `content` (default `""`) and an optional `tool_calls` list. Each call
has a nonempty string `id`, a registered `name`, and an `arguments` object. Each
tool receives that object as one positional argument and returns a JSON value.

Calls in a batch run sequentially after the entire batch is validated. A response
without tool calls ends the run. `max_turns` defaults to 8 and limits model calls;
tools requested on the last turn still run. An unfinished run raises
`TurnLimitError`. Callback exceptions propagate without retries. Messages and
results must be JSON serializable; non-finite numbers are rejected.

Requires Python 3.10 or newer. No runtime dependencies.

Licensed under Apache-2.0.
