Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:1jehuang Jcode Step Budget Bounding

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Reliability
Last Updated 2026-10-18 00:00 GMT

Overview

Browser handoff controller execution is bounded by max_steps, preventing unbounded browser automation loops when the controller cannot complete the goal.

Description

The Step_Budget_Bounding heuristic caps the number of controller iterations during a browser handoff. The main agent delegates a browser task with a max_steps budget; the controller (using Jev's typed Decisions API) selects actions from candidates until it signals done or hand_back, or until the step budget is exhausted. This prevents the controller from looping indefinitely when the goal cannot be achieved, when the page state is unexpected, or when the Jev classifier keeps selecting ineffective actions. The main LLM supplies generated code or text only when the controller requests it via script_needed or text_needed.

Usage

Use this heuristic when delegating browser tasks via the handoff protocol. Set max_steps to a reasonable value based on task complexity. If the controller exhausts the budget, control returns to the main agent, which can retry, simplify the goal, or give up.

The Insight (Rule of Thumb)

  • Action: Set max_steps in the handoff action; abort controller execution when the budget is exhausted.
  • Value: Default from config; should be proportional to task complexity (e.g., 10-30 for form filling, more for multi-page workflows).
  • Trade-off: Too low: complex tasks fail prematurely. Too high: wasted time/tokens on unachievable goals.
  • Compatibility: Controller signals done (task complete) or hand_back (return control to main agent).

Reasoning

Without a step budget, a controller that cannot achieve the goal (e.g., page structure changed, login failed, elements not found) would loop indefinitely, consuming LLM tokens and browser resources. The step budget provides a hard stop, returning control to the main agent which can reason about the failure and decide whether to retry with a different approach.

Code Evidence

Bounded controller from docs/BROWSER_FAST_AGENT.md:5-8:

A bounded controller uses Jev's typed Decisions API with
`typesafe/jev-1.13` to choose an offered action ID, `done`, `hand_back`,
`script_needed`, or `text_needed`. Jev is the fast general-purpose classifier.

Completion signals and step budget from docs/BROWSER_FAST_AGENT.md and docs/BROWSER_PROVIDER_PROTOCOL.md:

// Completion signals:
{ done: true }     // Task complete
{ hand_back: true } // Return control to main agent

// Step budget:
max_steps: number  // Maximum controller iterations

Status check before handoff from docs/BROWSER_FAST_AGENT.md:18:

Check `browser` with `action: "status"` first and run setup only if not ready.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment