Skip to content

fix(providers): send Console Go's session header from the dialect probe - #101

Merged
imateusdev merged 2 commits into
mainfrom
fix/opencode-go-probe-session
Sep 15, 2026
Merged

imateusdev merged 2 commits into
mainfrom
fix/opencode-go-probe-session

Conversation

@imateusdev

Copy link
Copy Markdown
Owner

Checking a model on the OpenCode Go card ticked the box and then unticked it on its own, with nothing shown in the UI and nothing logged at the default level.

Console Go rejects every request arriving without x-opencode-session with a 400 and MissingSessionID, whatever the dialect. toggle_model refuses to enable a model until it has probed which of the three wires it speaks, and reads any non-2xx as "not this wire", so with no header it concluded no Go model spoke any of them and failed. The frontend then rolled back to backend truth, which is the box unticking itself.

#89 propagated the header along the routed path, where it comes from the client turn. The probe has no client turn behind it, so it generates one; the gateway accepts a generated id, since it is a routing hint rather than a credential. The provider-scoped check now lives in a single helper next to the routed path's own use so the two cannot drift.

Validation

  • Measured against the live gateway, same key and model, header the only variable: chat/completions 400 -> 200, messages 400 -> 200.
  • New unit test asserts the probe carries one id across all three dialect attempts for opencode-go and none for other providers. Confirmed it fails without the fix (got [None, None, None]).
  • New live smoke test pins both halves of the upstream contract, self-skipping without LOOM_ROUTER_OPENCODE_GO_API_KEY. PASS with real credentials.
  • Ran the real probe_model_dialect against the live gateway for four models that were stuck disabled (kimi-k3, glm-5.2, minimax-m3, qwen3.8-max): all resolve now, all failed before.
  • cargo test: PASS (482 + 21 + 3 + 1)
  • cargo clippy -D warnings: PASS
  • cargo fmt --check: PASS
  • bun run lint: PASS
  • bun run test: PASS (168 tests)
  • bun run build: PASS

Enabling any OpenCode Go model ticked the checkbox and then unticked it on
its own. Nothing reached the UI and nothing was logged at the default
level, so the only visible symptom was a control that would not stay on.

Console Go answers every request arriving without `x-opencode-session`
with a 400 and `MissingSessionID`, whatever the dialect. `toggle_model`
will not enable a model until it has probed which of the three wires that
model speaks, and it reads any non-2xx as "not this wire" - so with no
header it concluded that no Go model spoke any of them, returned an error,
and the frontend rolled back to backend truth. Measured against the live
gateway: 400/400/401 without the header, 200/200 with it.

The header was already propagated along the routed path (#89), where it is
forwarded from the client turn. The probe has no client turn behind it and
has to generate one, which the gateway accepts: it is a routing hint, not a
credential and not a reference to state the gateway already holds.

The provider-scoped check now lives in one helper next to the routed path's
own use, so the two cannot drift on which providers get the header. Other
upstreams reject unknown headers, so the scoping is part of the contract.

The live smoke test pins both halves of the upstream behaviour this rests
on. If Go stops requiring the header the fix is merely redundant, but if it
starts demanding more than a generated id the probe breaks the same silent
way, and that is worth failing loudly for.
…ing in silence

A refused toggle had three layers of silence stacked on it. The catch block
discarded the error, the app has no toast to have shown it in, and the only
record of the reason was a debug line under a default filter of
`loom_router=info`, so it was never written either. What the user saw was a
switch that would not stay on.

The probe now keeps why each dialect turned the model away and puts all
three in the error it returns, with the upstream's own sentence where the
body carries one: Console Go names the missing session header there, and a
quota failure says so in the body while its status could be either. The
aggregate is logged at warn, since a single rejection is ordinary - most
models speak one wire and refuse the other two - and only the whole set
failing is the outcome that blocks anyone.

The page keeps rolling the switch back, because the model really is not
enabled and leaving it on would show the one state that is never true. It
now shows the reason next to the model list, using the same treatment the
catalogue error beside it already had, and clears it when a later toggle
succeeds.
@imateusdev

Copy link
Copy Markdown
Owner Author

Pushed the two follow-ups discussed on top of the header fix.

Diagnostics. probe_model_dialect now keeps why each dialect rejected the model and returns all three, carrying the upstream's own message where the body has one. Against the live gateway:

no upstream wire dialect accepted model 'modelo-que-nao-existe'
(chat/completions 401: Model modelo-que-nao-existe is not supported;
 messages 401: ...; responses 401: ...)

The aggregate is logged at warn so it survives the default loom_router=info filter. The per-dialect lines stay at debug: a single rejection is ordinary, since most models speak one wire and refuse the other two, and raising those would bury the case that matters.

UI. The page still rolls the switch back, because the model really is not enabled and leaving it on would show the one state that is never true. It now prints the reason beside the model list, reusing the treatment the catalogue error there already had, and clears it on the next successful toggle. New string in all four locales.

Validation

  • 2 new frontend tests: the reason reaches the screen and the switch ends up off, and a later success clears it. Confirmed both fail against the old silent-catch behaviour.
  • 2 new backend tests for the rejection summarizer: prefers the upstream message across the shapes gateways use, falls back to raw text, stays short enough for a 340px card.
  • Error text measured against the live gateway, not constructed by hand.
  • cargo test: PASS (484 + 21 + 3 + 1), clippy -D warnings: PASS, fmt: PASS
  • bun run test: PASS (170), lint: PASS, build: PASS

@imateusdev
imateusdev merged commit ba8f3bf into main Sep 15, 2026
2 checks passed
@imateusdev
imateusdev deleted the fix/opencode-go-probe-session branch September 15, 2026 18:45
imateusdev added a commit to sargita92/loom-router that referenced this pull request Sep 15, 2026
…e for side calls

Review follow-up on the rebase against main, which had gained
`apply_opencode_session` from imateusdev#101. Keeping both helpers left two functions
with near-identical names running the same provider-id check and setting the
same header, which is what this change set out to avoid in the first place.

`apply_opencode_session` is now the only place that knows Console Go is
special. The two wrappers differ in where they get an id, never in that rule:
`apply_provider_session` forwards the client's on a routed turn, and
`apply_side_call_session` forwards it or mints one.

The split is the point. A routed turn belongs to a session the client owns,
so minting there would hand the gateway a new session on every request and
lose whatever affinity it keeps across a conversation. A side call belongs to
no conversation, and sending nothing is not a degraded mode: Console Go
rejects the request outright, and because a failed visual preparation returns
Err from dispatch_routed, that aborts the entire turn it was enriching rather
than skipping the enrichment. A client that sends none of the three accepted
header names would have hit exactly that.

Also repairs the em dashes in proxy.rs and upstream.rs, which the conflict
resolution mangled by reading the files back under the Windows locale
instead of UTF-8.
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.

1 participant