Skip to content

Fix Anthropic judge default path: json_schema + any-llm-sdk floor bump#16

Merged
kelkalot merged 2 commits into
kelkalot:mainfrom
avalyset:fix/judge-anthropic-json-schema-pr
May 6, 2026
Merged

Fix Anthropic judge default path: json_schema + any-llm-sdk floor bump#16
kelkalot merged 2 commits into
kelkalot:mainfrom
avalyset:fix/judge-anthropic-json-schema-pr

Conversation

@avalyset

@avalyset avalyset commented May 6, 2026

Copy link
Copy Markdown
Contributor

Per discussion in #15.

Fixes the Anthropic judge default path (json_format=True), which has
been silently broken against any-llm-sdk's Anthropic provider across
the entire previously supported range due to blanket rejection of
response_format={"type": "json_object"}.

Changes:

  1. simpleaudit/model_auditor.py: _judge_conversation_async now uses
    the json_schema form, which _convert_response_format translates
    into Anthropic's output_config. Cross-provider compatible.

  2. pyproject.toml: floor bump any-llm-sdk>=1.9.0. Required because
    _convert_response_format was added in 1.8.6, and 1.8.3/1.8.4
    (previously allowed by the floor) would still hit the blanket
    rejection.

  3. tests/test_anthropic_judge_default_path.py: smoke test that runs
    a single scenario through the default path with an Anthropic judge.
    Catches future regressions on the path that had no CI coverage.

Tested locally: full suite passes, new smoke test passes against
claude-haiku-4-5-20251001.

Test skips cleanly with pytest.mark.skipif if ANTHROPIC_API_KEY is
not present in the CI environment — no broken CI if secrets aren't
configured.

Split out from the nav_aap pack discussion in #15 so it can land
independently. The pack PR will rebase cleanly once this is in main.

avalyset and others added 2 commits April 29, 2026 10:49
any-llm-sdk changed behaviour from ~1.9.x onwards: the Anthropic provider
no longer accepts response_format={"type": "json_object"} and raises
UnsupportedParameterError. The correct form is {"type": "json_schema",
"json_schema": {"name": ..., "schema": {...}}}, from which any-llm extracts
and forwards the JSON schema to Anthropic's output_config.

Replaces the opaque json_object call with an explicit schema that matches
exactly what parse_json_response and downstream AuditResult code consume
(severity, issues_found, positive_behaviors, summary, recommendations).
Also corrects the _call_async type hint (Dict[str, str] → Dict[str, Any]).

Tested with any-llm-sdk 1.13.0 against claude-opus-4-7 as judge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Eirik Botten Nicolaysen <eirik@ecodeco.no>
The json_schema switch in _judge_conversation_async only works on
any-llm-sdk versions where _convert_response_format is present
(>=1.8.6). Bumping to 1.9.0 for the cleaner stability point.

Adds a smoke test that exercises the default-path Anthropic judge
(json_format=True) with a single scenario, so CI catches a regression
on the path that was silently broken across the entire previous
supported range.
@kelkalot
kelkalot merged commit 49ca234 into kelkalot:main May 6, 2026
2 checks passed
@kelkalot

kelkalot commented May 6, 2026

Copy link
Copy Markdown
Owner

thanks a lot!

@avalyset

avalyset commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the quick turnaround. Will rebase nav_aap on updated main and open that PR shortly.

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.

2 participants