oracle icon indicating copy to clipboard operation
oracle copied to clipboard

Feature: user-config per-model overrides (apiModel + reasoning effort) for custom OpenAI-compatible --base-url endpoints

Open wangwllu opened this issue 5 months ago • 1 comments

Summary

When running against a custom OpenAI-compatible gateway via --base-url / apiBaseUrl (e.g. a LiteLLM proxy or a self-hosted gateway), there is currently no supported way to override a model's apiModel (the on-wire model id) and reasoning effort from user config. The only way to make such an endpoint work correctly is to hand-edit the bundled MODEL_CONFIGS in the published package — which is wiped on every reinstall/upgrade.

This is a gap specifically for the --base-url path that the CLI already advertises ("Override the OpenAI-compatible base URL for API runs (e.g. LiteLLM proxy endpoint)").

Motivation / real-world setup

Many OpenAI-compatible gateways rename model ids in their catalog. For example, a gateway may expose gpt-5.5 as gpt-5.5-mygateway (vendor suffix), and the model may require a non-default reasoning.effort (e.g. high/xhigh) to think hard.

Two things break today:

  1. Passing the gateway's renamed id directly (-m gpt-5.5-mygateway) hits the generic synthesized config in resolveModelConfig (src/oracle/modelResolver.ts), which sets reasoning: null, inputLimit: 200_000, and a GPT-5-pro tokenizer. So reasoning effort is silently dropped, the context limit is wrong, and token estimates are off.
  2. Passing the canonical id (-m gpt-5.5) preserves reasoning/tokenizer/inputLimit from MODEL_CONFIGS, but then the request is sent with the bundled apiModel (model: modelConfig.apiModel ?? modelConfig.model in src/oracle/request.ts), which the gateway doesn't recognize.

There is no way to get both the renamed apiModel and the correct reasoning/metadata without editing bundled code.

Why user config can't do it today

  • User config (~/.oracle/config.json, src/config.ts) accepts engine, model, apiBaseUrl, search, maxFileSizeBytes, notify, heartbeatSeconds, filesReport, background, promptSuffix, and a browser{} block. There is no per-model override field.
  • Project config is sanitized to a fixed allowlist (sanitizeProjectConfig in src/config.ts) that intentionally excludes model routing — good, that should stay.
  • resolveModelConfig already composes config from multiple sources: known MODEL_CONFIGS, OpenRouter catalog enrichment (isOpenRouterBaseUrl path), and a generic fallback. A user-config override layer would be a natural additional source, mirroring how OpenRouter enrichment already augments/overrides fields like apiModel, inputLimit, and pricing.

Proposed solution

Allow a modelOverrides map in user config only (not project config, for safety) that merges over known MODEL_CONFIGS entries inside resolveModelConfig:

{
  "apiBaseUrl": "https://my-gateway.example/v1",
  "model": "gpt-5.5",
  "modelOverrides": {
    "gpt-5.5": {
      "apiModel": "gpt-5.5-mygateway",
      "reasoning": { "effort": "xhigh" },
      "inputLimit": 1050000,
      "pricing": { "inputPerToken": 0.000005, "outputPerToken": 0.00003 }
    }
  }
}

Then oracle -m gpt-5.5 (or model in config) routes to the gateway's id while keeping correct reasoning/tokenizer/limits.

Suggested scope for a first PR (intentionally tight)

  • User config only (skip project config — keeps the existing sanitize allowlist boundary intact).
  • Override existing known model keys only (inherit tokenizer from MODEL_CONFIGS — avoids the "JSON can't express a tokenizer function" problem). New custom aliases / tokenizer selection / extends inheritance can be a follow-up.
  • Whitelist a small set of overridable fields: apiModel, reasoning, inputLimit, pricing.
  • Apply the override as the last layer in resolveModelConfig.
  • Support reasoning: null to explicitly clear a known model's effort (don't blind deep-merge in a way that prevents clearing).
  • No new CLI flags in the first cut (a per-model map avoids the multi-model ambiguity that --api-model would have with --models a,b).

Risks / open questions

  • Provider-specific reasoning shape: reasoning is forwarded as-is to the request body (src/oracle/request.ts); a malformed override could be rejected by some providers. Could validate the minimal { effort: low|medium|high|xhigh } shape and document arbitrary objects as advanced/OpenAI-compatible-only.
  • Field validation: inputLimit/pricing should be finite, non-negative numbers.
  • OpenRouter interaction: decide ordering — explicit user overrides probably apply last, after catalog enrichment.

Happy to send a PR along these lines if the design/naming (modelOverrides, user-config-only, known-key overrides) sounds right. Wanted to confirm the shape before implementing.

Environment: oracle 0.15.0 (npm @steipete/oracle), API engine, custom OpenAI-compatible --base-url.

wangwllu avatar Jun 25 '26 01:06 wangwllu

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 30, 2026, 9:25 AM ET / 13:25 UTC.

Summary Keep open: current main and v0.15.0 still lack the requested user-config per-model override layer, and https://github.com/steipete/oracle/pull/274 is the open implementation candidate that should be reviewed before this issue closes.

Reproducibility: yes. from source inspection: current main has no modelOverrides field, no user override input in resolveModelConfig, and the custom-base-url chat/completions adapter does not forward reasoning_effort. I did not run a live gateway reproduction because this is a read-only issue review and the linked PR already provides redacted real-gateway proof for the proposed fix.

Root-cause cluster Relationship: canonical Canonical: https://github.com/steipete/oracle/issues/273 Summary: This issue is the canonical request for user-config per-model overrides, and the linked open PR is its implementation candidate.

Members:

  • fixed_by_candidate: https://github.com/steipete/oracle/pull/274 - The PR uses closing syntax for this issue and implements the requested modelOverrides capability for the custom gateway path.

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Next step Do not queue a second fix PR because https://github.com/steipete/oracle/pull/274 is already open and the remaining blocker is maintainer approval of the provider-routing config API.

Review details

Best possible solution:

Review and either land or deliberately revise https://github.com/steipete/oracle/pull/274 so user config can remap known models for custom gateways without allowing project configs to reroute traffic.

Do we have a high-confidence way to reproduce the issue?

Yes, from source inspection: current main has no modelOverrides field, no user override input in resolveModelConfig, and the custom-base-url chat/completions adapter does not forward reasoning_effort. I did not run a live gateway reproduction because this is a read-only issue review and the linked PR already provides redacted real-gateway proof for the proposed fix.

Is this the best way to solve the issue?

Unclear pending maintainer product review: the linked PR's user-config-only, known-model-only map is a narrow technical solution, but it still adds a provider-routing configuration API that maintainers need to accept.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The public API shape still needs maintainer approval because it adds a persistent user config field that can affect provider routing and model metadata.
  • The linked implementation PR is still open, so closing this issue before merge would break the normal issue-to-PR tracking path.

Codex review notes: model internal, reasoning high; reviewed against 2fa6b5a6ed92.

Label changes

Label changes:

  • remove clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label.

Label justifications:

  • P2: The request affects custom OpenAI-compatible provider routing but is a bounded feature/config improvement rather than an urgent regression.
  • impact:auth-provider: The issue is about provider/model routing for custom OpenAI-compatible base URLs and on-wire model selection.
Evidence reviewed

What I checked:

  • AGENTS.md read: Read the full 30-line repository AGENTS.md and applied its Oracle-specific release, proof, and live-smoke guidance to this read-only review. (AGENTS.md:1, 2fa6b5a6ed92)
  • No vision or maturity files in checkout: The checkout contains AGENTS.md but no VISION.md, taxonomy.yaml, qa/maturity-scores.yaml, or docs/maturity files; the maturity helper also failed because its local yaml dependency was unavailable, so no stable maturity label was selected.
  • Current user config lacks override field: UserConfig currently exposes model and apiBaseUrl but no modelOverrides or equivalent per-model routing override. (src/config.ts:86, 2fa6b5a6ed92)
  • Project config boundary excludes provider routing: sanitizeProjectConfig allowlists safe project defaults and still excludes apiBaseUrl and any per-model model-routing override, matching the issue's user-config-only safety boundary. (src/config.ts:253, 2fa6b5a6ed92)
  • Resolver has no user override layer: resolveModelConfig accepts only base URL, OpenRouter API key, and fetcher options, then returns known, OpenRouter-enriched, or synthesized configs without user override input. (src/oracle/modelResolver.ts:153, 2fa6b5a6ed92)
  • Custom chat adapter drops reasoning effort today: The OpenAI-compatible chat/completions adapter builds requests with model, messages, and max_tokens, but no reasoning_effort, so custom-base-url runs cannot carry the known model's effort through this path. (src/oracle/client.ts:180, 2fa6b5a6ed92)

Likely related people:

  • steipete: Current-main blame attributes the relevant config, resolver, and adapter lines to the v0.15.0 release commit, and GitHub path history shows repeated OpenRouter/model-routing work by steipete. (role: recent resolver/provider-routing contributor; confidence: high; commits: 14c146a453b5, 044b8437a913, 81c38b696dc9; files: src/config.ts, src/oracle/modelResolver.ts, src/oracle/client.ts)
  • thesobercoder: GitHub path history shows custom base-url and OpenRouter chat/completions routing work in the adapter path affected by this issue. (role: adjacent custom-base-url contributor; confidence: medium; commits: 188ac5729710, b51a347ad264; files: src/oracle/client.ts)
  • marmotize: GitHub history shows the project config layering and restriction work that is directly relevant to keeping provider/model routing overrides user-config-only. (role: config boundary contributor; confidence: medium; commits: 3ae0df0db0fa; files: src/config.ts, docs/configuration.md, src/cli/runOptions.ts)
  • devYRPauli: GitHub history shows a recent resolveModelConfig pricing and catalog-enrichment fix adjacent to the requested override ordering and model metadata behavior. (role: recent resolver contributor; confidence: medium; commits: 4367396a0d31; files: src/oracle/modelResolver.ts, tests/openrouter.test.ts)
  • wangwllu: The issue author also opened the linked implementation PR that threads modelOverrides through the affected config, resolver, client, and run-option paths. (role: linked implementation contributor; confidence: high; commits: c8159253e8bc, c6e8d4b4730a; files: src/config.ts, src/oracle/modelResolver.ts, src/oracle/client.ts)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar Jun 25 '26 01:06 clawsweeper[bot]