Skip to content

feat(omp): pin OpenRouter upstreams per thread - #11

Merged
Coriou merged 6 commits into
mainfrom
feat/omp-openrouter-upstream-pin
Oct 27, 2026
Merged

Coriou merged 6 commits into
mainfrom
feat/omp-openrouter-upstream-pin

Conversation

@Coriou

@Coriou Coriou commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Problem

OpenRouter can serve one model from several upstream providers that differ in price, quantization,
latency, and context limit, and Oh My Pi's ACP surface only exposes mode/model/thinking
(can1357/oh-my-pi#14876 tracks first-class upstream selection upstream). So every Tx Code thread got
OpenRouter's default routing, with no way to pin a model to the upstream you actually want.

Fix

Fork-local, OMP only. Tx Code never reads or writes OMP's models.yml or config, and nothing is
added to prompts.

  • Setting. OmpSettings.openrouterUpstreams lists the OpenRouter provider slugs you want
    available (comma-separated, e.g. deepinfra, cerebras). Empty means the feature is entirely off:
    no extension is generated, loaded, or hooked.
  • Picker. OMP OpenRouter models gain an Upstream control beside Thinking, defaulting to
    Auto. The selection is stored with the thread, so every client, delegated task, and resumed
    session sees the same pin.
  • Delivery. The adapter writes a two-line pin per ACP session
    (<upstream> + <provider>/<id>) under <stateDir>/omp-openrouter-routing/pins/. A small extension
    Tx Code generates in that directory and loads with omp acp -e rewrites provider.only for
    requests whose model matches the pin — compaction, handoff, and advisor requests for other models
    are untouched. A slug removed from settings stops pinning instead of silently disagreeing with the
    picker. Text generation honours the same selection.
  • A failed pin write logs a warning rather than failing the turn; a state directory that cannot hold
    the artifacts disables routing instead of breaking the OMP provider.

Verification

  • vp run check:changed on the branch: format, lint, knip, graphql, typecheck (30 packages), and the
    6 test files beside the changes pass.
  • Offline end-to-end with OMP 18.12.6: real omp acp plus the generated extension against a local
    OpenRouter mock; session/new → pin file → session/prompt captured POST /api/v1/responses with
    provider: {"only": ["deepinfra"]} and the real model id. Same pass with --no-extensions on the
    CLI, and a second turn after rewriting the pin used the new upstream without a restart.
  • Adversarial reviews: OMP GLM 5.3 Flash (max) on the research plan; Claude Opus 5.5 (Claude Code,
    effort medium) twice on the implementation. Round 1 (PASS WITH FIXES) found the model-scoping,
    opt-in gating, and pin/label problems; round 2 returned PASS with no blockers, and its two optional
    follow-ups (guards covered by tests, text-generation pins cleaned up) are in this branch.

Not in scope: routing strategy (:nitro/:floor/sort), per-provider ZDR/fallback preferences, or
auto-discovering each model's endpoints. Those need more of OpenRouter's provider object than OMP
models today, and endpoint discovery would add a network path to provider snapshots.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 27, 2026
OpenRouter serves one model from several upstream providers that differ in price, quantization,
latency, and context limits, and OMP has no ACP surface to choose one, so every Tx Code thread got
OpenRouter's default routing.

OMP models now carry an "Upstream" option when the instance lists OpenRouter provider slugs, and the
selection is stored with the thread. The adapter writes it to a per-session pin file, and a generated
OMP extension loaded with `-e` rewrites the outgoing request's `provider.only` from that file.
Review round 1 findings.

- The generated extension now pins only the model the thread chose, read from a
  two-line pin file, so compaction, handoff, and advisor requests for other
  OpenRouter models keep OpenRouter's routing instead of failing on a hard
  `only` restriction.
- Routing is built and injected only when the instance lists upstreams, and a
  state dir that cannot hold the artifacts disables the feature instead of
  failing the whole OMP provider.
- A stored pin whose slug is no longer configured is dropped, so the picker's
  "Auto" label cannot disagree with the wire.
- Text generation honours the selection through the same extension.
- The docs describe the next-message timing and the no-fallback behaviour, and
  the unrelated formatter churn is gone.
Review round 2 follow-ups.

- A pinned text-generation call removes its pin when the call's scope ends,
  instead of leaving one file per commit message or title.
- `resolvePinnedUpstream` names the "stored slug must still be configured"
  rule and is covered, as is the spawn staying untouched when routing is off.
@Coriou
Coriou force-pushed the feat/omp-openrouter-upstream-pin branch from e7fd672 to b794335 Compare October 27, 2026 20:30
@Coriou
Coriou merged commit a94f859 into main Oct 27, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant