Principle:1jehuang Jcode Browser Task Handoff
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Multi_Agent_Systems |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
A delegation pattern where a main agent hands off browser interaction tasks to a bounded controller that uses typed Decisions API to select actions from candidates, minimizing expensive LLM calls while maintaining task control through a step budget.
Description
Browser task handoff is a hierarchical delegation pattern where the main conversational agent delegates browser interaction to a lightweight controller. Instead of the main LLM deciding every browser action (click, type, scroll), the controller uses the Jev Typed Decisions API to classify the current page state against candidate actions and select the best one. The main LLM is only invoked when the controller requests code or text generation (flagged by script_needed or text_needed).
The problem solved is cost and latency of LLM-driven browser automation: having a large language model decide every mouse click and keystroke is slow and expensive. By using a fast classification model (Jev) for action selection and only invoking the main LLM for generation tasks, the handoff reduces both cost and latency by orders of magnitude.
The design includes a step budget (max_steps) to bound the controller's autonomy, and completion/handback semantics: the controller signals done when the task is complete or hand_back when it needs the main agent to continue.
Usage
Use this principle when a conversational agent needs to interact with a web browser and per-action LLM calls are too expensive. The trigger is: "the user asks the agent to do something in a browser (fill a form, scrape a page, navigate)." It is appropriate for: form filling, web scraping, browser-based testing, and any task requiring DOM interaction.
Theoretical Basis
The handoff protocol has five stages:
- Status check: The agent queries the browser provider's status (running, tab count, provider type).
- Handoff construction: The agent constructs a handoff request with
tab_id,goal(task description), andcandidates(available actions). - Action selection: The Jev Decisions API classifies the page state against the candidate actions and returns the selected action with a confidence score. This is a
choicequestion with 2-255 options. - Generation (conditional): If the Jev response flags
script_neededortext_needed, the main LLM generates the requested code or text. - Completion: The controller signals
done(task complete) orhand_back(return control to main agent). Amax_stepsbudget bounds the total iterations.
Pseudo-code logic:
# Abstract algorithm (NOT real implementation)
def browser_handoff(browser, goal, tab_id, max_steps):
# 1. Check status
status = browser.status()
if not status.running:
return "browser not available"
# 2. Build candidate actions
candidates = browser.get_actions(tab_id)
# 3. Controller loop
for step in range(max_steps):
page_state = browser.get_page_state(tab_id)
decision = jev.evaluate(
state=page_state,
questions={"action": choice_question(candidates)}
)
action = decision.answers["action"].choice
if action == "done":
return "task complete"
if action == "hand_back":
return "handing back to main agent"
if decision.script_needed:
script = main_llm.generate(goal, page_state)
browser.execute(script)
if decision.text_needed:
text = main_llm.generate(goal, page_state)
browser.type(text)
browser.perform(action)
return "max steps exceeded"
The browser Decisions endpoint uses the X-Jcode-Jev-Purpose: browser header on the Jcode provider so the gateway budgets browser handoffs separately from memory recall.