llm-connect/tests
tegwick 9de0f495db Pass --output-format json with --json-schema and unwrap CLI envelope
The Claude Code adapter previously passed --json-schema alone. On Claude
CLI 2.1.160 that combination still emits the model's conversational
preamble on stdout while the schema-enforced structured payload ships on
a sidecar channel the adapter cannot read. Result: callers requesting
structured output got prose that fails JSON parsing downstream — exactly
the failure mode the activity-core CUST-WP-0045 daily triage canary hit
on 2026-06-01 ("Triage report generated and returned via structured
output. Key signals:..." → json.loads error at column 1).

Fix: when --json-schema is set, also pass --output-format json. The CLI
then writes a JSON envelope on stdout. The adapter unwraps it by
probing a small allowlist of known text-bearing fields (result,
result_text, content, text, output). Unknown envelope shapes fall
through to raw stdout so the operator can introspect the structure and
extend the allowlist.

The unwrap path is only triggered when --json-schema was set, so non-
schema callers keep the existing raw-stdout behavior.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 10:20:24 +02:00
..
conftest.py feat: WP-0001 foundation + WP-0002 core extensions 2026-04-01 22:24:14 +00:00
test_adapter.py feat: WP-0001 foundation + WP-0002 core extensions 2026-04-01 22:24:14 +00:00
test_adaptive_integration.py Adaptive routing initial version 2026-05-18 11:38:12 +02:00
test_adaptive_routing.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
test_async.py feat: WP-0001 foundation + WP-0002 core extensions 2026-04-01 22:24:14 +00:00
test_budget.py feat: WP-0001 foundation + WP-0002 core extensions 2026-04-01 22:24:14 +00:00
test_claude_code.py Pass --output-format json with --json-schema and unwrap CLI envelope 2026-06-02 10:20:24 +02:00
test_cli.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
test_costs.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
test_exceptions.py feat: WP-0001 foundation + WP-0002 core extensions 2026-04-01 22:24:14 +00:00
test_factory.py feat: WP-0003 — RoutingPolicy (FR-2) and HTTP serve mode (FR-1) 2026-04-01 22:34:00 +00:00
test_grading.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
test_models.py feat: WP-0001 foundation + WP-0002 core extensions 2026-04-01 22:24:14 +00:00
test_package_exports.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
test_problem_classes.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
test_quality.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
test_rates.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
test_routing.py feat: WP-0003 — RoutingPolicy (FR-2) and HTTP serve mode (FR-1) 2026-04-01 22:34:00 +00:00
test_server.py Preserve llm-connect run config in server mode 2026-05-19 20:55:02 +02:00
test_shadowing.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00