Skip to content

feat(ai-summaries): add OpenAI-compatible provider - #159

Open
yashiels wants to merge 3 commits into
steipete:mainfrom
yashiels:agent/ai-summary-compatible-provider
Open

yashiels wants to merge 3 commits into
steipete:mainfrom
yashiels:agent/ai-summary-compatible-provider

Conversation

@yashiels

@yashiels yashiels commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #157

Depends on #158. This branch includes #158's commit, so review only the last two commits (feat(ai-summaries): add OpenAI-compatible provider and fix(ai-summaries): bind compatible API key to its base URL). Once #158 merges, this diff shrinks to those commits.

AI summaries could only reach api.openai.com and only with the three public OpenAI models. This adds an explicit OpenAI-compatible provider for self-hosted servers and gateways that implement the Responses API, such as LiteLLM. The OpenAI provider is unchanged, including its model list.

Behaviour

  • AISummarySettings gains provider (openai / openai-compatible), compatibleBaseURL and compatibleModel. All decode with decodeIfPresent, so older settings load unchanged. Unknown providers decode as openai. The OpenAI model field keeps its existing normalization.
  • AISummaryEndpoint resolves the destination. A compatible base URL must be HTTPS (plain HTTP only for localhost, 127.0.0.1 and [::1]) and must have no credentials, query or fragment. Trailing slashes are removed. A missing or invalid URL, or an empty model, throws before any request, so there is never a fallback to OpenAI.
  • The compatible provider has its own Keychain slot (openai-compatible-api-key), and the key is stored with the base URL it was saved for. If the base URL changes, that key is not used: status shows "Stored key belongs to a different base URL" and no request is sent until a key is saved for the new URL. Saving requires a valid base URL. The stored OpenAI key and OPENAI_API_KEY are never sent to a compatible endpoint. clearAllCredentials clears both slots.
  • Requests go through a task delegate that refuses redirects, so a 3xx response surfaces as an error.
  • The compatible provider omits reasoning.effort, which is OpenAI-specific. Error messages name the endpoint instead of OpenAI.
  • The Issue Navigator summary signature includes the provider, URL and model, so changing them refreshes cached summaries.
  • Settings: the AI Summaries section moved into AISummarySettingsSection, which keeps AdvancedSettingsView under 500 lines. It adds a provider picker, Base URL and Model fields (applied on Return or Test), and a key field for whichever provider is selected.
  • CLI: repobar settings set accepts ai-summary-provider, ai-summary-base-url and ai-summary-compatible-model, and validates them the same way. Documented in docs/cli.md alongside the existing ai-summaries and ai-summary-model keys.

Verification

  • New tests: endpoint resolution and URL validation, including lookalike loopback hosts and IPv6 loopback; settings round trip and legacy decoding; separate key storage; a compatible request that omits reasoning; zero requests when the URL is invalid, only an OpenAI key exists, or the stored key belongs to a different URL; the redirect delegate refusing redirects (tested directly); endpoint-named errors; and the CLI keys.
  • pnpm format, pnpm lint (pinned SwiftLint and SwiftFormat): clean. pnpm test: 95 CLI and 661 app tests passed. Run with core.hooksPath unset, because this machine's global git hooks reject the LocalGitService tests' throwaway commits. pnpm test:tooling: 24 passed. The iOS build-for-testing step from ci.yml: succeeded.
  • Live test against a LiteLLM gateway (/v1/responses, deepseek-flash) through the real URLSession path: both the connection test and a PR summary returned clean single sentences.
  • Built the app and walked through Settings → Advanced → AI Summaries. An http:// remote URL showed "Base URL must use HTTPS unless it points to localhost." and sent nothing. The HTTPS gateway URL with a typed (unsaved) key showed "Test passed: RepoBar AI summaries are ready. Typed key was not saved." The provider, cleaned-up URL and model persisted across relaunch.

Limits: compatible servers must implement POST {base}/responses; Chat Completions-only servers are not supported. Reasoning-heavy models can spend most of the 1024-token output budget before answering.

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 31, 2026

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

clawsweeper:intake:feature Preliminary submission classification; full source review pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support OpenAI-compatible endpoints for AI summaries

1 participant