Skip to content

fix(browser-handoff): make the scheduled recheck actually re-check - #197

Merged
convyusboy merged 7 commits into
boonfrom
ridho/eng-17466-browser-handoff-recheck-reliability
Sep 4, 2026
Merged

convyusboy merged 7 commits into
boonfrom
ridho/eng-17466-browser-handoff-recheck-reliability

Conversation

@convyusboy

@convyusboy convyusboy commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes an issue where the browser login handoff flow would silently stop
rechecking after a customer signed in, requiring the customer to manually
say "continue" every time -- and even then, sometimes get told sign-in
"hasn't come through" with no further automatic retry, even though the
customer had genuinely signed in and the automatic background recheck
should have picked it up shortly after.

Why This Change Was Made

Live-verified via direct log correlation (boon-core's request logs against
the gateway's own turn logs) on a real test host: the scheduled recheck
turn (scheduleSessionTurn, one-shot, silent) would sometimes complete
without the resumed model ever calling browser_handoff with
action="status" at all -- confirmed by zero matching status-check
requests reaching boon-core for that turn, even though the turn itself ran
and completed normally.

The old scheduled message told the model: "if it's still pending, end
your turn without replying."
A resumed model can pattern-match that
against its own recent context (it had just told the customer moments
earlier that sign-in hadn't come through) and answer from memory instead
of actually calling the tool again -- silently breaking the recheck chain,
since the reschedule for the next check only happens inside the status
handler itself.

The fix rewrites the scheduled message so the tool call is the
unconditional first action of the turn, not one branch of a conditional
the model can reason its way past -- explicitly stating that whatever the
model already believes is stale and it has no real answer until it
checks.

User Impact

Customers using the browser login handoff (BuildingConnected, Procore,
Gmail, etc.) should see the agent reliably resume on its own after they
sign in, without needing to repeatedly nudge it, and without the agent
prematurely reporting sign-in "hasn't come through" when it never actually
re-checked.

This is a prompt-structure mitigation, not a structural guarantee --
scheduleSessionTurn's API has no way to force a specific tool call, so
this reduces the failure rate rather than making it impossible. Confirmed
no other extension uses scheduleSessionTurn, so this is an isolated fix,
not a broader pattern.

Evidence

  • node scripts/run-vitest.mjs extensions/browser-handoff -- 39/39 tests pass
  • oxlint/oxfmt clean on the touched file
  • Root-caused via live log correlation on a real test host: compared the
    cron-resumed turn (1 LLM round-trip, no tool call, no browser activity)
    against a normal interactive "continue" turn (4 round-trips + actual
    browser tool execution) for the same session, then cross-referenced
    against boon-core's own request logs showing zero GET /browser_handoff/status calls for that cron turn's timeframe.

Summary by cubic

Fixes the browser handoff scheduled recheck so the agent reliably re-checks after a customer signs in, validates the site argument at the tool boundary to close a prompt-injection surface, and unblocks the pre-commit security audit by excluding a package that hangs npm's advisory endpoint.

  • The old recheck prompt let a resumed model answer from memory and skip the browser_handoff status call, which also broke the reschedule chain since the next check is only scheduled inside the status handler.
  • The new prompt states that whatever the model already believes is stale and makes the status call the unconditional first action of the turn; it's a prompt-level mitigation, not a structural guarantee, since scheduleSessionTurn can't force a specific tool call.
  • site must now look like a hostname (max 253 characters total), because the model-supplied value gets interpolated directly into scheduled-turn and reply prompt text.
  • pnpm-audit-prod now excludes @a2ui/web_core from the bulk advisory request and prints a stderr warning that the package wasn't checked; a request containing only that package hangs registry.npmjs.org indefinitely, and the retry mechanism just repeats the same broken request.
  • When the excluded package is the only production dependency, output says it was excluded rather than claiming none were found.
  • Applies to the Browser Login Handoff flow (ENG-17466) for sites like BuildingConnected, Procore, and Gmail.

Written for commit 2609e6f. Summary will update on new commits.

Review in cubic

Live-verified on arief-openclaw-test: a resumed cron turn would
sometimes end silently without ever calling browser_handoff
action="status" at all -- confirmed via boon-core's own request logs,
which show zero GET /browser_handoff/status calls for a cron-resumed
turn that nonetheless completed normally. The resumed model appears to
pattern-match the old wording's "if it's still pending, end your turn
without replying" against its own recent context (it had just told the
customer moments earlier that sign-in hadn't come through) and answer
from memory instead of actually checking again -- silently breaking the
recheck chain, since handleStatus (the only place that reschedules the
next check) never runs.

Rewrite the scheduled message to remove that shortcut: state up front
that whatever the model already believes is stale, and make the tool
call the first, unconditional action for the turn rather than one leg
of a conditional the model can reason its way around.
@convyusboy
convyusboy marked this pull request as ready for review September 4, 2026 09:34
@convyusboy
convyusboy requested a review from a team September 4, 2026 09:34

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread extensions/browser-handoff/src/tool.ts Resolved
Review feedback: site is model-supplied and gets interpolated directly
into scheduled-turn and reply prompt text in several places (schedule
recheck's message, the request_login reply, status/error text). A value
containing quotes, newlines, or instruction-like text there is a
prompt-injection surface.

site is documented as a hostname (e.g. "app.procore.com"), so validate
it as one at readSite -- the actual boundary where model-supplied args
enter the tool -- rather than trying to escape it at every
interpolation site.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread extensions/browser-handoff/src/tool.ts Resolved
Review feedback: HOSTNAME_PATTERN bounded each label to 63 characters
but not the total hostname length, so an arbitrary number of valid
labels could still produce an unbounded string -- one that then gets
embedded in prompts and used to build state/schedule keys. Add the
standard 253-character total-length bound.

Also fixes a test that claimed to cover newline rejection but whose
fixture contained no actual newline character -- it was passing for
the wrong reason (the quote/instruction-text portion alone already
failed validation). The fixture now includes a real newline.
Live-verified (2026-09-04): a bulk advisory request to
registry.npmjs.org containing only "@a2ui/web_core" hangs indefinitely
-- confirmed twice, 15-20s+ each time, zero bytes received -- even
though the package's own registry metadata resolves normally in under
a second. Not payload-size related: it reproduces with this single
package alone, and blocks security-fast on every PR that pulls it in
as a production dependency (the canvas extension's a2ui bundle), not
just ones that touch it. The existing retry-once mechanism (#195, #196)
doesn't help since it retries the identical request against the same
broken endpoint behavior.

Exclude it from the bulk request entirely (not just filter it from
findings afterward) so the rest of production dependencies still get
audited. Remove once npm fixes the underlying advisory-lookup bug for
this package.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread scripts/pre-commit/pnpm-audit-prod.mjs Resolved
Comment thread test/scripts/pnpm-audit-prod.test.ts Resolved
Review feedback: silently excluding a package from the bulk advisory
request means it was never checked, but the check still reports
success -- indistinguishable from full coverage. Excluding it from the
bulk endpoint request is still necessary (the endpoint hangs on it
regardless of batch size, confirmed by testing it in isolation), so
make the gap impossible to miss instead: print a clear warning naming
the package whenever it's actually a production dependency, so a
passing security-fast never silently implies full coverage.

Also renames the exclusion test to describe the asserted behavior
instead of reading like an incident report.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread scripts/pre-commit/pnpm-audit-prod.mjs Resolved
Comment thread test/scripts/pnpm-audit-prod.test.ts Resolved
Review feedback: when the only production dependency present was the
excluded package, the audit reported "No production dependencies
found" -- misleading, since a dependency was found, it was just
excluded (and the SECURITY WARNING above it already says so). Give
that case its own message that doesn't contradict the warning just
printed.

Also strengthens the "no warning" negative test: it previously proved
only that an absent package produces no warning, not that a package
present as a devDependency (non-production) does not. The fixture now
includes @a2ui/web_core as an explicit devDependency so the test
actually exercises the scenario its name claims.

@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.

  • Root cause diagnosis is solid: live log correlation showed the resumed model completing the scheduled turn without ever calling browser_handoff/status — matching the code's own comment that handleStatus is the only place a reschedule happens, so a skipped call silently breaks the whole chain.
  • Prompt rewrite is the right shape: makes the tool call the unconditional first action, explicitly marks the model's own recent context as stale, keeps the silent-when-pending contract. The PR is honest that this is prompt-structure mitigation, not a structural guarantee (scheduleSessionTurn can't force a tool call) — correct framing.
  • Hostname validation on site is a good adjacent tightening — the field is interpolated directly into prompt text, so bounding shape + total length (253 DNS limit via lookahead) closes a real injection surface. Regex is correct (per-label 63-char cap + total-length lookahead + trailing-hyphen guard).
  • @a2ui/web_core exclusion from the bulk advisory request is a genuine coverage gap, but it's surfaced loudly on stderr every run and the "only-excluded" edge case (which would otherwise misreport as "no prod deps found") is handled + tested. Acceptable unblock for security-fast until npm's advisory endpoint stops hanging on that package; the TODO to remove is on the constant.
  • Tests cover the important cases: injection payload rejection, hostname length limit, valid hostname reaches the handler; exclusion happens, warns, correct message when excluded is the only prod dep.
  • 39/39 extension tests pass, ~100 CI checks green, no secrets in commit history.

Ship it.

@convyusboy
convyusboy merged commit c8259e2 into boon Sep 4, 2026
141 of 142 checks passed
@convyusboy
convyusboy deleted the ridho/eng-17466-browser-handoff-recheck-reliability branch September 4, 2026 12:48
insomnius added a commit that referenced this pull request Sep 4, 2026
…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.
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