Skip to content

fix: explicit max_completion_tokens on OpenRouter chat calls - #172

Merged
fazpu merged 1 commit into
mainfrom
fix/openrouter-max-tokens
Jul 29, 2026
Merged

fix: explicit max_completion_tokens on OpenRouter chat calls#172
fazpu merged 1 commit into
mainfrom
fix/openrouter-max-tokens

Conversation

@fazpu

@fazpu fazpu commented Jul 29, 2026

Copy link
Copy Markdown
Member

Urgent production fix from the GLM-5.2 smoke: the adapter sent no max_tokens, so reasoning models burned the provider's default completion cap on reasoning — observed finish_reason='length', content=null, reasoning_present=True, and mid-string-truncated JSON (constant-length non-JSON content) dead-lettering E2 on hard chunks.

OpenRouterSettings.max_completion_tokens (env REMEMBERSTACK_OPENROUTER_MAX_COMPLETION_TOKENS, default 32000, empty string = default, None omits the key) now rides every chat payload as max_tokens; forwarded in compose, documented in .env.example, exposed in readiness bindings, and recorded as a dated §2.4 observation. Provider account caps remain the monetary boundary.

Review: Grok APPROVE (4 NITs, none blocking — noted for follow-up: a third positive-override param case, the deprecated wire-key name, no env spelling for omit). Final review by Claude. Fast gate local; the full matrix is CI's.

@fazpu
fazpu enabled auto-merge (squash) July 29, 2026 12:29
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/rememberstack/adapters
  openrouter.py
Project Total  

This report was generated by python-coverage-comment-action

@fazpu
fazpu merged commit 8ac4878 into main Jul 29, 2026
6 checks passed
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.

1 participant