Skip to content

fix(probe): give probes and the Playground bench their own identity - #162

Merged
jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
cheerc:fix/pinned-probe-identity
Oct 29, 2026
Merged

jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
cheerc:fix/pinned-probe-identity

Conversation

@cheerc

@cheerc cheerc commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Two identity paths that were never conversations stop presenting one:

  • internal/gateway/probe.go — the hourly free-model probe now sends a fresh canonical session and a random project id per probe instead of project = "opencode2api:default-project" plus session = CanonicalSessionID("availability:" + model).
  • internal/admin/debug.go — the Playground bench now sets x-opencode-session to a fresh canonical session per click.

Why

The free tier meters per project id × egress, and a pinned session reads as one continuous conversation. Both paths therefore reused a single bucket:

  • the probe's project id was shared by every deployment that ran the same probe, so a charged bucket on a popular exit made the probe answer 429 FreeUsageLimitError and cached the model unavailable for an hour while live traffic on the same process and egress succeeded;
  • the bench sent no session signal, so DeriveRequestIDs fell back to conversationSeed — system prompt plus first user turn. Replaying the same prompt on every click produced the same session forever.

Neither path benefits from reuse: the probe result is cached for the next interval, and a Playground click is one-shot. Canonical ids are forwarded verbatim, so the scope mixin does not apply and the id that goes out already has the shape the free tier accepts.

Verification

Temporary instance with the admin UI enabled, login → CSRF → POST /api/debug/inference with the same body each time, sessions read from the request_routed log line:

build clicks upstream session
before 3 ses_ea4eb1680ffe0B8cZBh0nKJ03A ×3
after 2 ses_eb2c888f1ffe4Y0DodMQdwvu6c, ses_ed8748efdffe2ez6IH352OdMpV

All clicks returned 200 on this exit both before and after — the bucket was not charged today, which is consistent with the report: the failure appears once the shared bucket is charged. Probes on this build measured 8/8 probe_succeeded with a freshly deleted availability cache, also 8/8-would-be before it, so this change is hardening for the case in the issue rather than a reproduction of it.

go build ./..., go vet ./..., go test ./... pass. Coverage: internal/gateway/probe_test.go pins fresh, complete and canonical probe identity; internal/admin/debug_test.go pins a fresh canonical session per bench click.

Notes

Closes #156.

The hourly free-model probe presented one pinned identity: project
"opencode2api:default-project" together with a session derived from the
model name. The free tier meters per project id and egress, so every
deployment running the same probe shared one bucket; once a popular exit
had charged that bucket, every probe answered 429 FreeUsageLimitError and
the model was cached as unavailable for an hour while live traffic on the
same process and egress succeeded.

The Playground bench pinned a session indirectly: it sent no session
signal, so DeriveRequestIDs fell back to conversationSeed — the system
prompt plus the first user turn — and every click replaying the same
prompt produced the same session.

Neither path is a conversation, so neither should present one. Each now
mints fresh identity per attempt: a canonical session and a random project
id for the probe, a canonical session per Playground click. Canonical ids
are forwarded verbatim, so the scope mixin does not apply and the shape the
free tier accepts is what goes out.

Verified end to end with the admin UI enabled on a temporary instance.
Three Playground clicks before the change logged the same upstream session
three times (ses_ea4eb1680ffe0B8cZBh0nKJ03A); two clicks after logged
ses_eb2c888f1ffe4Y0DodMQdwvu6c and ses_ed8748efdffe2ez6IH352OdMpV, both
200. Probes on this build measured 8/8 probe_succeeded with a fresh
availability cache — they already succeeded on this exit before the change,
so this is hardening for the charged-bucket case in the report, not a
reproduction of it.
@jasonxu114514
jasonxu114514 merged commit 6bb3487 into jasonxu114514:main Oct 29, 2026
5 checks passed
jasonxu114514 added a commit that referenced this pull request Oct 29, 2026
The repository ships without test files; strips the tests that arrived
with #160, #161 and #162 after their squash merges.
@cheerc
cheerc deleted the fix/pinned-probe-identity branch October 29, 2026 14:21
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.

Availability probes and the Playground bench both pin a deterministic session, so both 429 while live traffic succeeds

2 participants