Skip to content

test(365): pin the stickler surface Strands Evals 1.6.0 reads - #410

Merged
sromoam merged 2 commits into
devfrom
test/365-strands-evals-contract
Oct 20, 2026
Merged

sromoam merged 2 commits into
devfrom
test/365-strands-evals-contract

Conversation

@sromoam

@sromoam sromoam commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Closes #365.

strands-agents-evals 1.6.0 ships StructuredOutputSimilarity, and its stickler extra pins stickler-eval>=1.0.0,<2.0.0, so every stickler 1.x release reaches its users. Nothing in this repo exercised that surface. This adds tests that fail if stickler changes anything the evaluator reads.

What is pinned

Read from the 1.6.0 source (strands_evals/evaluators/deterministic/structured_output.py), not guessed:

  • Imports: stickler.eval_for, stickler.aggregate_from_comparisons, stickler.utils.process_evaluation.ProcessEvaluation.
  • eval_for / EvalSpec: the exact call the evaluator makes (match_threshold, weight_hints), evaluate(expected, actual), and explain() keyed by dotted path with comparator, threshold, weight, clip_under_threshold, source, why.
  • EvalResult: overall_score, precision, recall, f1 are finite floats in [0, 1]; matched == overall_score >= match_threshold; field_scores keys are the top-level fields.
  • raw: confusion_matrix.overall carries integer tp, fa, fd, fp, tn, fn. The evaluator reads these with .get() defaults, so a renamed key would turn every case into a pass instead of raising. The tests assert the keys exist.
  • The pass/fail guard: a verbatim copy of 1.6.0's _passed, checked against 13 expected verdicts. The e2e tests confirm the copy agrees with the real evaluator on every case.
  • aggregate_from_comparisons: on raws with prediction_raw stripped, as the evaluator stores them: no warnings, correct document_count, field_metrics keyed by the explain() paths, totals equal to the per-document counts, identical after a JSON round trip.

Files

tests/integrations/:

  • test_strands_evals_contract.py: the surface above, over a 42-case corpus (5 models: flat, nested, optional nested, lists of strings and of models, aliases). 605 tests, no extra dependency.
  • test_strands_evals_snapshot.py + strands_evals_snapshot.json: a golden snapshot of what the evaluator receives for 40 typical cases. Any change to it changes what Strands Evals users see, so it needs a CHANGELOG entry and a check against strands-agents-evals. Regenerate with STICKLER_UPDATE_STRANDS_SNAPSHOT=1.
  • test_strands_evals_e2e.py: the real evaluator, offline (a plain task function, no agent or model), through Experiment(..., report_cls=StructuredOutputReport). Skipped when strands_evals is absent. It also asserts that stickler imports from this checkout, not a PyPI copy.
  • README.md: the contract and the snapshot rule.

CI

A strands-evals job in run_pytest.yaml (Python 3.10 and 3.14) runs uv sync --frozen, installs strands-agents-evals==1.6.0 without the [stickler] extra (so it cannot replace this checkout with a PyPI stickler), then pytest tests/integrations. The package is exempt from the 7-day cooldown up to a cutoff just after the 1.6.0 upload; its dependencies are not. uv.lock and pyproject.toml are unchanged. The contract and snapshot tests also run in the existing test job.

Verified

Found in 1.6.0, for the evals side

  • On a sparse schema a wrong value can still pass: recall excludes FD, and fields blank on both sides lift the score.
  • The gate reads only the document's overall counts, so a missing item inside a nested list does not lower recall.
  • report.to_file() fails on datetime.date values.

strands-agents-evals 1.6.0 scores structured output with stickler
(StructuredOutputSimilarity, StructuredOutputReport). Its suite pins a released
stickler, so only a test here fails on the commit that breaks it.

- tests/integrations/strands_corpus.py: five models covering the shapes users
  pass as structured_output_model, 42 cases, and a verbatim copy of 1.6.0's
  _passed gate.
- test_strands_evals_contract.py (no strands dependency): import paths,
  eval_for kwargs, evaluate/explain shapes, every EvalResult attribute,
  that raw["confusion_matrix"]["overall"] carries integer tp/fa/fd/fp/tn/fn,
  recall = tp/(tp+fn), matched = score >= threshold, the nothing-to-find guard,
  and aggregate_from_comparisons on stripped and JSON-reloaded raws.
- test_strands_evals_snapshot.py + strands_evals_snapshot.json: exact scores,
  verdicts and aggregate metrics for 40 typical cases.
  STICKLER_UPDATE_STRANDS_SNAPSHOT=1 regenerates it.
- test_strands_evals_e2e.py: the real evaluator through Experiment, offline;
  skipped without strands_evals, fails if stickler is not this checkout.
- CI: a strands-evals job installs strands-agents-evals==1.6.0 without its
  [stickler] extra and runs tests/integrations on Python 3.10 and 3.14.

Refs #365.
@sromoam sromoam added this to the 1.0.1 (Minor) milestone Oct 16, 2026
@sromoam
sromoam requested a review from vawsgit October 16, 2026 17:44
@github-actions

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

  • Report generated: 2026-10-16T17:49:56+00:00
  • Time since scan: 3 minutes

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-10-16T17:46:29+00:00
  • ASH version: 3.1.2

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

  • Severity levels:
    • Suppressed (S): Findings that have been explicitly suppressed and don't affect scanner status
    • Critical (C): Highest severity findings that require immediate attention
    • High (H): Serious findings that should be addressed soon
    • Medium (M): Moderate risk findings
    • Low (L): Lower risk findings
    • Info (I): Informational findings with minimal risk
  • Duration (Time): Time taken by the scanner to complete its execution
  • Actionable: Number of findings at or above the threshold severity level that require attention
  • Result:
    • PASSED = No findings at or above threshold
    • FAILED = Findings at or above threshold
    • MISSING = Required dependencies not available
    • SKIPPED = Scanner explicitly disabled
    • ERROR = Scanner execution error
  • Threshold: The minimum severity level that will cause a scanner to fail
    • Thresholds: ALL, LOW, MEDIUM, HIGH, CRITICAL
    • Source: Values in parentheses indicate where the threshold is set:
      • global (global_settings section in the ASH_CONFIG used)
      • config (scanner config section in the ASH_CONFIG used)
      • scanner (default configuration in the plugin, if explicitly set)
  • Statistics calculation:
    • All statistics are calculated from the final aggregated SARIF report
    • Suppressed findings are counted separately and do not contribute to actionable findings
    • Scanner status is determined by comparing actionable findings to the threshold
Scanner Suppressed Critical High Medium Low Info Actionable Result Threshold
bandit 0 3 0 0 5965 0 3 FAILED MEDIUM (global)
cdk-nag 0 0 0 0 0 0 0 PASSED MEDIUM (global)
cfn-nag 0 0 0 0 0 0 0 MISSING MEDIUM (global)
checkov 0 0 0 0 0 0 0 PASSED MEDIUM (global)
detect-secrets 0 1 0 0 0 0 1 SKIPPED MEDIUM (global)
grype 0 0 0 0 0 0 0 MISSING MEDIUM (global)
npm-audit 0 0 0 0 0 0 0 PASSED MEDIUM (global)
opengrep 0 0 0 0 0 0 0 MISSING MEDIUM (global)
semgrep 3 0 0 0 0 0 0 PASSED MEDIUM (global)
syft 0 0 0 0 0 0 0 MISSING MEDIUM (global)

Top 2 Hotspots

Files with the highest number of security findings:

Finding Count File Location
2 tests/comparators/test_anls_leaf_semantics.py
2 tests/structured_object_evaluator/test_rollup_node_semantics.py

Detailed Findings

Show 4 actionable findings

Finding 1: SECRET-HEX-HIGH-ENTROPY-STRING

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-HEX-HIGH-ENTROPY-STRING
  • Location: tests/comparators/test_anls_leaf_semantics.py:89

Description:
Secret of type 'Hex High Entropy String' detected in file 'tests/comparators/test_anls_leaf_semantics.py' at line 89

Code Snippet:

Secret of type Hex High Entropy String detected

Finding 2: B108

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B108
  • Location: tests/comparators/test_anls_leaf_semantics.py:210-212

Description:
Probable insecure usage of temp file/directory.

Code Snippet:

uuid.UUID(int=1),
            pathlib.Path("/tmp/x"),
            b"bytes",

Finding 3: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1362-1368

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

def published_label(node: dict, section: str, object_lists: set) -> str:
            counts_objects = eval(  # noqa: S307
                cond.group(1),
                {},
                {"data": node, "section": section, "OBJECT_LISTS": object_lists},
            )
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Finding 4: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1367-1369

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

)
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Report generated by Automated Security Helper (ASH) at 2026-10-16T17:49:57+00:00


# e2e: install strands-agents-evals WITHOUT the [stickler] extra, which would
# pull a PyPI stickler-eval over this checkout. The e2e fails if it did.
uv pip install --python .venv "strands-agents-evals==1.6.0"

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

The local e2e install command fails today: it has no --exclude-newer-package, so the 7-day [tool.uv] cooldown rejects 1.6.0 (uploaded 2026-10-14T22:45Z).

Verified with uv 0.12.3 on 2026-10-20: uv pip install --python .venv "strands-agents-evals==1.6.0" exits with "requirements are unsatisfiable" and the hint "strands-agents-evals was filtered by exclude-newer". Anyone following the Running section before 2026-10-21 cannot run the e2e file. Add the same --exclude-newer-package "strands-agents-evals=2026-10-15T00:00:00Z" flag the workflow uses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442 (59e39ce, 2db699d). The README command now carries the workflow's --exclude-newer-package "strands-agents-evals=2026-10-15T00:00:00Z" and the same uv.lock constraints as CI, and it writes them to a mktemp file instead of a fixed /tmp path. Ran the exact snippet as a dry run in bash and zsh against a fresh venv (uv 0.11.6): it resolves strands-agents-evals==1.6.0 with idna==3.15. Thanks for catching it.

## Bumping strands-agents-evals

Re-read `structured_output.py` in the new wheel, update the line references and
`strands_test_pass` if `_passed` changed, then bump the pin in the workflow. The

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

The bump procedure says to bump the pin but not to move the --exclude-newer-package cutoff, and the fixed cutoff blocks every later release permanently.

The per-package override replaces the global 7-day cooldown for strands-agents-evals. A maintainer who follows this section and changes only ==1.6.0 to ==1.7.0 keeps the cutoff 2026-10-15T00:00:00Z, so 1.7.0 never resolves, even after 7 days, and the strands-evals job fails at install. The workflow comment says "Move the cutoff with the pin". Add that step here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442 (59e39ce, 2db699d). The bump steps now say to change the ==1.6.0 pin and move the --exclude-newer-package cutoff to just after the new release's upload time, in both the workflow and the README command, and to git grep -n 1.6.0 for the remaining references. They also say why: the cutoff replaces the cooldown for this package, so a pin newer than the cutoff never resolves.

# (1.6.0 was uploaded 2026-10-14T22:45Z), so the job tests the release
# the integration shipped in. Move the cutoff with the pin.
run: >-
uv pip install --python .venv

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

uv pip install runs without constraints, so it upgrades packages that uv.lock pinned. The strands-evals job then tests stickler against dependency versions that uv.lock does not record.

Measured on this branch after uv sync --frozen: the dry run of this exact command replaces idna==3.15 (locked) with idna==3.20. A future strands-agents or transitive release that raises a pydantic, numpy or scipy floor would move those packages too, and failures would be blamed on stickler. Constrain the install to the lock: uv export --frozen --no-hashes -o /tmp/lock.txt followed by uv pip install ... -c /tmp/lock.txt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442 (59e39ce, 2db699d). The install is now constrained to the lock: uv export --frozen --no-hashes --no-emit-project -q -o "$RUNNER_TEMP/uv-lock.txt", then uv pip install -c. --no-emit-project is required: without it the export includes -e . and uv rejects it ("Unnamed requirements are not allowed as constraints"). Measured with a dry run in a fresh venv: constrained gives idna==3.15, unconstrained gives 3.20. The constraints cover uv.lock's default (no-extras) export only, 78 packages. 35 of the packages strands-agents-evals installs (boto3, httpx, strands-agents, mcp, ...) are locked only under extras and can still move. The workflow comment says so. CI uses a file and not <(...) because process substitution hides a failed export and installs unconstrained (measured). -q stops the 221-line echo.

class TestGuard:
@pytest.mark.parametrize("case_id,expected", sorted(GUARD_VERDICTS.items()))
def test_verdict(self, case_id, expected):
assert strands_test_pass(_evaluate(_case(case_id)), 0.7) is expected

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

TestGuard hardcodes 0.7 instead of STRANDS_DEFAULT_THRESHOLD, which this file imports and uses elsewhere.

If the default in strands_corpus.STRANDS_DEFAULT_THRESHOLD changes on a strands bump, _evaluate scores at the new threshold but strands_test_pass(..., 0.7) still gates recall at 0.7. Lines 325, 333, 341 and the other 0.7 literals in TestGuard then pin verdicts for a configuration the evaluator does not use. Replace the literals with the constant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442. 59e39ce replaced the TestGuard literals with STRANDS_DEFAULT_THRESHOLD. 2db699d replaced the last stray one, the eval_for signature bind. The only 0.7s left are the [0.5, 0.7, 0.9, 1.0] threshold sweeps, which are deliberate.

# --- aggregate_from_comparisons ---------------------------------------------------


def _by_model():

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

_by_model() evaluates all 42 corpus cases on every call, and every TestAggregate test calls it, even though each test uses one model's cases.

There are 25 parametrized calls, so the corpus is evaluated about 1,000 times to produce results that never change. Optional: cache the result with a module-scoped fixture or functools.lru_cache, or evaluate only the requested model's cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442. 59e39ce made the helper (now _results(model)) evaluate only the requested model's cases. 2db699d makes _evaluate share one spec per model and threshold, as the evaluator shares the one it builds at line 344. Measured over test_strands_evals_contract.py: eval_for calls went from 1630 to 116 and evaluate calls from 1577 to 737, still 603 passed.

stored: Dict[str, List[Dict[str, Any]]] = {}
cases: Dict[str, Any] = {}
for case in SNAPSHOT_CORPUS:
spec = specs.setdefault(

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

specs.setdefault(case.model, eval_for(...)) evaluates its default eagerly, so eval_for runs once per case (40 times) and 35 of the specs are discarded.

setdefault always evaluates its second argument. Optional: use if case.model not in specs: specs[case.model] = eval_for(...), which builds one spec per model as the code intends.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442 (59e39ce). It is now if case.model not in specs: specs[case.model] = eval_for(...). Measured: build_snapshot calls eval_for 4 times (one per model), down from 40. The snapshot is unchanged.

return spec.evaluate(case.expected, case.actual)


def _case(case_id):

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

_case, CASE_IDS, and _direct (an equivalent of the contract file's _spec/_evaluate) are copied between test_strands_evals_e2e.py and test_strands_evals_contract.py.

Both files already import from strands_corpus.py. Optional: move these helpers there, so a change to how a case is looked up or scored only has to be made once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I kept it out of the follow-up to keep that diff to review fixes. It is tracked for 1.1.0 in #440: move _case, CASE_IDS and the evaluate helper (_direct / _evaluate) into strands_corpus.py, so both files share one lookup and one scoring path.



@pytest.fixture(scope="module", autouse=True)
def _this_checkout_offline():

@vawsgit vawsgit Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking — suggest a follow-on issue.

Only the e2e file checks which stickler is imported. The contract and snapshot tests do not, and they run when strands_evals is absent, which is when the e2e file is skipped.

If an editable install points at another worktree, a local pytest tests/integrations without strands reports the snapshot as matching or changed against that other tree, and nothing fails to flag it. AGENTS.md ("Print which stickler you imported before you trust a number") describes this case. Optional: move the inspect.getfile(stickler) check into a tests/integrations/conftest.py so it covers all three files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #442 (59e39ce). The check moved from the e2e file into tests/integrations/conftest.py as a session-scoped autouse fixture, so it covers the contract, snapshot and e2e files whether or not strands is installed. Measured: run from w365f with a venv whose editable stickler points at another worktree, all 777 tests error. With PYTHONPATH set to the checkout: 776 passed, 1 xfailed. A repo-wide version of the guard is tracked separately in #441.

@vawsgit vawsgit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM!

The 8 inline comments are non-blocking and are suggestions for follow-on issues.

@sromoam
sromoam merged commit 0921f4a into dev Oct 20, 2026
13 checks passed
@sromoam
sromoam deleted the test/365-strands-evals-contract branch October 20, 2026 19:27
@sromoam

sromoam commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @vawsgit for the careful review. #410 merged before the fixes landed, so they are in #442:

  • 59e39ce: README install command gets the cooldown cutoff; CI and README are constrained to uv.lock; bump steps move the cutoff; the this-checkout guard moves to conftest.py; TestGuard uses STRANDS_DEFAULT_THRESHOLD; TestAggregate evaluates one model's cases; the snapshot builds one spec per model.
  • 2db699d: the constraint file is a mktemp file chained with && (fails closed; <(...) measured to fail open), uv export -q, accurate default-lock wording, the README pin named in the bump steps, the workflows README row updated, the last 0.7 replaced, and specs shared across cases (eval_for calls in the contract file: 1630 to 116).

Measured on the follow-up tree: full suite 3765 passed, 3 skipped, 1 xfailed; Strands e2e (strands-agents-evals 1.6.0) 776 passed, 1 xfailed; snapshot unchanged. Helper dedup (#440) and a repo-wide wrong-tree guard (#441) are tracked for 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strands Evals integration contract tests (strands-agents-evals 1.6.0)

2 participants