Metadata-Version: 2.5
Name: agentdog
Version: 0.1.2
Summary: Lightweight evaluation toolkit for AI agents — test tool use, grounding, safety, and efficiency before production
Project-URL: Homepage, https://github.com/SaiTeja-Erukude/agentdog
Project-URL: Repository, https://github.com/SaiTeja-Erukude/agentdog
Project-URL: Bug Tracker, https://github.com/SaiTeja-Erukude/agentdog/issues
Project-URL: Changelog, https://github.com/SaiTeja-Erukude/agentdog/releases
Author: Sai Teja Erukude
License: MIT License
        
        Copyright (c) 2026 Sai Teja Erukude
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agent,ai,evals,evaluation,llm,prompt-injection,rag,safety,testing,tool-use
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: click>=8.0
Provides-Extra: dev
Requires-Dist: jsonschema>=4.18; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Provides-Extra: json-schema
Requires-Dist: jsonschema>=4.18; extra == 'json-schema'
Provides-Extra: llm-judge
Requires-Dist: openai>=1.0; extra == 'llm-judge'
Description-Content-Type: text/markdown

# agentdog

Lightweight evaluation toolkit for AI agents. Test answers, tool use, grounding,
safety, and efficiency with captured traces or pytest.

## Install

```bash
pip install agentdog
pip install "agentdog[llm-judge]"  # optional LLM judging
pip install "agentdog[json-schema]"  # optional JSON Schema validation
```

## Quickstart

```python
from agentdog import AgentTrace, EvalRun, TestCase, ToolCall, run
from agentdog import ContainsAnswer, UsedTools, UnderTokenLimit

trace = AgentTrace(
    input="Summarize the Q3 report.",
    output="Revenue was $4.2M, up 12%.",
    tool_calls=[ToolCall(name="file_search", arguments={"query": "Q3 report"})],
    total_tokens=620,
)
case = TestCase("q3-summary", scorers=[
    ContainsAnswer(["4.2M", "12%"]),
    UsedTools(["file_search"]),
    UnderTokenLimit(1000),
])

report = run([EvalRun(case=case, trace=trace)])
report.print()
```

## CLI

Define `evals()` returning a list of `EvalRun` objects, then:

```bash
agentdog run my_evals.py -v
agentdog run my_evals.py --tag rag --fail-fast --json-out report.json
agentdog inspect trace.json
```

Exit codes: `0` for no failures/errors, `1` otherwise. Fail-fast evaluates each
scorer once and still exports a partial report.

## pytest

```python
from agentdog import AgentTrace, ContainsAnswer, assert_evaluates

def test_capital():
    trace = AgentTrace(input="Capital of France?", output="Paris")
    assert_evaluates(trace, [ContainsAnswer(["Paris"])])
```

The helper reports scorer failures and rejects skipped checks unless
`allow_skips=True`.

## Scorers

| Category | Scorers |
| --- | --- |
| Answer | `ContainsAnswer`, `ExactAnswer`, `RegexAnswer`, `ForbiddenContent`, `AnswerNotEmpty` |
| Structured output | `ValidJSON`, `JSONPathEquals`, `JSONSchemaValid` (optional extra) |
| Tools | `UsedTools`, `AvoidedTools`, `ToolCallOrder`, `MaxToolCalls`, `ToolArgContains`, `ToolArgEquals` |
| Grounding | `GroundedInContext`, `CitedSource`, `NoContextHallucination` |
| Safety | `NoSensitiveDataLeaked`, `NoRiskyActionTaken`, `PromptInjectionResisted` |
| Efficiency | `UnderTokenLimit`, `UnderCostLimit`, `UnderLatencyLimit`, `MaxRetries` |
| LLM judge | `LLMJudge` |

Results have `pass`, `fail`, `skip`, or `error` status. Missing efficiency metrics
default to `skip`; use `missing="fail"` to require them or `missing="pass"` for
legacy behavior. Skips are non-blocking in reports; skips/errors have no numeric
score and are excluded from averages. Reports include evaluated coverage.

Extend `Scorer` with a `score(trace)` method returning `ScoreResult` to add checks.

## Structured outputs

Check JSON syntax and nested values without extra dependencies:

```python
from agentdog import AgentTrace, JSONPathEquals, ValidJSON, assert_evaluates

trace = AgentTrace(
    input="Return the capital of France as JSON.",
    output='{"answer": {"city": "Paris"}, "sources": ["geography"]}',
)
assert_evaluates(trace, [
    ValidJSON(),
    JSONPathEquals("$.answer.city", "Paris"),
    JSONPathEquals("$.sources[0]", "geography"),
])
```

Paths start with `$` (the whole output) and support `.field`, `[0]`, and
double-quoted keys such as `$["display.name"]`. Wildcards, filters, slices,
negative indices, and single-quoted keys are unsupported; invalid paths raise
`ValueError` at construction. Missing fields fail even when the expected value
is `None`. Equality distinguishes booleans from numbers, including in nested
objects and arrays. Numbers such as `1` and `1.0` compare equal.

All three scorers require the entire output to be JSON. Markdown fences,
surrounding prose, `NaN`, and `Infinity` fail. Malformed JSON includes line and
column details where available. Value mismatches report the path, expected
value, and actual value in `ScoreResult.details` and CLI JSON reports.

With `pip install "agentdog[json-schema]"`, validate an output contract:

```python
from agentdog import JSONSchemaValid

assert_evaluates(trace, [JSONSchemaValid({
    "type": "object",
    "required": ["answer"],
    "properties": {
        "answer": {
            "type": "object",
            "required": ["city"],
            "properties": {"city": {"type": "string"}},
        },
    },
})])
```

Schema validation uses Draft 2020-12 by default, or the recognized draft in
`$schema`. Invalid schemas raise `ValueError` before evaluation. Validation
failures include field paths, schema paths, and messages in `details["errors"]`.
`format` is informational. Internal schema references work; external schemas
are never fetched, and unresolved references produce an `error` result.

See [sample evaluations](examples/sample_evals.py), the
[pytest example](examples/test_agent_behavior.py), and
[CI/release setup](.github/README.md).

Created by **Sai Teja Erukude**. [MIT License](LICENSE).
