Skip to content

feat(usage): forward gateway-audience OBO as x-boon-gateway-obo-token (ENG-19115) - #173

Merged
insomnius merged 2 commits into
boonfrom
ariefrahman/eng-19115-openclaw-forward-obo-token-x-boon-obo-token
Sep 1, 2026
Merged

insomnius merged 2 commits into
boonfrom
ariefrahman/eng-19115-openclaw-forward-obo-token-x-boon-obo-token

Conversation

@insomnius

@insomnius insomnius commented Sep 1, 2026 •

Copy link
Copy Markdown

What

Forward the gateway-audience OBO from MsgContext.OboToken (set by anychat-boon-web, ENG-19116) to the LLM-gateway call as the X-Boon-Gateway-Obo-Token header, so the gateway (ENG-19117) can verify it fail-closed and skip metering internal-test traffic against the customer's token meter (parent ENG-18998).

Mirrors the existing senderId → x-boon-user-id seam exactly.

Changes (6 files, all additive/optional)

  • auto-reply/templating.ts — add OboToken? to MsgContext.
  • embedded-agent-runner/run/params.ts — add oboToken? to RunEmbeddedAgentParams (propagates to EmbeddedRunAttemptParams via the existing Omit).
  • auto-reply/reply/get-reply-run.ts — read sessionCtx.OboToken into the run params.
  • embedded-agent-runner/run/attempt.ts — thread oboToken into the model-call diagnostic context (omit-when-absent).
  • embedded-agent-runner/run/attempt.model-diagnostic-events.ts — oboToken on ModelCallDiagnosticContext, BOON_OBO_HEADER_NAME = "x-boon-gateway-obo-token", and the entry in withBoonUsageHeaders.
  • test — x-boon-gateway-obo-token emitted / omitted case.

Header name (pinned)

Emits x-boon-gateway-obo-token (lowercase; Go net/http canonicalizes to X-Boon-Gateway-Obo-Token). Pinned by the gateway verifier — boon-llm-gateway middleware/obo.go const OboHeader = "X-Boon-Gateway-Obo-Token" (ENG-19117, boon-llm-gateway#96). A mismatch would fail-open (traffic metered), so this stays in lockstep with that constant. (First commit used the old plan name x-boon-obo-token; second commit corrects it.)

Security / scope

  • Plumbing only. Carries the opaque token verbatim; never logged. All verification (sig + aud + exp + org-binding, fail-closed) is at the gateway.
  • Optional / omit-when-absent — non-web surfaces (Slack/Teams) and older boon-core builds are unaffected (header simply not emitted).

Closes the OBO runtime chain: 19112 mint + 19113 stamp + 19116 MsgContext + 19115 header + 19117 verify + 19110 skip.

Test

  • node scripts/run-vitest.mjs run src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.test.ts → 21 passed.
  • pnpm tsgo:all (full monorepo typecheck) → clean.
  • oxlint on changed files → clean.

Closes ENG-19115.

…115)

Thread the gateway-audience OBO from MsgContext.OboToken (set by
anychat-boon-web, ENG-19116) through the runner param chain into the
model-call diagnostic context, and emit it as the x-boon-obo-token
header in withBoonUsageHeaders -- mirroring senderId -> x-boon-user-id.

The gateway (ENG-19117) verifies the signed token fail-closed to skip
metering internal-test traffic. Security-neutral plumbing: this only
carries the opaque token (never logged); all verification is at the
gateway. Optional/omit-when-absent, so non-web surfaces and older
boon-core builds are unaffected.
@claude

claude Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@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 — the header threads through exactly like x-boon-user-id, sanitized + omit-when-absent, and never logged.

Verified locally:

  • grep -rn oboToken src/ — only the 6 documented touchpoints; zero logging/serialization contexts
  • node scripts/run-vitest.mjs run src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.test.ts → 21/21 pass (including the new emitted/omitted case)
  • pnpm tsgo:all clean
  • CI checks in progress; every completed check is SUCCESS (mergeStateStatus=UNSTABLE only because checks are still running)

Ship the OBO chain.

The gateway verifier reads exactly X-Boon-Gateway-Obo-Token
(boon-llm-gateway middleware/obo.go `OboHeader`, ENG-19117). The first
commit emitted the old plan name x-boon-obo-token, which the gateway
would ignore -> fail-open (internal-test traffic still metered). Align
the emitted header, comments, and test with the pinned name.
@insomnius insomnius changed the title feat(usage): forward gateway-audience OBO as x-boon-obo-token (ENG-19115) feat(usage): forward gateway-audience OBO as x-boon-gateway-obo-token (ENG-19115) Sep 1, 2026
@insomnius
insomnius merged commit 86cb5a3 into boon Sep 1, 2026
146 checks passed
@insomnius
insomnius deleted the ariefrahman/eng-19115-openclaw-forward-obo-token-x-boon-obo-token branch September 1, 2026 13:57
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.

1 participant