Metadata-Version: 2.4
Name: sentient-evals
Version: 0.1.2
Summary: Universal evaluation harness for AI agents (local + embeddable).
Author-email: Sentient <oss@sentient.ai>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
License-File: LICENSE
Keywords: agents,ai,benchmark,evaluation,harness,llm
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Requires-Dist: jinja2>=3.1
Requires-Dist: packaging>=23.0
Requires-Dist: pydantic>=2.7
Requires-Dist: requests>=2.31
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Provides-Extra: autogen
Requires-Dist: pyautogen; extra == 'autogen'
Provides-Extra: crewai
Requires-Dist: crewai; extra == 'crewai'
Provides-Extra: daytona
Requires-Dist: daytona; extra == 'daytona'
Provides-Extra: docker
Requires-Dist: docker; extra == 'docker'
Provides-Extra: e2b
Requires-Dist: e2b; extra == 'e2b'
Provides-Extra: interactive
Requires-Dist: inquirerpy>=0.3.4; extra == 'interactive'
Provides-Extra: langchain
Requires-Dist: langchain-core; extra == 'langchain'
Provides-Extra: llm
Requires-Dist: litellm>=1.50; extra == 'llm'
Provides-Extra: modal
Requires-Dist: modal>=1.3.0.post1; extra == 'modal'
Description-Content-Type: text/markdown

# sentient-evals

`sentient-evals` is a plug-and-play evaluation harness for AI agents (any framework) that can run locally/offline and can also be embedded by the Sentient platform.

## Goals

- Run **tasks** concurrently with **multiple trials** to reduce variance.
- Capture **trajectories (ATIF)** and **outcomes** (final environment state).
- Support **code-based graders** (tests, static checks, tool-call verification), **model-based graders** (LLM-as-judge, multi-judge voting + calibration), and **human review** hooks for calibration.
- Produce a **Harbor-style jobs directory** for debuggability.
- Keep the core harness framework-agnostic; integrate frameworks via adapters.

This design is aligned with Anthropic’s definitions of task, trial, transcript, outcome, grader, harness, and suites ([Demystifying evals for AI agents](https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents)).

## Install

```bash
pip install sentient-evals
```

For model-based graders:

```bash
pip install "sentient-evals[llm]"
```

## CLI (local mode)

```bash
sentient-evals --help
sentient-evals run --help
```

### Installed CLI agents (Harbor-style)

Built-in installed adapters (run via `--adapter <name>`) mirror Harbor's CLI agents:

- `claude-code`
- `codex`
- `opencode`
- `cursor-cli`
- `cline-cli`
- `gemini-cli`
- `goose`
- `qwen-coder`
- `openhands`
- `swe-agent`
- `mini-swe-agent`
- `aider`

These adapters install the CLI inside the trial environment at runtime.
For sandboxed runs, use Docker, Daytona, or E2B environments so the agent can be installed
in an isolated container.

### Plug-and-play graders via config

For real evaluations, pass an adapter and grader config (TOML or JSON). The CLI can also default to `verifier_script` for task bundles when `tests/test.sh` exists.

### Plug-and-play custom agents via --agent-file

If you have a local Python agent (LangChain, CrewAI, custom loop, etc.), you can point the CLI at a file without packaging your repo:

```bash
sentient-evals run --tasks-dir ./tasks --env local_python --agent-file ./path/to/agent.py:my_agent --config eval.toml
```

The `:my_agent` attribute can be:
- an adapter object with an async `run(task, instruction, seed, env, artifacts)` method
- a factory function that returns such an adapter
- a plain function (sync/async) that returns `dict`/`str` (it will be wrapped automatically)

Example (TOML):

```toml
[adapter]
type = "import"
import_path = "my_project.my_adapter:build_adapter"

[[graders]]
type = "verifier_script"

[[graders]]
type = "static_analysis"
config = { checks = [{ name = "ruff", cmd = "ruff check ." }] }
```

Run:

```bash
sentient-evals run --tasks-dir path/to/tasks --env docker_cli --config eval.toml --concurrency 4
```

## Task bundles (directory format)

For production agent evals, prefer **task bundles** (directories) over plain JSON tasks.

Bundle layout:

- `task.toml` (task id, inputs, env config)
- `instruction.md` (agent-facing instruction)
- `files/` (payload copied into the trial workspace)
- `environment/` (Dockerfile/build context for container backends)
- `tests/` (optional verifier scripts and fixtures)

Run a directory of task bundles:

```bash
sentient-evals run --tasks-dir path/to/tasks --env docker_cli
```

Supported `--env` values:
- `local_python`
- `docker_cli`
- `docker_sdk` (requires `sentient-evals[docker]`)
- `podman_cli` (requires `podman` installed)
- `daytona` (requires `sentient-evals[daytona]` and Daytona configured)
- `e2b` (requires `sentient-evals[e2b]` and `E2B_API_KEY`)
- `modal` (requires `sentient-evals[modal]`, `MODAL_TOKEN_ID`, and `MODAL_TOKEN_SECRET`)

Notes:
- Docker-based runs require Docker (or Podman) installed and running.
- For parallel sandboxed evals, prefer `docker_cli` locally or Daytona/E2B in the cloud.
- Modal is a strong cloud alternative when Daytona/E2B networking or runtime installation constraints block runs.
- If Daytona access is blocked (for example, client-side IP restrictions), use `--env e2b` as a cloud fallback.
- Cloud backends currently assume **single-container** tasks (multi-container orchestration is not yet supported).
- You can throttle cloud provider concurrency per task bundle via `environment.provider_concurrency` in `task.toml`.
- E2B does not build per-task Dockerfiles at runtime. For container tasks on E2B, set `[environment].image` to a valid E2B template id (for example `base`).
- Datasets that rely on Docker image parity (for example many SWE-bench style tasks with `FROM swebench/...`) should run on `docker_cli` or `daytona` unless you provide mapped E2B templates.

Install E2B support:

```bash
pip install "sentient-evals[e2b]"
export E2B_API_KEY=your_api_key
```

Example:

```bash
sentient-evals run --tasks-dir path/to/tasks --env e2b --adapter cursor-cli --config eval.toml
```

Install Modal support:

```bash
pip install "sentient-evals[modal]"
export MODAL_TOKEN_ID=your_token_id
export MODAL_TOKEN_SECRET=your_token_secret
```

Example:

```bash
sentient-evals run --tasks-dir path/to/tasks --env modal --adapter cursor-cli --config eval.toml
```

## Output layout (local runs)

By default, results are written under `jobs/<run_id>/`:

- `jobs/<run_id>/run_config.json`
- `jobs/<run_id>/run_result.json`
- `jobs/<run_id>/trials/<trial_id>/trial_config.json`
- `jobs/<run_id>/trials/<trial_id>/trajectory.json`
- `jobs/<run_id>/trials/<trial_id>/outcome.json`
- `jobs/<run_id>/trials/<trial_id>/trial_result.json`
- `jobs/<run_id>/trials/<trial_id>/judge/` (optional judge artifacts)
- `jobs/<run_id>/trials/<trial_id>/verifier/` (optional verifier artifacts)

## Artifact anatomy

Example directory structure for a run with one trial using an LLM-as-judge grader:

```
jobs/my-run-2025-01-20/
├── run_config.json                # Run-level configuration
├── run_result.json                # Run-level aggregated results
└── trials/
    └── task1__0/
        ├── trial_config.json      # Trial configuration (seed, adapter, etc.)
        ├── trajectory.json        # ATIF trajectory (full run)
        ├── outcome.json           # Final environment state snapshot
        ├── trial_result.json      # Trial-level grader results
        ├── judge/                 # LLM judge artifacts (when using LLM graders)
        │   ├── prompt.txt         # Judge prompt sent to LLM
        │   ├── response.json      # Raw LLM response (full API response)
        │   ├── response.txt       # Extracted text content
        │   └── verdict.json       # Parsed verdict (passed, score, model)
        └── verifier/              # Code-based grader outputs (optional)
            └── test_output.txt    # Example: test stdout/stderr
```

### Example: `jobs/my-run-2025-01-20/run_config.json`

```json
{
  "schema_version": "v1",
  "run_id": "my-run-2025-01-20",
  "suite": {
    "schema_version": "v1",
    "id": "default",
    "trials_per_task": 1,
    "concurrency": 1,
    "seeds": [123]
  },
  "adapter": "json_echo",
  "started_at": "2025-01-20T10:00:00Z",
  "harness_version": "0.0.1",
  "model": null
}
```

### Example: `jobs/my-run-2025-01-20/run_result.json`

```json
{
  "schema_version": "v1",
  "run_id": "my-run-2025-01-20",
  "suite_id": "default",
  "started_at": "2025-01-20T10:00:00Z",
  "finished_at": "2025-01-20T10:00:05Z",
  "task_count": 1,
  "trial_count": 1,
  "passed_trials": 1,
  "failed_trials": 0,
  "avg_score": 1.0
}
```

### Example: `jobs/my-run-2025-01-20/trials/task1__0/judge/verdict.json`

```json
{
  "passed": true,
  "score": 1.0,
  "judge_model": "gpt-4",
  "raw_head": "PASS"
}
```

## License

Apache-2.0. See `LICENSE`.
