Skip to content

Let a custom endpoint answer past 4,096 tokens — every model added as 'Another OpenAI-compatible service' is hard-capped at 32–94× under the free allowance today, and nothing shows or lifts the ceiling #199

Closed

Description

@bencode

Problem

Every model on a reader-added "Another OpenAI-compatible service…" endpoint is built by customModel, which pins maxTokens: 4_096 (ui-packages/web/src/core/models/byok/runtime.ts:42-56). The agent passes no maxTokens of its own (ui-packages/web/src/core/agent/definition.ts:31-38), so pi-ai falls back to the model's number (options?.maxTokens ?? model.maxTokens, and contextWindow: 0 — "unknown" — returns it unclamped), and every request carries a 4,096-token output cap.

So a reader who brought a key for a vendor outside the eight presets (Qwen's compatible mode, MiniMax, SiliconFlow, an ollama or LM Studio endpoint, a company relay) gets answers cut mid-sentence at 4,096 tokens — 32× under GLM's 131,072 and 94× under DeepSeek's 384,000, the ceilings the same conversation runs under on the free allowance or any preset (pi's catalog data). The only symptom is the notice "The response reached its output limit." (ui-packages/web/src/features/conversation/use-conversation/messages.ts:74-75), and nothing anywhere raises it: the provider dialog holds name, address, key and models only (ui-packages/web/src/features/settings/model-providers/index.tsx:29-45). Regenerating (#42) hits the same wall.

The same number breaks the repair path for long conversations: a compaction summary is clamped to model.maxTokens, and a cut summary throws "The summary reached its output limit and was not saved." (ui-packages/web/src/features/assistant/compaction.ts:101-111) — on a custom endpoint an entire conversation must summarize inside 4,096 tokens or compaction fails outright.

PRODUCT.md keeps the own-key path "open, not hidden"; a silent 32–94× output handicap that only that path carries is neither.

Proposal

  • Stop pinning every custom model at 4,096: send a generous ceiling, or none where the endpoint derives one from the model, so a reply ends when it ends.
  • Keep contextWindow: 0 as today — unknown stays unknown; the change is about the ceiling sent, not a guessed window.
  • If a number must be kept, show it next to the model in the provider dialog and let the reader raise it; a hidden constant plus a one-line notice is the state to remove.
  • Compaction and the length notice keep following whatever ceiling the model then carries.

Goal

After this, a reader asking their own OpenAI-compatible endpoint for a long comparison or a full-document summary gets the whole answer: replies through a custom endpoint are no longer stopped at 4,096 output tokens, and a compaction summary on such a model no longer fails merely because the conversation is long.

Verification

test -z "$(grep -n 'maxTokens: 4_096' ui-packages/web/src/core/models/byok/runtime.ts)"
pnpm --filter @gamma-reader/web test --silent
pnpm check

Refs

Activity

  1. added
    enhancement
    source:scheduled
    on Oct 23, 2026
  2. bencode commented on Oct 23, 2026

    @bencode
    OwnerAuthor

    Independent review — posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Evidence audit (HEAD da3dfad): confirmed, every anchor exact. byok/runtime.ts:42-56 pins maxTokens: 4_096 with contextWindow: 0; agent/definition.ts:31-38 (streamFn) passes no maxTokens; pi-ai dist/api/simple-options.js:23 is options?.maxTokens ?? model.maxTokens and :5-10 returns it unclamped when contextWindow <= 0 — all verified in the vendored package. Catalog numbers check out (glm-5.3 = 131,072; deepseek-flash / v4-pro = 384,000 → 32× / 94×). The symptom notice (messages.ts:74-75), the ceiling-less provider dialog (index.tsx:29-45), and the compaction clamp + failure (compaction.ts:101-111) are all as described. #70 closed, #159/#164/#174/#184 open as referenced.

    Duplicate check: none across open + closed titles.

    Sensor: lint ✓ · verify ✗ (expected — maxTokens: 4_096 still at runtime.ts:55).

    Sharpening:

    • Model.maxTokens is type-required (pi-ai/dist/types.d.ts:648) and per-request omission falls back to it, so "send none" isn't reachable through pi's options today — the realistic shapes are a generous finite ceiling or the reader-visible field. Worth stating in the proposal so implementation doesn't chase an impossible branch.
    • The first verification command (! grep "maxTokens: 4_096") passes on any rename even if a cap remains. Prefer an outcome anchor: a unit test on customModel asserting the built model's ceiling is either the generous default or a reader-configured value, and one on the compaction clamp following that ceiling.

    Valid; stays open.

  3. bencode commented on Oct 24, 2026

    @bencode
    OwnerAuthor

    Independent re-review — posted by the scheduled issue-reviewer loop, independent of the session that authored this issue. Audited against main@90b046f; last review stood at main@da3dfad.

    Drift check: 2 commits since the last review (93563a2 styles.css only, plus its merge) — no code drift. Anchors re-confirmed: core/models/byok/runtime.ts:42-56 — customModel with contextWindow: 0 and maxTokens: 4_096 at :55; core/agent/definition.ts:31-38 — streamFn passes no maxTokens; messages.ts:74-75 — the limit notice; compaction.ts:101-111 — the model.maxTokens clamp and the failed-summary throw.

    Sensor incident — verify reported ✓ spuriously; this issue is NOT implemented. Cause: the sensor runs the Verification block as a bash script under set -e, and a command whose status is inverted with ! neither triggers errexit nor survives as the script's exit status — the matching grep's failure was silently overwritten by the passing test/check commands after it. The cap stands at runtime.ts:55.

    Verification-block edit logged (only the fence's first line changed, per the review playbook):

    -! grep -rn "maxTokens: 4_096" ui-packages/web/src
    +test -z "$(grep -n 'maxTokens: 4_096' ui-packages/web/src/core/models/byok/runtime.ts)"

    Same intent, sensor-compatible, and scoped to the deliverable site (a repo-wide pattern would stay hostage to unrelated literals such as features/assistant/vision.ts:35's maxTokens: 4096). Re-lint ✓; verify now correctly ✗ on main.

    Duplicate check (open + closed titles): none.

    Sharpening carried (unchanged): pi-ai's Model.maxTokens is type-required and per-request omission falls back to it, so "send none" is not a reachable branch — the realistic shapes are a generous finite ceiling or a reader-visible field; prefer outcome anchors (a customModel ceiling test, the compaction clamp following it) over the string grep when implementing.

    Verdict: valid, keep open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsource:scheduled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions