Skip to content

fix(llm): route OpenRouter structured-output calls only to upstreams that support response_format - #5304

Merged
nicoloboschi merged 3 commits into
mainfrom
fix/openrouter-require-parameters-3494
Oct 6, 2026
Merged

nicoloboschi merged 3 commits into
mainfrom
fix/openrouter-require-parameters-3494

Conversation

@nicoloboschi

Copy link
Copy Markdown
Collaborator

Fixes #3494.

OpenRouter spreads one model across several upstreams. Some don't support response_format and reply with empty content and finish_reason=stop. That matches the issue: errors only on retain_extract_facts and consolidation (the JSON-format scopes), none on reflect. Consolidation sends no output-token cap, so the 64k-cap theory in the issue doesn't explain it.

Change: on structured-output calls to OpenRouter (the openrouter provider, or openai with an openrouter.ai base URL), send provider.require_parameters=true. Any provider keys set in HINDSIGHT_API_LLM_EXTRA_BODY are kept and take precedence. Free-text and tool calls are unchanged.

Note: retain was not silently losing facts. A chunk that fails extraction fails the whole operation, which the worker retries.

Tests: tests/test_openrouter_require_parameters.py.

…that support response_format (#3494)

OpenRouter load-balances one model across upstreams. An upstream without
response_format support can answer extraction/consolidation calls with empty
content and finish_reason=stop. Send provider.require_parameters=true on
structured-output calls (openrouter provider, or openai pointed at
openrouter.ai), keeping any operator-set provider routing keys.
@nicoloboschi
nicoloboschi force-pushed the fix/openrouter-require-parameters-3494 branch from 1c4f45d to 3fd56f0 Compare October 6, 2026 14:02
@nicoloboschi
nicoloboschi merged commit f1783fa into main Oct 6, 2026
115 of 117 checks passed
@nicoloboschi
nicoloboschi deleted the fix/openrouter-require-parameters-3494 branch October 6, 2026 15:09
This was referenced Oct 6, 2026
@nicoloboschi nicoloboschi mentioned this pull request Nov 3, 2026
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.

retain/consolidation via OpenRouter (z-ai/glm-5.2): intermittent empty message content with finish_reason=stop — silent fact loss

1 participant