Skip to content

feat(web): add observationNodeBudget option - #1620

Closed
ahmadparizaad wants to merge 4 commits into
e2e-inc:mainfrom
ahmadparizaad:feat/web-observation-node-budget
Closed

ahmadparizaad wants to merge 4 commits into
e2e-inc:mainfrom
ahmadparizaad:feat/web-observation-node-budget

Conversation

@ahmadparizaad

@ahmadparizaad ahmadparizaad commented Nov 7, 2026 •

Copy link
Copy Markdown

Issue

Fixes #1510

What changed

  • web({ observationNodeBudget }) sets the node budget one observation spends, shared across the main document and its frames, default 3,000 (MAX_OBSERVED_NODES in observation-capture.ts was the fixed value).
  • Validated at config load as a positive safe integer, INVALID_CONFIG otherwise; added to WEB_OPTION_KEYS so it is a known web() key.
  • The value reaches captureObservation through CaptureSettings.nodeBudget, which also feeds TraceFeed captures.
  • Docs (docs/reference/web.mdx option table and section) and a patch changeset for @e2e-dev/web and e2e.

Verified

Ran it locally: yes

  • pnpm --filter @e2e-dev/web test:unit: all unit tests pass, including the new web({ observationNodeBudget }) cases (rejects 0, -1, 1.5, NaN, '8000' as INVALID_CONFIG; accepts 8_000) and the updated unknown-key message.
  • pnpm --filter @e2e-dev/web typecheck, pnpm run lint, pnpm docs:check: clean.

View guided diff

@github-actions github-actions Bot added the size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 7, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

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 7 files

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

View guided diff | Re-trigger cubic

Comment thread packages/web/src/engine.ts Resolved
Comment thread packages/web/src/engine.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 4 files (changes from recent commits).

View guided diff | Re-trigger cubic

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated review (agent-run triage).

Thanks. The wiring is small and clean: both capture paths (surface.ts observe and trace-feed.ts) get nodeBudget, the old constant is gone, frames still share one budget, truncation flag untouched, no cache-key impact (buildTraceCacheKey has no observation content). CI green.

Heads up: this is a feat, and #1510 has no maintainer agreement on the API yet (CONTRIBUTING asks for that first). The API shape is a maintainer call, see the end. Review of the code as it stands:

Must fix

  1. No test proves the option does anything. protected-app-options.test.ts:69-86 only checks validation. The issue asked for "override reaches a control past the old cutoff" and "shared cross-frame limit" tests; both are missing. Mutations that make surface.ts:339 ignore the option, hardcode 3000 in capture, or switch to a per-frame budget all survive the suite. Add an integration test through web({...}).observe (like hidden-frames.test.ts): ~4,000 buttons + a trailing link, default misses it, observationNodeBudget: 8_000 finds it; and a small budget split across main document + iframe. (A scratch version of both killed those mutations.)
  2. Docs miss the agent-side byte budget, which likely binds first. The agent cuts the tree text at agents.<name>.maxObservationBytes (256 KB), also clamped by maxInputTokens (64k) minus overhead, so roughly 55-60 KB by default. At ~25-60 bytes per tree line, the model probably already sees fewer than 3,000 nodes on a dense page, so raising the node budget alone may not let act reach the late control. Docs should say to raise those too, and the PR needs evidence the #1510 storefront case is actually fixed (a real run).
  3. Cost wording is off. "every extra node costs tokens on each observation": model tokens are capped by the byte budget. The real cost is capture time, CDP payload, and the trace screen after each action, which has a 1 s deadline (trace-feed.ts:15), so big budgets can silently drop trace screens. Say that in user terms.

Nits

  • Changeset bumps e2e, but nothing in e2e changed. Only @e2e-dev/web.
  • engine.ts:411-415: JSDoc cites mintId, budgets go through reserveIds (refs.ts:45); the 1,000,000 cap has no stated basis. engine.ts:418 "no capture could spend" isn't what the validator checks.
  • surface.ts:278 repeats the JSDoc of CaptureSettings.nodeBudget and WebOptions (three near-identical comments).
  • Docs use internal terms ("semantic capture", "reports truncated"). Prefer "the observation is marked incomplete".
  • protected-app-options.test.ts header comment listing the options wasn't updated.

For maintainers: accept the option at all (vs ranking viewport/interactive nodes first, #1237); name observationNodeBudget vs maxObservationNodes (parallels maxObservationBytes); per-target vs config-level; the 1,000,000 cap.

@ahmadparizaad

Copy link
Copy Markdown
Author

Before I build out the remaining items (integration test, docs on the byte budget, changeset fix): is web({ observationNodeBudget }) the shape you want, or would you prefer a different name (maxObservationNodes, paralleling maxObservationBytes), a config-level key, or a different approach entirely (e.g. prioritizing visible nodes per #1237)? Happy to adjust before I invest in the tests.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

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 5 files (changes from recent commits).

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

View guided diff | Re-trigger cubic

Comment thread docs/reference/web.mdx Resolved
@okwasniewski

Copy link
Copy Markdown
Member

Automated review (agent-run triage).

Good call to ask before building the tests. The shape (web({ observationNodeBudget }) vs maxObservationNodes vs config-level vs ranking visible nodes first per #1237) is a maintainer decision, and an automated pass can't make it. I've flagged it for the maintainers. Holding further review until they answer. The ec1e492 wording changes look fine in the meantime.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

View guided diff | Re-trigger cubic

@kdy1

kdy1 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. We are closing it without merging.

We have not agreed on an API for #1510 yet, and the requested changes from 2026-11-07 are still open: no test shows that the option reaches a control past the old cutoff. Also, the agent's observation byte budget (maxObservationBytes, clamped by maxInputTokens) probably cuts the tree before the node limit does, so a larger node budget may not fix #1510. The branch now conflicts with main, and #1503 replaces the capture code it changes. #1510 stays open to track the problem.

@kdy1 kdy1 closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: configurable observation node budget for dense pages

3 participants