Skip to content

fix(usage): forward run.oboToken into embedded runner params (ENG-19115) - #190

Merged
insomnius merged 1 commit into
boonfrom
ariefrahman/eng-19115-forward-obo-run-params
Sep 3, 2026
Merged

insomnius merged 1 commit into
boonfrom
ariefrahman/eng-19115-forward-obo-run-params

Conversation

@insomnius

@insomnius insomnius commented Sep 3, 2026 •

Copy link
Copy Markdown

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 persisted sessionCtx). That was correct but not sufficient: the token still died one hop later.

followup-runner.ts builds RunEmbeddedPiAgentParams from an explicit field list off the run block:

senderId: run.senderId,
senderName: run.senderName,
senderUsername: run.senderUsername,
senderE164: run.senderE164,
channelContext: run.channelContext,
// oboToken was never forwarded

And FollowupRun.run (queue/types.ts) never declared oboToken, so no hop could legally reference it. get-reply-run's const followupRun = {…} is untyped, so TS inferred the literal (with oboToken) and structural typing let it pass — the value rode the object to this hop at runtime and was silently dropped. params.oboToken was always undefined in attempt.ts → x-boon-gateway-obo-token never emitted.

Production evidence (the dev canary org, already on boon.34)

  • Box: anychat v0.0.39, openclaw boon.34 running (process started after install; ctx.OboToken present in dist), gatewayOboPresent:true on the inbound.
  • Gateway (the gateway host) for that turn's two requests (14:51:39/43): only access-log lines — no obo verified, no no 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.ai identity, so tier-2 couldn't catch it either).
  • an internal-test org (also boon.34) still logs tier-2 getboon_email + no OBO header — same missing header.

Fix

  • Declare oboToken?: string on FollowupRun.run.
  • Forward oboToken: run.oboToken in followup-runner alongside senderId/channelContext.

Tests

  • New: forwards run.oboToken into the runner params; leaves it undefined when absent (omit-when-absent preserved → attempt.ts still skips the header).
  • Red confirmed without the fix: expected undefined to be 'obo-signed-token' — the exact prod symptom.
  • followup-runner suite 85/85 · oxlint/oxfmt clean · 0 TS errors in changed files (the 3 pre-existing tsc errors on boon are in src/plugins/providers.test.ts, untouched).

Not in this PR (follow-up)

Compaction model calls (compact.ts diagnostic ctx) carry no senderId or 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

  • Declares oboToken on FollowupRun.run; previously it rode the untyped literal and no hop could legally reference it.
  • Forwards run.oboToken into the embedded runner params in followup-runner.ts, so x-boon-gateway-obo-token is emitted on the LLM-gateway call.
  • Preserves omit-when-absent behavior: when no OBO is present, the header is skipped as before.
  • Adds regression tests covering both forwarded and absent cases.

Written for commit 8c8fe92. Summary will update on new commits.

Review in cubic

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).
@insomnius
insomnius requested a review from a team September 3, 2026 15:31
@claude

claude Bot commented Sep 3, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@insomnius
insomnius enabled auto-merge (squash) September 3, 2026 15:53

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@insomnius
insomnius merged commit 4ea5409 into boon Sep 3, 2026
147 of 148 checks passed
@insomnius
insomnius deleted the ariefrahman/eng-19115-forward-obo-run-params branch September 3, 2026 16:28
insomnius added a commit that referenced this pull request Sep 3, 2026
…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.
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.
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.

2 participants