llm-connect/llm_connect
tegwick cd4551c575 Translate json_schema and drop non-OpenAI fields in OpenRouter adapter
The adapter previously did a blind payload.update(config.model_params).
For callers like activity-core that pass reasoning_effort, max_depth,
and json_schema (Claude / llm-connect-specific fields), those leaked
into the OpenAI Chat Completions request body and OpenRouter rejected
the whole call with HTTP 400. CUST-WP-0045 canary on 2026-06-02 hit
this — manual repro confirmed: same prompt with no model_params returns
a clean 10-recommendation WSJF report in 4.5s; with model_params
included, every call 400s.

Replace the merge with a whitelist + translation step:

- pass-through known OpenAI Chat Completions fields (top_p, stop, seed,
  tools, response_format, etc.)
- translate json_schema into the proper response_format wrapper
  ({type:"json_schema", json_schema:{name,schema,strict}})
- drop documented non-OpenAI fields (reasoning_effort, max_depth) so
  the payload stays valid
- silently drop unknown keys rather than risk another 400

The same pattern will need to apply to the OpenAI and Gemini adapters
when their callers start passing provider-specific keys — left as
follow-up rather than speculative refactoring.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-02 14:15:24 +02:00
..
__init__.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
_http.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
_token_estimator.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
adapter.py refactor: simplify post-WP-0002 cleanup 2026-04-01 22:30:00 +00:00
claude_code.py Prefer JSON-bearing envelope fields, skip metadata, in Claude CLI unwrap 2026-06-02 12:44:25 +02:00
cli.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
config.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
costs.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
embedding_adapter.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
embedding_cache.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
embedding_factory.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
embedding_openai.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
exceptions.py refactor: simplify post-WP-0002 cleanup 2026-04-01 22:30:00 +00:00
factory.py feat: WP-0003 — RoutingPolicy (FR-2) and HTTP serve mode (FR-1) 2026-04-01 22:34:00 +00:00
gemini.py refactor: simplify post-WP-0002 cleanup 2026-04-01 22:30:00 +00:00
grading.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
models.py refactor: simplify post-WP-0002 cleanup 2026-04-01 22:30:00 +00:00
openai.py refactor: simplify post-WP-0002 cleanup 2026-04-01 22:30:00 +00:00
openrouter.py Translate json_schema and drop non-OpenAI fields in OpenRouter adapter 2026-06-02 14:15:24 +02:00
problem_classes.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
quality.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
rates.py Implement-LLM-WP-0005-cost-model-estimators 2026-05-19 05:02:20 +02:00
routing.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
server.py Preserve llm-connect run config in server mode 2026-05-19 20:55:02 +02:00
shadowing.py Add adaptive cost-quality routing primitives 2026-05-17 21:32:27 +02:00
similarity.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00
toml_config.py feat: initial llm-connect package scaffold 2026-02-27 07:54:42 +01:00