Repository navigation
feat(omp): pin OpenRouter upstreams per thread - #11
Merged
Merged
Conversation
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
force-pushed
the
feat/omp-openrouter-upstream-pin
branch
from
October 27, 2026 20:30
e7fd672 to
b794335
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ymlor config, and nothing isadded to prompts.
OmpSettings.openrouterUpstreamslists the OpenRouter provider slugs you wantavailable (comma-separated, e.g.
deepinfra, cerebras). Empty means the feature is entirely off:no extension is generated, loaded, or hooked.
Auto. The selection is stored with the thread, so every client, delegated task, and resumedsession sees the same pin.
(
<upstream>+<provider>/<id>) under<stateDir>/omp-openrouter-routing/pins/. A small extensionTx Code generates in that directory and loads with
omp acp -erewritesprovider.onlyforrequests 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.
the artifacts disables routing instead of breaking the OMP provider.
Verification
vp run check:changedon the branch: format, lint, knip, graphql, typecheck (30 packages), and the6 test files beside the changes pass.
omp acpplus the generated extension against a localOpenRouter mock;
session/new→ pin file →session/promptcapturedPOST /api/v1/responseswithprovider: {"only": ["deepinfra"]}and the real model id. Same pass with--no-extensionson theCLI, and a second turn after rewriting the pin used the new upstream without a restart.
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, orauto-discovering each model's endpoints. Those need more of OpenRouter's
providerobject than OMPmodels today, and endpoint discovery would add a network path to provider snapshots.