Repository navigation
fix(usage): carry the gateway OBO through the primary-turn params to the attempt (ENG-19115) - #198
Conversation
…the attempt (ENG-19115) 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.
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
Approved.
Trace holds: #185 fixed the read (ctx.OboToken → run.oboToken), #190 fixed the QUEUED-followup hop, but the PRIMARY turn goes through buildTemplateSenderContext (identity from sessionCtx only, no per-turn token) then run.ts's explicit field-by-field attempt-params copy (no oboToken line). Either fix alone leaves obo=absent at the wire — confirmed by the trace's turn #4 (B1 green, wire absent) vs turn #5 (both fixes, wire present ×2 + gateway fetches org-2 signing key for the first time).
Points I looked at hard:
- The B2 test 'leaves oboToken undefined … when sessionCtx has one' is the right invariant guard. Persisted OBO would be stale (5-min TTL); sourcing from sessionCtx here would silently look right and be wrong.
- Names-only debug log is genuinely names-only: 'attached' only ever gets header names, obo is boolean-coerced to present/absent, raw JWT never touches the log line, level is debug. Closes the observability gap that let three fixes ship blind.
- Compaction-recovery attempt sites (timeout/overflow) intentionally skipped — compaction carries no identity today, correct as a separate follow-up.
- Two regression tests are red-before / green-after for the two distinct hops, not one test that could pass for the wrong reason.
Auto-merge armed with SQUASH; the two directly-relevant CI shards (checks-node-auto-reply-reply-agent-runner, checks-node-agentic-agents-embedded) gate the merge.
…200) Ships #198 (ENG-19115) — the gateway-audience OBO finally reaches the wire: agent-runner-utils builds the primary-turn sender context from run.oboToken and run.ts copies it into the attempt params, verified end to end on a local stack (gateway fetched the org signing key and verified the token). Also #197 browser-handoff recheck, #194 sentry-monitor tenant tag + hook allow-list, #195/#196 CI dependency-audit hardening. Lockstep bump via release:prep; CHANGELOG.md gains the 2026.6.11-boon.37 section the prepack requires.
…206) ## Release 2026.6.11-boon.38 Ships channel-owned sub-agent completion replies for Boon web chat. ### Contents (merged onto `boon` since boon.37) - **#205 (ENG-19421)** — a plugin can register a completion owner for its channel; the announce flow hands the sub-agent completion to the owner and falls back to the existing delivery path when none is registered, so other channels are unchanged. `sessions_yield` runs its tool batch sequentially so a `message` send in the same turn is no longer aborted. Carries upstream openclaw#97657 and openclaw#98835 (`reply session initialization conflicted`). Smoke-tested on a local stack; evidence in #205. - **#202** — plugin-sdk read of the gateway live run count. - **#201** — internal identifiers removed from the public tree. ### Release prep - Root version boon.37 → boon.38; `pnpm release:prep` regenerated the lockstep set (211 files) → `[release-preflight] OK`. - `CHANGELOG.md` `## 2026.6.11-boon.38` section added; `scripts/package-changelog.mjs` extractor returns 2496 packaged bytes. ### After merge Tag `v2026.6.11-boon.38` → `boon-release.yml`. The fleet is pinned to `boon.36`, so the roll also picks up boon.37 (#189, #194–#198). Gateway roll first (gated `fleet-roll`), then the anychat-boon-web release that pins this tarball.
…211) ## Release 2026.6.11-boon.39 Surfaces a swallowed before_tool_call hook failure to Sentry + the durable audit trace so the ENG-19492 incident class is diagnosable after the fact. ### Contents (merged onto `boon` since boon.38) - **#209 (ENG-19492)** — emit a `before_tool_call_hook_failed` observability hook (genuine handler exception only, never a policy veto), paged by sentry-monitor, and thread the real error text into boon-core's audit_trace as an optional `detail` field. Requires boon-core companion getboon/boon#14629 (merged + live) which accepts the new field. Non-hook pipeline failures are classified separately. - **#208** — derive legacy tool counts from surfaced failures. ### Release prep - Root version boon.38 -> boon.39; lockstep regenerated (211 files: 135 plugin package.json + 70 npm-shrinkwrap.json + SDK/config baselines). All release-preflight --check steps pass. - CHANGELOG.md `## 2026.6.11-boon.39` section added. ### After merge Tag `v2026.6.11-boon.39` -> `boon-release.yml`. Fleet is pinned to boon.36, so a roll also picks up boon.37 (#194-#198) and boon.38 (#201, #202, #205). Claude-Session: https://claude.ai/code/session_01AMjtZJAWLVBwa5Dtc4oNog Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

Verified locally end to end this time — RED → GREEN
Full local stack: boon-core (
:3000) → anychat-boon-web-clone (dist rebuilt) → openclawpnpm dev gateway(:18789) → local boon-llm-gateway (:8080) → back to boon-core. Turns driven withboon agent send.RED (boon.36, i.e. #185 + #190 in): mint ✓ (
minted + attached: account=2 internal_test=true), plugin ✓ (gatewayOboPresent:true), but the gateway never fetched the org's signing key (GET boon-core's per-org signing-key endpoint— zero all day) and flushedtokens_consumedfor org 2 → the internal-test turn was metered. Exactly prod.Bisection (presence-only trace logs, since removed): token present at
dispatchInboundMessage, at get-reply-run (ctxandsessionCtx), and at agent-runner-execution (candidateRun.oboToken=present) — absent atwithBoonUsageHeaders. Two more explicit-field-list hops:agent-runner-utils.tsbuildTemplateSenderContext— built the primary-turn identity from persistedsessionCtxonly. The OBO is per-turn and lives onrun.oboToken, never onsessionCtx. (fix(usage): forward run.oboToken into embedded runner params (ENG-19115) #190 fixedfollowup-runner, which only serves queued mid-turn followups; the first turn goes throughagent-runner-execution→ this builder.)embedded-agent-runner/run.ts— copiesRunEmbeddedAgentParamsinto the attempt params field by field (senderId,senderName, …) and never copiedoboToken→attempt.ts'sparams.oboTokenwas always undefined. feat(usage): forward gateway-audience OBO as x-boon-gateway-obo-token (ENG-19115) #173 declared the field on the outer type and read it on the inner one; run.ts was never threaded.Both required: builder fix alone → wire log still
obo=absent. Builder + run.ts →boon usage headers attached: […, x-boon-gateway-obo-token] obo=presentand the local gateway didGET …/openclaw_signing_key→ 200 (first ever), i.e. it received and verified the OBO.Changes (5 files +
.design/trace)agent-runner-utils.ts:buildTemplateSenderContext(sessionCtx, run)addsoboToken: run.oboToken.run.ts: attempt params includeoboToken: params.oboToken(main attempt).attempt.model-diagnostic-events.ts: names-only debug log of attached Boon headers +obo=present|absent(never values). This hop had zero observability — how three fixes shipped blind.run.oboToken(red before) / never fromsessionCtx;runEmbeddedAgentforwardsoboTokeninto the attempt (red before) / undefined when absent. Touched suites 123/123; oxlint + oxfmt clean..design/: requirement, flow, nodes, gate + acceptance ledgers with the red/green evidence.Not in this PR
Compaction model calls (
compact.ts, and run.ts's timeout/overflow-recovery compaction sites) carry no identity today (nosenderIdeither) — pre-existing gap, separate follow-up.Refs #173, #185, #190, ENG-19115/19116/19117.
Summary by cubic
Carries the gateway-audience OBO token through the primary-turn runner params so internal-test turns reach the LLM gateway with the
x-boon-gateway-obo-tokenheader. Previously the token was dropped in two places —buildTemplateSenderContextbuilt sender identity from the persisted session context only (the OBO is a fresh per-turn token onrun.oboToken), andrun.tscopied attempt params field by field withoutoboToken— so the header never reached the gateway and internal-test turns were metered against the customer's agent token budget.run.tsforwardsoboTokenonly into the main attempt; compaction-recovery attempts are untouched because compaction carries no identity today (separate follow-up).withBoonUsageHeaders, never values, to give this previously unobservable hop visibility.buildEmbeddedRunExecutionParamscarryingrun.oboTokenand never sourcing it fromsessionCtx, plusrunEmbeddedAgentforwarding it into the attempt and leaving it undefined when absent.Addresses ENG-19115.
Written for commit 15df086. Summary will update on new commits.
Actual local results (verbatim, secrets-free)
Stack: boon-core
:3000(puma + sidekiq on the dispatch queue) · anychat-boon-web-clone v0.0.39 (dist rebuilt) · openclawpnpm dev gateway:18789· boon-llm-gateway:8080withBOON_CORE_URL=http://localhost:3000· turns driven byboon agent thread create / send / pollas the org-2 internal-test user. Harness:scripts/boon/obo-e2e-local.sh(this PR). Nothing below is a token, key, or personal identifier.Manual RED — boon.36 (#185 + #190 in), before any change here
boon-core
development.log, turn window:openclaw stdout:
"gatewayOboPresent":true·message dispatch completed … sessionKey=2:thread-124 … outcome=completedBisection (presence-only trace logs, since removed) — builder fix in, run.ts fix not yet
→ alive into agent-runner-execution, dead at the wire → the run.ts attempt-params copy was the last drop.
Harness RED —
scripts/boon/obo-e2e-local.sh 2withagent-runner-utils.ts+run.tsat theirorigin/boonversionsHarness GREEN — this branch (fresh gateway process, cache cold)
boon-core log for that turn:
Started GET "boon-core's per-org signing-key endpoint" … Completed 200 OK in 21ms— the first signing-key fetch the local gateway has ever made, i.e. it received the OBO and verified it.Not observable from these logs
The gateway's
[usage] … "source"field (signed OBO vsgetboon_email) is only on the gateway's own stdout. Locally the test user is@getboon.ai, so tier-2 also setsinternal_test=true— the tier-1 discriminator above is the signing-key fetch (only the OBO path performs it). To confirmsourceend-to-end, read the gateway terminal for the turn.Unit gate (red before / green after each edit)
agent-runner-utils.test.ts"carries run.oboToken into the primary-turn sender context": redexpected undefined to be 'obo-signed-token'→ greenrun.before-agent-reply-cron.test.ts"forwards the gateway-audience OBO into the embedded attempt": redexpected undefined to be 'obo-signed-token'→ green