Files
llm-connect/llm_connect
tegwick cd4551c575
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
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
..