Metadata-Version: 2.4
Name: agent-stress-lab
Version: 0.1.0
Summary: A CLI harness for fault and regression tests of existing agents
Project-URL: Homepage, https://github.com/eduard-s/agent-stress-lab
Project-URL: Repository, https://github.com/eduard-s/agent-stress-lab
Project-URL: Issues, https://github.com/eduard-s/agent-stress-lab/issues
Project-URL: Documentation, https://github.com/eduard-s/agent-stress-lab/blob/main/docs/harness-protocol.md
Author: Eduard Smirnov
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.12
Requires-Dist: httpx<1,>=0.28
Requires-Dist: pydantic<3,>=2.11
Requires-Dist: pyyaml<7,>=6
Provides-Extra: dev
Requires-Dist: build<2,>=1; extra == 'dev'
Requires-Dist: pytest<10,>=8; extra == 'dev'
Requires-Dist: ruff<1,>=0.14; extra == 'dev'
Requires-Dist: twine<7,>=6; extra == 'dev'
Description-Content-Type: text/markdown

# Agent Stress Lab

Agent Stress Lab is a CLI harness for agents that you already run. It sends test
cases to an agent, forces failures at its tool boundary, and grades the result.
It compares two agent versions and gives CI a pass or fail result. The harness
does not need a web server or an OpenAI key. The target agent uses its own model.

## Install

Use Python 3.12 or newer. Install the public package in a virtual environment.

```sh
python -m pip install agent-stress-lab
asl --help
```

The package supplies the CLI. The repository supplies the refund fixture and
the full [target protocol](https://github.com/eduard-s/agent-stress-lab/blob/main/docs/harness-protocol.md).

## First run

Use `uv` to run the fixture from the repository.
If `uv` is not on `PATH`, use `./.venv/bin/uv` in this checkout.

```sh
uv sync --locked
uv run --locked asl run \
  --target examples/refund/target.toml \
  --suite examples/refund/suite.yaml \
  --output results/refund.json \
  --html results/refund.html \
  --junit results/refund.xml
```

The fixture suite reports nine passes, six faults that fired, and nine safety
audits. It includes crashes after a refund and after an approval. The fixture
sets the approval decision in each case. It does not ask a person for a decision.
The fixture agent uses fixed rules.
Its result shows the harness fault paths. It does not measure a model.

To see a real regression in the fixture, run the changed target. Then compare
the two result files.

```sh
uv run --locked asl run \
  --target examples/refund/target_regressed.toml \
  --suite examples/refund/suite.yaml \
  --output results/refund_regressed.json
uv run --locked asl compare results/refund.json results/refund_regressed.json
```

The changed target fails the timeout case. `asl compare` names that case and
returns exit code 1. `asl run` also returns exit code 1 if a case fails. It
writes the result files before it returns.

## Connect an agent

A target file names a Python function, a JSON-lines process, or an HTTP
endpoint. The [target protocol](https://github.com/eduard-s/agent-stress-lab/blob/main/docs/harness-protocol.md) gives the exact
formats. A Python target has this small entry point:

```python
def run(request, tools):
    result = tools.call("lookup", {"id": request["input"]["id"]}, "call-1")
    return {"answer": str(result), "outcome": "resolved"}
```

The agent can call its own model inside that function. The harness does not
replace the agent. For tool faults, the agent must send tool calls through the
supplied `tools` client. A target environment receives those calls and gives
the harness the final state. An optional auditor examines that state after
each trial. The harness starts a new process and environment for each trial.

An HTTP target can run black-box tests against an existing service. It can
receive input faults. The agent returns an answer, outcome, and trace. A
separate endpoint supplies the observed state. Tool faults need a Python or
process target with a tool boundary.

## Cases and results

Each YAML case states the input, initial state, optional fault, and assertions.
Assertions can read the answer, outcome, final state, trace, or metrics. The
grader also fails a case if its planned fault never fires. A safety audit
finding fails a case. The result states how many trials received a safety
audit. A pass without an audit does not mean that no unsafe action occurred.

The harness supports an input attack, tool timeout, tool error, replaced tool
result, and process death after a tool effect. The process target restarts once
after that crash. Its workspace and tool environment survive the restart.

Use `--repeat N` to run each case more than once. Use `--case ID` to run one
case. The JSON result includes each trial, its trace, its final state, its
assertions, and hashes of the target and suite files. The static HTML report
needs no server. The JUnit file works in CI.

```sh
uv run --locked asl report results/refund.json \
  --html results/refund.html --junit results/refund.xml
```

## Development

```sh
uv sync --locked --extra dev
uv run --locked --extra dev pytest -q
uv run --locked --extra dev ruff check asl tests examples/refund
```

The [HTML specification](https://github.com/eduard-s/agent-stress-lab/blob/main/docs/agent-stress-lab-spec.html)
describes the CLI harness and the next work for a real agent.
