Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
573e56e
feat(flow): openadapt test, agent testing on real apps with planted f…
abrichr Nov 21, 2026
679da27
fix(flow): keep the agent-test packs out of the root data ignore rule…
abrichr Nov 21, 2026
86e9b36
feat(flow): agent-test keeps raw table dumps and task values for hand…
abrichr Nov 21, 2026
ab1fec4
fix(flow): agent-test read-back checks, the Action under bash -e, lab…
abrichr Nov 21, 2026
98c1dd9
feat(flow): agent-test proof runs, hand check and docs; MCP server pa…
abrichr Nov 21, 2026
3e48d0a
fix(flow): agent-test receipts name command agents by digest, --min-s…
abrichr Nov 21, 2026
0884788
fix(flow): agent-test mypy
abrichr Nov 21, 2026
f449717
chore: ignore two synthetic EspoCRM row ids in the agent-test proof d…
abrichr Nov 21, 2026
2429776
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 21, 2026
2751999
fix(agent-test): gate fails an agent that stops saving; browsers pass…
abrichr Nov 21, 2026
c6e1b39
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 22, 2026
78231de
fix(agent-test): bind the baseline to the scenarios run; count delive…
abrichr Nov 22, 2026
c418051
proof(agent-test): drop model prices from the committed proof; keep c…
abrichr Nov 22, 2026
3100cf7
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 22, 2026
bab2201
build(eligibility): relock for flow's agent-test extra
abrichr Nov 22, 2026
d3b34d2
fix(agent-test): report model calls, not prices; regenerate two gate …
abrichr Nov 22, 2026
5561a21
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 22, 2026
b1d6451
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 23, 2026
4b718d7
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 23, 2026
766258f
test(cli): refresh root CLI surface snapshot for #2419
abrichr Nov 23, 2026
3801c00
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 24, 2026
faaf809
style(agent-test): ruff format store.py
abrichr Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
179 changes: 179 additions & 0 deletions .github/actions/openadapt-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: OpenAdapt agent test
description: >-
Run an agent against stateful scenarios on a real app (OpenEMR, Dolibarr,
EspoCRM) with planted faults, grade the app's database, and fail the build
when silent corruption or false claims of success rise above a stored
baseline. Writes report.html, results.json and receipt.json.
inputs:
app:
description: A built-in app (openemr, dolibarr, espocrm) or the path to an app pack .yaml.
required: true
agent:
description: >-
scripted, scripted-readback, claude-cu, openai-cu, claude-code-mcp,
mcp:<command> or browser-use:<script.py>. Leave empty with agent-cmd.
default: ""
agent-cmd:
description: Any command, run once per scenario (see packages/flow/docs/agent-test.md).
default: ""
model:
description: The model, for claude-cu, openai-cu or claude-code-mcp.
default: ""
instructions:
description: A text file added to the agent's instruction (your agent's own prompt).
default: ""
scenarios:
description: A scenario pack .yaml (default the app's built-in pack).
default: ""
only:
description: Comma-separated scenario ids (default all).
default: ""
repetitions:
description: Runs per scenario.
default: "1"
baseline:
description: A baseline .json to gate against. Empty runs without a gate.
default: ""
tolerance:
description: How far (0-1) a gated rate may rise above the baseline before the build fails.
default: "0.05"
min-scored:
description: >-
Refuse the gate (fail) when fewer runs than this were scored. The gate
also fails when the run scores a smaller share of its runs than the
baseline did, so an agent that stops saving fails even at the default.
default: "1"
spend-cap-usd:
description: Model spend cap for the run.
default: "5"
port:
description: The app's port; the front door listens on the next one.
default: "9870"
start-app:
description: Start the app's containers here (true), or use a stack already running (false).
default: "true"
app-host:
description: Where the app's port is reachable, when start-app is false.
default: "127.0.0.1"
docker:
description: The docker command (for a stack on another host).
default: docker
out:
description: Output directory.
default: openadapt-test-out
install:
description: >-
"source" installs openadapt-flow from this action's own checkout (the
ref you pinned); "pypi" installs openadapt-flow[agent-test] from PyPI;
"none" uses the runner's python, with openadapt-flow[agent-test] and
Playwright's chromium-headless-shell already installed (a self-hosted
runner).
default: source
python-version:
default: "3.12"
upload-artifact:
description: Upload the report as a workflow artifact ("false" on a runner that cannot).
default: "true"
artifact-name:
description: Name of the uploaded report artifact (must be unique within the workflow run).
default: ""
sign-key:
description: Path to an Ed25519 private key (PEM) to sign the receipt.
default: ""
outputs:
verdict:
description: pass, fail, not_comparable, or none (no baseline).
value: ${{ steps.run.outputs.verdict }}
report:
description: Path to report.html.
value: ${{ steps.run.outputs.report }}
runs:
using: composite
steps:
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: inputs.install != 'none'
with:
python-version: ${{ inputs.python-version }}
- name: Install openadapt-flow with the agent-test extra
if: inputs.install != 'none'
shell: bash
env:
INSTALL: ${{ inputs.install }}
ROOT: ${{ github.action_path }}/../../..
run: |
set -euo pipefail
python -m pip install --disable-pip-version-check --quiet --upgrade pip
if [ "$INSTALL" = "source" ]; then
python -m pip install --disable-pip-version-check --quiet "$ROOT/packages/types" "$ROOT/packages/flow[agent-test]"
else
python -m pip install --disable-pip-version-check --quiet "openadapt-flow[agent-test]"
fi
python -m playwright install --with-deps chromium-headless-shell
- name: Run the scenarios
id: run
shell: bash
env:
A_APP: ${{ inputs.app }}
A_AGENT: ${{ inputs.agent }}
A_AGENT_CMD: ${{ inputs.agent-cmd }}
A_MODEL: ${{ inputs.model }}
A_INSTRUCTIONS: ${{ inputs.instructions }}
A_SCENARIOS: ${{ inputs.scenarios }}
A_ONLY: ${{ inputs.only }}
A_REPS: ${{ inputs.repetitions }}
A_BASELINE: ${{ inputs.baseline }}
A_TOL: ${{ inputs.tolerance }}
A_CAP: ${{ inputs.spend-cap-usd }}
A_MIN: ${{ inputs.min-scored }}
A_PORT: ${{ inputs.port }}
A_START: ${{ inputs.start-app }}
A_HOST: ${{ inputs.app-host }}
A_DOCKER: ${{ inputs.docker }}
A_OUT: ${{ inputs.out }}
A_SIGN: ${{ inputs.sign-key }}
run: |
set -uo pipefail
args=(run --app "$A_APP" --port "$A_PORT" --app-host "$A_HOST" --docker "$A_DOCKER"
--repetitions "$A_REPS" --tolerance "$A_TOL" --spend-cap-usd "$A_CAP" --min-scored "$A_MIN" --out "$A_OUT")
[ -n "$A_AGENT" ] && args+=(--agent "$A_AGENT")
[ -n "$A_AGENT_CMD" ] && args+=(--agent-cmd "$A_AGENT_CMD")
[ -n "$A_MODEL" ] && args+=(--model "$A_MODEL")
[ -n "$A_INSTRUCTIONS" ] && args+=(--instructions "$A_INSTRUCTIONS")
[ -n "$A_SCENARIOS" ] && args+=(--scenarios "$A_SCENARIOS")
[ -n "$A_ONLY" ] && args+=(--only "$A_ONLY")
[ -n "$A_BASELINE" ] && args+=(--baseline "$A_BASELINE")
[ -n "$A_SIGN" ] && args+=(--sign-key "$A_SIGN")
[ "$A_START" = "true" ] && args+=(--up --down-after)
code=0
python -m openadapt_flow.agent_test "${args[@]}" || code=$?
verdict=none
if [ -f "$A_OUT/gate.json" ]; then
verdict=$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["verdict"])' "$A_OUT/gate.json")
fi
echo "verdict=$verdict" >> "$GITHUB_OUTPUT"
echo "report=$A_OUT/report.html" >> "$GITHUB_OUTPUT"
mkdir -p "$A_OUT" && echo "$code" > "$A_OUT/.exit-code"
exit 0
- name: Keep the report
if: always() && inputs.upload-artifact == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: ${{ inputs.artifact-name || format('openadapt-test-{0}-{1}', github.job, inputs.app) }}
path: |
${{ inputs.out }}/results.json
${{ inputs.out }}/report.html
${{ inputs.out }}/receipt.json
${{ inputs.out }}/gate.json
${{ inputs.out }}/summary.md
if-no-files-found: warn
- name: Fail on a regression
shell: bash
env:
A_OUT: ${{ inputs.out }}
run: |
code=$(cat "$A_OUT/.exit-code" 2>/dev/null || echo 2)
case "$code" in
0) echo "no regression" ;;
1) echo "::error::silent corruption or false success rose above the baseline (see report.html)"; exit 1 ;;
*) echo "::error::the test run failed or was not comparable with the baseline (exit $code)"; exit "$code" ;;
esac
60 changes: 60 additions & 0 deletions .github/workflows/agent-test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: agent-test-action

# Self-test of the `openadapt test` GitHub Action on a hosted runner, at no
# model cost: the model-free reference agent that reads its save back sets a
# baseline on Dolibarr, then the one that believes the page must fail the
# gate. Not a required check. Runs when the action or openadapt_flow.agent_test
# changes, and by hand.

on:
workflow_dispatch:
pull_request:
paths:
- .github/actions/openadapt-test/**
- .github/workflows/agent-test-action.yml
- packages/flow/openadapt_flow/agent_test/**

permissions:
contents: read

concurrency:
group: agent-test-action-${{ github.ref }}
cancel-in-progress: true

jobs:
gate-catches-a-regression:
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Baseline (scripted-readback)
id: base
uses: ./.github/actions/openadapt-test
with:
app: dolibarr
agent: scripted-readback
out: run-baseline
artifact-name: agent-test-baseline
- name: Store the baseline
run: python -m openadapt_flow.agent_test baseline --results run-baseline/results.json --out baseline.json
- name: Candidate (scripted, which never checks)
id: cand
continue-on-error: true
uses: ./.github/actions/openadapt-test
with:
app: dolibarr
agent: scripted
baseline: baseline.json
out: run-candidate
artifact-name: agent-test-candidate
- name: The gate must have failed the candidate
env:
VERDICT: ${{ steps.cand.outputs.verdict }}
OUTCOME: ${{ steps.cand.outcome }}
run: |
echo "candidate verdict: $VERDICT, step outcome: $OUTCOME"
test "$VERDICT" = fail
test "$OUTCOME" = failure
4 changes: 4 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ cc5fba3e0b69646430c7e11ae0c181aaaad82d7f:packages/flow/tests/test_sanitized_arti
f92237889163b242800c6aecd7c334c174ce4428:packages/flow/tests/test_connector_pilot.py:generic-api-key:56
# #2293 squash merge: the same tx/lens.py:885 type annotation that is already ignored at 7571d9c8 (no secret).
5e37bf177d46afddb4e48ea7b1bf87499964e276:packages/flow/openadapt_flow/tx/lens.py:generic-api-key:885
# PR #2419: EspoCRM's synthetic account row ids ("__key": "6b0157...") in the
# openadapt test proof runs' table dumps (no secret).
98c1dd9385e2e2f9a9da7be8dd67773ded477632:packages/flow/benchmark/agent_test_proof/runs/esp-scripted/evidence/esp-wrong-value-r1/table_after.json:generic-api-key:11
98c1dd9385e2e2f9a9da7be8dd67773ded477632:packages/flow/benchmark/agent_test_proof/runs/esp-scripted/evidence/esp-collateral-edit-r1/table_after.json:generic-api-key:11
# PR #2411: benchmark/hooks_live/runs/*/report.json from one live hooks run. Each match is
# "hold_key", a SHA-256 digest of a declared write's name and values (or of a call), not a
# credential. The reports must stay byte-identical because signed receipts cover them; the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| Test any agent on real apps with planted faults, in CI: `openadapt test run --app APP --agent AGENT` (apps: OpenEMR, Dolibarr, EspoCRM; agents: `scripted`, `scripted-readback`, `claude-cu`, `openai-cu`, `claude-code-mcp`, `mcp:CMD`, `browser-use:SCRIPT`, or `--agent-cmd`) runs the agent through stateful scenarios in local containers, plants one fault per save at a front-door proxy (partial, wrong value, duplicate, no_persist, collateral loss or edit, late revert, lost response, refused), grades the app's database before and after, and reports completed correctly, silent corruption, collateral edits, false success and safe stops as `results.json`, `report.html` and a digest-bound receipt (optionally Ed25519-signed). `baseline` and `gate` fail a build when silent corruption or false success rises; a composite GitHub Action (`.github/actions/openadapt-test`) wraps it. Apps and 24 scenarios are YAML data; app images are pulled by reference | In PR [#2419](https://github.com/OpenAdaptAI/OpenAdapt/pull/2419) | Real apps (Dolibarr 20.0.2, OpenEMR 8.0.0.3, EspoCRM 8.4 in Docker, synthetic records): all 20 faulted scenarios delivered their fault with the model-free agents; through the Action on Dolibarr, Claude Sonnet 5.5 with a read-back instruction scored 10% false success (2/20), and the gate failed both the same agent without the instruction (39%, 7/18) and GPT-6.1-sol (42%, 8/19), mostly collateral changes and duplicates said done; the late revert was said done by every agent that saved; 0 of 130 runs disagreed with an independent re-read of the raw tables (by the building agent, not a person); hosted-runner self-test 5 min 18 s cold. Not yet: a Medplum or openIMIS pack, significance testing in the gate, OpenEMR and EspoCRM with model agents | `openadapt test`, [AGENT_TEST.md](packages/flow/docs/AGENT_TEST.md), `openadapt_flow/agent_test/`, [proof runs](packages/flow/benchmark/agent_test_proof/README.md), `packages/flow/tests/test_agent_test.py` |
30 changes: 30 additions & 0 deletions openadapt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,36 @@ def _wrap_arguments(parsed: list[str]) -> list[str]:
return parsed


@main.command(
"test",
context_settings={
"ignore_unknown_options": True,
"allow_extra_args": True,
# openadapt_flow.agent_test owns its argparse help.
"help_option_names": [],
},
)
@click.pass_context
def agent_test_command(command_ctx: click.Context) -> None:
"""Test an agent on real apps with planted faults, for CI.

Runs any agent against stateful scenarios on an app in local containers
(OpenEMR, Dolibarr, EspoCRM), plants faults on its saves, grades the
app's database, and gates against a stored baseline. Every argument
passes to openadapt_flow.agent_test unchanged.
"""
_require_supported_python()
test_main = _optional_engine_entrypoint(
command_ctx, ("openadapt_flow.agent_test.cli",)
)
if test_main is None:
click.echo(
"Error: this openadapt-flow installation has no test command.", err=True
)
sys.exit(2)
sys.exit(int(test_main(list(command_ctx.args)) or 0))


@main.command(
"agent",
context_settings={
Expand Down
3 changes: 2 additions & 1 deletion openadapt/cli_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

# These tasks are implemented by launcher-native commands, not the Flow parser.
LAUNCHER_TASKS = {
"wrap": "Run an agent task once, then reuse its checked compiled tool"
"wrap": "Run an agent task once, then reuse its checked compiled tool",
"test": "Test an agent on real apps with planted faults, for CI",
}
TASKS.update(LAUNCHER_TASKS)

Expand Down
5 changes: 4 additions & 1 deletion packages/connectors/eligibility/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading