Repository navigation
fix(usage): read gateway OBO from inbound ctx, not persisted sessionCtx (ENG-19115) - #185
Merged
Merged
Conversation
…tx (ENG-19115) The gateway-audience OBO is a FRESH per-turn token -- boon-core mints it with a 5-min TTL on every /boon-chat inbound. get-reply-run read it from `sessionCtx` (the reconstructed/persisted session context), where it is absent on every persisted-session turn -> `oboToken` was empty -> withBoonUsageHeaders emitted no x-boon-gateway-obo-token -> the gateway fell back to tier-2 (@getboon.ai) for internal-test metering. SenderId survived only because it is a stable identity carried on the persisted sessionCtx. Read OboToken from the inbound `ctx` first (fallback to sessionCtx), mirroring `channelContext` on the next line. Verified live: the box receives the token (anychat gatewayOboPresent=true for org 99) yet the gateway logged "no OBO header on request" every turn.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Approving — the diagnosis is right and the fix is minimal.
Correctness check:
MsgContext.OboTokenis declared on bothctxandsessionCtx(same type), soctx.OboToken ?? sessionCtx.OboTokentype-checks cleanly.- The comment nails the invariant: fresh per-turn 5-min-TTL token has to ride the inbound
ctx, not the reconstructed session. The parallel withchannelContext: ctx.ChannelContext ?? sessionCtx.ChannelContexton the very next line makes the pattern obvious to the next reader. - SenderId staying
sessionCtx-only is the right call — it's stable-per-session identity, not per-turn.
Follow-up (not a merge-blocker):
-
Please add a regression test at the
get-reply-runlayer (get-reply-run.media-only.test.tsalready stubsrunPreparedReply— extend it or spin a sibling.obo-token.test.ts) that pins:ctx.OboTokenset +sessionCtx.OboTokenempty →run.oboToken= ctx value- Both empty →
run.oboTokenundefined - Both set → ctx wins (precedence)
The existing
attempt.model-diagnostic-events.test.tsproves the header flows whenoboTokenis truthy, but nothing at the get-reply-run layer pins where it's read from — which is exactly the regression that just shipped. A three-case test would make the same bug impossible to reintroduce silently.
Merge when CI settles.
insomnius
added a commit
that referenced
this pull request
Sep 3, 2026
…186) Cut the boon.34 fork release. Carries ENG-19115 fix (#185): read the gateway-audience OBO from the inbound ctx, not the persisted sessionCtx -- the per-turn token was being dropped, so the tier-1 internal-test meter-skip never fired. Plus #182 (sentry-monitor correlation ids). release:prep synced the lockstep extension versions + regenerated release artifacts (plugin inventory/reference docs, shrinkwraps, plugin-sdk API baseline, bundled-channel-config metadata).
insomnius
added a commit
that referenced
this pull request
Sep 3, 2026
#186 bumped the version but omitted the CHANGELOG.md section, so the boon-release.yml prepack (scripts/package-changelog.mjs) hard-fails with "CHANGELOG.md does not contain a release section for 2026.6.11-boon.34" and no fleet tarball is built. Add the boon.34 section (covers #185 ENG-19115 OBO ctx fix, #182, #181) to unblock the release.
insomnius
added a commit
that referenced
this pull request
Sep 3, 2026
…15) (#190) The gateway-audience OBO never reached the model call even after #185. get-reply-run correctly sets run.oboToken from the inbound ctx, but followup-runner builds RunEmbeddedPiAgentParams from an explicit field list off the run block and never forwarded oboToken. FollowupRun.run did not declare the field either, so no hop could legally reference it: the value rode the untyped literal to that hop and was silently dropped, params.oboToken was undefined in attempt.ts, and x-boon-gateway-obo-token was never emitted. The gateway fell back to tier-2 email, or fully metered internal-test senders whose identity is not @getboon.ai — confirmed on org 543 (arief-openclaw-test) running boon.34, where the gateway logged neither tier for the turn. Declare oboToken on FollowupRun.run and forward it alongside senderId/channelContext. Regression tests cover both directions: forwarded when present, undefined when absent (omit-when-absent kept).
This was referenced Sep 3, 2026
insomnius
added a commit
that referenced
this pull request
Sep 4, 2026
…the attempt (ENG-19115) (#198) Local end-to-end run (boon-core -> anychat-boon-web -> openclaw -> local boon-llm-gateway) on boon.36 reproduced the production failure: boon-core minted the gateway-audience OBO, the plugin set MsgContext.OboToken, and x-boon-gateway-obo-token still never reached the gateway. Presence-only tracing at each hop showed the token alive through get-reply-run (#185) and into agent-runner-execution, then gone at withBoonUsageHeaders. Two more explicit-field-list hops dropped it: - agent-runner-utils buildTemplateSenderContext built the primary-turn sender identity from the persisted sessionCtx only. The OBO is a fresh per-turn token that lives on run.oboToken, never on sessionCtx, so the first turn never carried it. (#190 fixed followup-runner, which only serves queued mid-turn followups.) - embedded-agent-runner/run.ts copies RunEmbeddedAgentParams into the attempt params field by field and never copied oboToken, so attempt.ts's params.oboToken was undefined on every turn. #173 declared the field on the outer type and read it on the inner one without threading run.ts. Both are required: with the builder fixed alone the wire log still read obo=absent; with run.ts fixed as well the header attached and the local gateway fetched the org's signing key from boon-core (200) for the first time. Also adds a names-only debug log of the Boon headers attached to each model call (never values) - this hop had no observability, which is how three fixes shipped without moving the gateway. Regression tests: buildEmbeddedRunExecutionParams carries run.oboToken (red before the builder edit) and never sources it from sessionCtx; runEmbeddedAgent forwards oboToken into the embedded attempt (red before the run.ts edit) and leaves it undefined when absent. Compaction-recovery attempts intentionally untouched: compaction carries no identity today (separate follow-up). .design/ records the trace and red->green ledger.
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.
Root cause of the tier-1 OBO meter-skip never firing
The signed gateway-audience OBO (ENG-19112/19115/19117) was never reaching the gateway — every an internal-test org request logged
no OBO header on requestand fell back to the spoofable tier-2@getboon.aisignal.get-reply-runreads the OBO fromsessionCtx— the reconstructed/persisted session context:But the gateway-audience OBO is a fresh per-turn token (boon-core mints it with a 5-min TTL on every
/boon-chatinbound). It rides the inboundctx, not the persisted session. SosessionCtx.OboTokenis empty on every persisted-session turn →oboTokenempty →withBoonUsageHeadersemits nox-boon-gateway-obo-token→ the gateway fail-closes to tier-2.SenderIdsurvived the same path only because it's a stable identity carried on the persistedsessionCtx— the seam OboToken was assumed to mirror, but a per-turn token can't be.Fix
Read the inbound
ctxfirst, fall back tosessionCtx— mirroringchannelContexton the very next line:Evidence (live, an internal-test org)
add_gateway_obo_token minted+attached account=<internal-test org> internal_test=true).gatewayOboPresent: true(an internal-test org, ×16/hr) after v0.0.38 rolled.no OBO header on requestevery turn (its ENG-19230 logging) → the token was dropped between inbound receipt and the emitted header. This is the drop.Confirmation after deploy
The gateway's existing logging is the regression check: post-deploy, an internal-test org requests flip from
no OBO header on request→obo verified(tier-1).Test
tsgo:coreclean; existing get-reply-run +attempt.model-diagnostic-events(header-emit) tests pass. One-line context-source change mirroring the adjacentchannelContextread.Summary by cubic
Fixes the tier-1 OBO meter-skip never firing by sourcing the gateway-audience OBO from the inbound
ctxinstead of the persistedsessionCtx./boon-chatinbound, so it lives onctx, not the reconstructedsessionCtx; reading onlysessionCtx.OboTokenleft it empty and suppressed thex-boon-gateway-obo-tokenheader, so the gateway fell back to tier-2 metering.ctx.OboTokenwith asessionCtxfallback, mirroring the adjacentchannelContextread; post-deploy, an internal-test org requests flip fromno OBO header on requesttoobo verified.Written for commit 8764155. Summary will update on new commits.