Skip to main content

revefi-agent-test

A small Python harness that asserts an AI agent actually called the tools it was supposed to — verified against Revefi's LLM observability spans, not the answer text. Works for any agent instrumented with revefi-llm-sdk.

Per case it: generates a per-run test_prompt_id → POSTs the case body to the agent's url with a test-prompt-id header → polls Revefi's test-span-data API by that id → checks the run's span for the required_tools → optionally scores the answer against a baseline_answer via Revefi's baseline-similarity API → prints the result. Exit code is non-zero if any case fails.

Two keys (least-privilege)

The harness uses two distinct API keys so each can be least-privilege:

  • config.api_key — the read-only key for Revefi observability reads (test-span-data and baseline-similarity). config.base_url is the Revefi public API base.
  • cases[].api_key — the key used to call that case's agent url (e.g. /raden/ask).

Keys, config.base_url and each case url may contain ${ENV_VAR} references, expanded from the environment at load time. CI injects secrets via env so the YAML never commits them, and one YAML can target several deployments (base_url: ${REVEFI_API_BASE}, url: ${REVEFI_API_BASE}/raden/ask). An unset variable fails the run before any case starts. The read and agent keys must be the same tenant, or the span read won't find the agent run's spans.

Layout

revefi_agent_test/__init__.py   # all the logic + the CLI (run_test, AgentTestCase, RevefiConfig, main)
revefi_agent_test/__main__.py   # lets you do `python -m revefi_agent_test`
examples/raden.yaml             # a worked example config you copy and edit
pyproject.toml                  # package metadata (the `revefi-agent-test` command)

Run it

pip install -e .                          # from this repo (editable; no PyPI needed)
cp examples/raden.yaml my.yaml            # copy the example, then edit the config block + cases
export REVEFI_OBS_API_KEY=…  REVEFI_AGENT_API_KEY=…   # if the YAML uses ${REVEFI_OBS_API_KEY} / ${REVEFI_AGENT_API_KEY}
revefi-agent-test --config my.yaml

The config (one generic format)

A single YAML file: a config block (the read-only observability connection) plus cases, each a self-contained agent request (url + api_key + body).

config:
  base_url: https://your-revefi-instance.com/v1   # Revefi public API base — observability reads
  api_key: ${REVEFI_OBS_API_KEY}                       # READ-ONLY key; literal or a ${ENV_VAR} reference

cases:
  - name: web search
    url: https://your-agent.example.com/run        # the agent endpoint to drive
    api_key: ${REVEFI_AGENT_API_KEY}                    # key for THIS agent call; literal or ${ENV_VAR}
    body:                                           # POSTed to `url` verbatim — shape is up to the agent
      input: "Who won the 2024 IPL final? Use web search."
    required_tools:
      - web_search_tool

  - name: answer quality                            # optional semantic check via baseline-similarity
    url: https://your-agent.example.com/run
    api_key: ${REVEFI_AGENT_API_KEY}
    body:
      input: "What is the configuration of warehouse REVEFI_DEV_WH?"
    baseline_answer: "REVEFI_DEV_WH is X-SMALL with auto-suspend 60s."
    min_similarity: 0.8                             # fail if cosine(answer, baseline) < this (default 0.8)

body is opaque — it's whatever the agent under test expects. A case can assert required_tools (verified via spans) and/or set baseline_answer + min_similarity (verified via baseline-similarity). The similarity candidate is the answer text parsed from the run's span (the LLM completion content — cleaner than the agent's JSON/markup HTTP body); if the span can't be read (not ingested), it falls back to the raw agent response.

As a library

from revefi_agent_test import RevefiConfig, AgentTestCase, run_test

cfg = RevefiConfig(base_url="https://your-revefi-instance.com/v1", api_key="<read-only obs key>")
cases = [
    AgentTestCase(
        name="web search",
        url="https://your-agent.example.com/run",
        api_key="<agent key>",
        body={"input": "Who won the 2024 IPL final? Use web search."},
        required_tools=["web_search_tool"],
    )
]
assert all(r.passed for r in run_test(cfg, cases))

How test_prompt_id reaches the agent

The harness attaches a per-run test-prompt-id header to every agent call. The agent reads it off its inbound request and forwards it to revefi_llm_sdk.set_request_test_prompt_id(...) so the run's spans get tagged — in the agent's own request handler, or in whatever gateway fronts it. The harness never touches the body, so adopting this needs no change to your agent's request schema.

How tools are detected

Verification reads the run's latest SPAN_KIND_CLIENT span from Revefi's test-span-data API and collects tool names from extractedData.promptsList[*].toolCallsList[*].name (and completionsList[*]), comparing them against required_tools.

CI

Run it in CI by pointing --config at a YAML committed to your repo whose api_key values are ${ENV_VAR} references, and inject the matching secrets via env — never commit the tokens. For example, with config.api_key: ${PUBLIC_API_TOKEN_RO} and cases[].api_key: ${PUBLIC_API_TOKEN}:

env:
  PUBLIC_API_TOKEN_RO: ${{ secrets.PUBLIC_API_TOKEN_RO }}   # read-only observability key
  PUBLIC_API_TOKEN:    ${{ secrets.PUBLIC_API_TOKEN }}      # agent-call key (same tenant)

Metadata

Release files for revefi-agent-test 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for revefi-agent-test 0.3.4
File Size Uploaded Provenance Actions
revefi_agent_test-0.3.4.tar.gz 14.2 kB Without provenance Details for revefi_agent_test-0.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for revefi-agent-test 0.3.4
File Interpreter ABI Platform Actions
revefi_agent_test-0.3.4-py3-none-any.whl Python 3 none any Details for revefi_agent_test-0.3.4-py3-none-any.whl

Total release size: 27.1 kB

Release files / revefi_agent_test-0.3.4.tar.gz

Download URL revefi_agent_test-0.3.4.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c9f305ea8d9450adf1bab4879ac53e916057762823f2effba4ace18a9b58405a
BLAKE2b-256 checksum
How to use checksums
8a00ebceea8778beb2b6bb75d3cff0275efe5df1d327925a436cc6ead15a1f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / revefi_agent_test-0.3.4-py3-none-any.whl

Download URL revefi_agent_test-0.3.4-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d07d672c8e44f3a6aa5bea3344ec464febb5a9ac7c2b2adb454fa2721c7f671
BLAKE2b-256 checksum
How to use checksums
2e8f49810c4a812f2bbd655f36eb2ead72425b9d21057c31540dc69f7a07e70b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for revefi-agent-test 0.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page