Skip to content

Fix custom Claude-compatible request timeout and context window settings - #1458

Draft
baron wants to merge 2 commits into
mainfrom
fix/1019-cc-custom-timeout-context-window
Draft

baron wants to merge 2 commits into
mainfrom
fix/1019-cc-custom-timeout-context-window

Conversation

@baron

@baron baron commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1019.

Custom Claude-compatible backends could not declare a request timeout or context window: environment generation only emitted API_TIMEOUT_MS and CLAUDE_CODE_AUTO_COMPACT_WINDOW inside the Z.ai special case, and persisted backend configuration had no override fields.

  • Add optional per-backend requestTimeoutMilliseconds and contextWindowTokens fields to persisted app configuration and provider DTOs, preserving legacy decoding.
  • Retain overrides through normalization, slot overrides, persistence, and bridge conversion; validate shared numeric bounds and avoid emitting invalid values.
  • Expose both fields in custom-backend settings, with inline invalid-input feedback. Blank values retain Claude Code defaults; existing Z.ai model-specific defaults and Moonshot behavior remain unchanged.
  • Emit CLAUDE_CODE_MAX_CONTEXT_TOKENS for explicit context-window overrides (not the auto-compaction threshold), and use the configured window as the app accounting fallback when no provider-reported window is available.
  • Keep credentials in the existing secure-storage path; no new secret logging.

Relevance / overlap

Issue #1019 is open with no comments and remains reproducible on base ab84d47e6. PR #356 concerns custom-backend launch isolation/model selection and an execution-location popover crash; it does not add these configuration fields or overrides.

Validation

All builds/tests used the worktree's coordinated daemon.

  • Fail first: make dev-provider-test FILTER=ClaudeCompatibleRuntimeSupportTests/testCustomBackendPersistsAndAppliesRequestLimits — 1 test, 4 expected assertion failures before implementation.
  • make dev-provider-test — 21 tests passed.
  • make dev-test FILTER=ClaudeCompatiblePluginBridgeTests — 10 tests passed, including the new store/bridge/legacy-decode regression.
  • make dev-swift-build PRODUCT=RepoPrompt — passed (existing unrelated warnings remain).
  • Changed-files-only SwiftFormat; pinned SwiftFormat 0.61.1 check passed.
  • make dev-lint — passed with pinned SwiftFormat 0.61.1 and strict SwiftLint. Initial attempt stopped because only system SwiftFormat 0.63.1 was available; installed the repository-pinned tool and reran successfully.
  • .agents/skills/rpce-contribution-check/scripts/preflight.sh commit and push — passed, including redacted secret scans and repository guardrails.
  • Static Oracle review — no material findings.

Not run: full root test suite, pr-ready, release/package validation, or live UI/provider/MCP smoke. No app was launched, relaunched, or stopped. Draft pending independent adversarial review.

Adversarial review follow-up

  • Verified the official model configuration docs: CLAUDE_CODE_AUTO_COMPACT_WINDOW changes the compaction threshold and cannot raise the assumed model window. Explicit overrides now emit CLAUDE_CODE_MAX_CONTEXT_TOKENS; existing GLM preset auto-compaction behavior stays unchanged. The UI warns about [1m], bare claude- names, and recognized-model semantics; no compaction-disabling flags are added.
  • Added adapter/sidebar and estimator coverage: a 262,144-token configured fallback accepts 250K usage, while a provider-reported window wins and survives later window-less events. Provider environment tests also cover a 32K window without an auto-compact threshold.
  • Shared validation bounds: RepoPrompt timeouts are 1000–2147483647 ms (one-second product minimum to catch seconds-as-ms mistakes; upstream maximum documented in environment variables). Context overrides accept 1–2147483647 tokens as a local numeric bound, with advisory UI warnings outside the typical 4K–1M range, not a claimed upstream MAX_CONTEXT cap.
  • UI states the default timeout (600000 ms / 10 min), default for unknown model IDs (200K), units, and that one backend window applies to all three slots. 600 is rejected with guidance to enter 600000 for ten minutes.
  • Removed default nil arguments from the public provider config initializer so construction sites must explicitly account for both overrides.
  • Expected integration conflict: open PR Fix custom Claude-compatible backend isolation and execution-location popover crash #356 edits the same environment(...) builder in ClaudeCompatibleRuntimeSupport.swift and the same runtime test file. Expect a rebase conflict/adjacent-hunk reconciliation; preserve both launch-isolation behavior and these explicit limits when integrating.

Follow-up validation (conductor-only):

  • make dev-provider-test: 21 passed (ticket f517ee3a).
  • make dev-test FILTER=ClaudeCompatiblePluginBridgeTests: 10 passed (final ticket 176b4190). An intermediate run failed linking with framework Sparkle not found; the subsequent app build and test retry passed without source changes.
  • make dev-swift-build PRODUCT=RepoPrompt: passed (ticket d6d1a3b6).
  • make dev-lint: passed (final ticket 870b2d70); changed files formatted with pinned SwiftFormat 0.61.1.
  • Commit and push preflights passed, including secret scans and guardrails.
  • Full root suite, live smoke, packaging/release validation, and visible app lifecycle operations remain not run.

@baron baron left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 39355a06a275137f580bf00b4e593b21bd950bc5 against its merge base.

No actionable correctness defect identified in the limit plumbing. I checked optional Codable compatibility, host/provider bounds, persistence through normalization and slot overrides, launch-environment construction, and the usage estimator's precedence for provider-reported windows. The controls retain invalid edits locally rather than persisting them, and the tests distinguish the configured context capacity from an auto-compaction threshold.

This branch is currently reported non-mergeable against main, and its observed CI run remains queued (https://github.com/repoprompt/repoprompt-ce/actions/runs/39879288536). Resolve the conflict and revalidate the resulting head; a green run of the pre-resolution tree would not cover that integration. Review was static source/test inspection only; I did not launch Claude Code or run native macOS tests.

This branch has not been deployed

No deployments
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.

Custom Claude-compatible backends cannot set API_TIMEOUT_MS or a context window (both hardcoded to glmZAI)

1 participant