Repository navigation
fix(usage): forward run.oboToken into embedded runner params (ENG-19115) - #190
Conversation
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).
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
Approved.
Clean RCA and surgical fix. #185 fixed the read side but the value died one hop later — followup-runner builds RunEmbeddedPiAgentParams from an explicit field list and FollowupRun.run never declared oboToken, so structural typing let it ride the untyped literal to this hop and get silently dropped before attempt.ts could emit x-boon-gateway-obo-token. Fix declares the field on the run type + forwards it alongside senderId/channelContext. Tests cover both directions (forwards when present, undefined when absent — omit-when-absent semantics preserved). Prod evidence on org 543 / arief-openclaw-test (boon.34) confirms the header was never emitted — gateway logged neither tier for the turn.
Scope discipline is right: compaction-path OBO gap (senderId + OBO both absent on compact.ts) noted as a separate follow-up rather than widened here. Refs ENG-19115/ENG-19116.
There was a problem hiding this comment.
Approved.
Diff verified against description — 3 files, 57+/0-:
• queue/types.ts declares oboToken?: string on FollowupRun.run (closes the type gap that let it ride the untyped literal)
• followup-runner.ts forwards oboToken: run.oboToken alongside senderId/channelContext in the params object (closes the runtime gap — the explicit field-list handoff was the actual drop site)
• followup-runner.test.ts +2 regression tests: forwarded-when-present + undefined-when-absent
Root-cause read is sound. #185 correctly populated run.oboToken from ctx in get-reply-run, but followup-runner picks fields explicitly, so the value passed the untyped literal (const followupRun = {…}) via structural typing and then died at the next hop. Both edits together are necessary — the type declaration alone doesn't forward it, the forward alone re-introduces the type gap. Fix is minimal and only touches the drop site.
Regression tests are real. expected undefined to be 'obo-signed-token' is exactly the prod symptom (no x-boon-gateway-obo-token emitted → gateway can't classify tier-1 → internal-test turn fully metered against customer meter). Second test locks in omit-when-absent so attempt.ts still skips the header cleanly.
CI: all green. 148 successful checks incl. build-artifacts, check-prod-types, check-test-types, check-lint, every boundary/security scan, all node-agentic suites. Neutrals are cubic-review + CodeQL aggregator (expected). Cancelled Claude PR Review is the auto-cancel pattern, not a failure. Auto-merge (squash) armed.
Follow-up call-out on compaction ctx carrying no sender/OBO is correct to split — different scope, pre-existing.
…191) Carries #190 (ENG-19115) — forward run.oboToken into the embedded runner params so x-boon-gateway-obo-token is actually emitted and the tier-1 signed-OBO meter-skip fires — and #141 (ENG-15749) preserve per-turn provider session headers. Fork gateway + @openclaw/slack + @openclaw/msteams + @openclaw/diagnostics-prometheus bumped in lockstep via release:prep; CHANGELOG.md gains the 2026.6.11-boon.35 section the prepack requires.
…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.

The real root cause of tier-1 OBO never firing
#185 fixed get-reply-run to read the per-turn OBO from the inbound
ctx(not persistedsessionCtx). That was correct but not sufficient: the token still died one hop later.followup-runner.tsbuildsRunEmbeddedPiAgentParamsfrom an explicit field list off therunblock:And
FollowupRun.run(queue/types.ts) never declaredoboToken, so no hop could legally reference it. get-reply-run'sconst followupRun = {…}is untyped, so TS inferred the literal (withoboToken) and structural typing let it pass — the value rode the object to this hop at runtime and was silently dropped.params.oboTokenwas alwaysundefinedinattempt.ts→x-boon-gateway-obo-tokennever emitted.Production evidence (the dev canary org, already on boon.34)
ctx.OboTokenpresent in dist),gatewayOboPresent:trueon the inbound.obo verified, nono OBO header, no[usage]meter line at all. Neither tier classified it → the internal-test turn was fully metered against the customer meter (its sender isn't a@getboon.aiidentity, so tier-2 couldn't catch it either).getboon_email+no OBO header— same missing header.Fix
oboToken?: stringonFollowupRun.run.oboToken: run.oboTokenin followup-runner alongsidesenderId/channelContext.Tests
run.oboTokeninto the runner params; leaves itundefinedwhen absent (omit-when-absent preserved → attempt.ts still skips the header).expected undefined to be 'obo-signed-token'— the exact prod symptom.tscerrors onboonare insrc/plugins/providers.test.ts, untouched).Not in this PR (follow-up)
Compaction model calls (
compact.tsdiagnostic ctx) carry nosenderIdor OBO today — a pre-existing, broader attribution gap, not OBO-specific. Filing separately rather than widening this ASAP fix.Refs #185, ENG-19115, ENG-19116.
Summary by cubic
Fixes the gateway-audience OBO token being silently dropped before the model call, so internal-test turns were fully metered against customer meters instead of being classified as internal (ENG-19115).
Bug Fixes
oboTokenonFollowupRun.run; previously it rode the untyped literal and no hop could legally reference it.run.oboTokeninto the embedded runner params infollowup-runner.ts, sox-boon-gateway-obo-tokenis emitted on the LLM-gateway call.Written for commit 8c8fe92. Summary will update on new commits.