How is the agent loop / planning implemented?
Step loop; planner vs executor; tool-call schema; stop conditions; memory between steps.
Verdict
browser-use has the most complete self-driving loop for “give it a goal” tasks, and Skyvern offers the most loop designs. The Jev-based agents trade open-ended reasoning for one cheap typed decision per step, and several projects have no loop at all.
Autonomous LLM loops. browser-use asks for an AgentOutput each step, compacts history with an LLM summary, and stops on done, max_steps or five failures. Skyvern ships a per-step engine (skyvern-1.0), a block planner (skyvern-2.0) and a tool-calling conversation capped at 80 turns (skyvern-3.0). HyperAgent runs one action per step and fails after five failures or waits in a row. Cua’s ComputerAgent loops until the model returns a plain message.
Jev decision loops. Jev Ultrafast caps runs at 60 actions and stops as blocked after three actions that change nothing. jev-browser asks three independent questions per step (action, goal done, stuck) and stops before acting when a score passes 0.85. typesafe-computer-use stops below 0.4 confidence and hands off to a writer LLM. jev-use runs up to 14 cycles; its OpenRouter planner also needs a PlannerEnabled default that no UI sets. Ulka puts an FX planner over Jev subgoals capped at 8 actions, and only a separate verifier can mark a task done.
Deterministic replay. Workflow Use walks saved steps; only agent steps start a browser-use agent.
No loop. Stagehand has no agent() at this commit. browser-harness runs one script per call. dsh-browser registers 15 browser_* tools and leaves the loop to DeepSeek Harness. agent-desktop does not apply: an outside agent calls it once per step.
Outliers. mobile-jev sends one Jev request per phone step with speculative targets and treats DONE as unverified. openjev-sglang does not apply: it answers one stateless request at a time.
Pick: browser-use for unattended goal-driven browsing, or Skyvern to compare loop designs. Pick: Stagehand, browser-harness, dsh-browser or agent-desktop if you already run an agent harness. Pick: Jev Ultrafast, jev-browser or Workflow Use when per-step model cost must be close to zero.
Per-project answers
browser-use/browser-use
answeredMain loop. Agent.run(max_steps=500) (browser_use/agent/service.py:2501-2727) is the entry point. It starts the browser session, dispatches session/task events, runs initial actions (URL extraction from task), then enters a while self.state.n_steps <= max_steps loop calling _execute_step() which internally calls step().
Step loop. step() (browser_use/agent/service.py:1033-1085) has four phases:
- CAPTCHA wait: checks if a CAPTCHA solver is in progress and blocks if needed (
browser_use/agent/service.py:1044-1061). - Context preparation (
_prepare_context): captures browser state (DOM + screenshot), checks downloads, checks stop/pause signals, updates action models for the current page, builds plan description, creates LLM messages with the state, runs optional message compaction, injects loop-detection/replan/exploration/budget nudges. - LLM call + execution (
_get_next_action+_execute_actions): calls LLM with the prepared messages, parses structuredAgentOutput, then callsmulti_act()to run all returned actions sequentially. - Post-processing (
_post_process): updates plan state, records actions for loop detection, increments consecutive failures counter on error.
Tool-call schema. LLM output is parsed into AgentOutput (browser_use/agent/views.py:388-398) containing thinking, evaluation_previous_goal, memory, next_goal, current_plan_item, plan_update, and action (list of ActionModel). The ActionModel is a discriminated union of all registered action types. In flash mode, planning fields are stripped. The output goes through AgentOutput.type_with_custom_actions() which dynamically creates a Pydantic model with the registry's current actions as a discriminated union.
Planning. When enable_planning=True, the LLM can output plan_update (list of step strings) to create/replace a plan stored as PlanItem objects with status tracking (pending/current/done/skipped). _render_plan_description() formats it for re-injection. Replan nudges trigger after 3 consecutive failures (planning_replan_on_stall). An exploration nudge suggests creating a plan after 5 steps without one.
Memory between steps. The MessageManager maintains message history. _maybe_compact_messages() summarizes old history every 25 steps (configurable) when the prompt exceeds ~10K tokens, using a compaction LLM. memory field in AgentOutput allows the LLM to persist structured notes. ActionResult.long_term_memory lets actions inject persistent context.
Stop conditions. max_steps reached (forces done action with last-step warning), max_failures exceeded (default 5, with optional final recovery attempt), manual stop/pause via signal handler (SIGINT toggles pause/resume; second SIGINT force-exits). The _force_done_after_last_step() method replaces the action model with a done-only schema on the final step.
History. Each step records an AgentHistory item with model output, results, browser state (URL, title, tabs, screenshot path). After completion, an optional LLM judge evaluates the trace.
trycua/cua
answeredThe agent loop lives in the Python cua_agent package (in the Python agent SDK at libs/python/agent/), with the TypeScript @trycua/agent package providing a client interface to the same proxy.
Architecture. ComputerAgent (libs/python/agent/cua_agent/agent.py:250) is the main class. It auto-selects an agent loop based on the model name via a decorator-based registry (libs/python/agent/cua_agent/decorators.py:13-55). Each loop implements the AsyncAgentConfig protocol with predict_step, predict_click, and get_capabilities methods (libs/python/agent/cua_agent/loops/base.py:11-80).
Step loop. The core loop in ComputerAgent._run() (around line 936) iterates: it sends messages + tool schemas to the model via the loop's predict_step, collects the response, handles any computer actions by executing them through a ComputerHandler, appends the results (screenshots, outputs) back to the message history, and repeats until the model produces an assistant message (no more tool calls). The loop is a single agent — no separate planner vs. executor distinction; the model itself decides actions and their sequence.
Tool-call schema. Messages follow OpenAI's Responses API schema: ComputerCallMessage (with {type: "computer_call", action: {type, x, y, ...}}) and ComputerCallOutputMessage (with screenshot) are the primary computer-use types (libs/typescript/agent/src/types.ts:76-87). Each agent loop maps these to its provider's format (Anthropic's computer_use beta tool, OpenAI's computer_use_preview, Gemini's computer_use, or custom function calls).
Stop conditions. The loop naturally terminates when the model returns a non-computer-call response (text assistant message). The BudgetManagerCallback can also stop based on token/cost limits. Per-request timeout (default 30s) limits individual API calls (libs/typescript/agent/src/client.ts:160).
Memory between steps. The full message history (old_items + new_items) accumulates across iterations. Callbacks like ImageRetentionCallback (optionally keeping only N most recent images) and PromptInstructionsCallback can trim context. use_prompt_caching enables Anthropic-style prompt caching (libs/python/agent/cua_agent/agent.py:948).
browserbase/stagehand
answeredStagehand does not implement a traditional autonomous agent loop (no planner/executor loop within the SDK itself). Instead, it provides a tool-call API designed to be used from external agent frameworks. The core operations are act(), observe(), and extract(), each making one (or two) LLM calls per invocation.
act() service flow (actService.ts):
- Wait for DOM/network quiet via
waitForDomNetworkQuiet(CDP Network events) - Capture a hybrid snapshot (
page.captureSnapshot) - Call the LLM with
buildActPrompt+ the snapshot — the LLM returns anActInferenceSchema(elementId, method, args, twoStep flag) - Execute the action deterministically via CDP (
takeDeterministicAction) - If
twoStepis true, diff the new snapshot against the old one (diffCombinedTrees), make a second LLM call (buildStepTwoPrompt), and execute a follow-up action
LLM calling (inference.ts): All calls use structured output via responseFormat: { type: "json_schema", name, schema }. The schemas are defined as Zod objects — ActInferenceSchema, ObservationSchema, ExtractMetadataSchema — and serialized to JSON Schema via z.toJSONSchema(). This is JSON Schema-driven structured generation (not tool calling).
observe() captures a snapshot and asks the LLM to return an array of candidate actions (element + method + args) matching the user's instruction.
extract() captures a snapshot, calls the LLM for structured data extraction against a user-provided Zod schema, then makes a second LLM call for a metadata judgment on whether extraction is complete.
External agent loop: The prompt.ts file contains buildOperatorSystemPrompt and buildGoogleCUASystemPrompt — system prompts for an external agent that calls act()/extract()/goto() as tools in a loop. But Stagehand itself is not that loop; it's the tool layer beneath it.
Memory between steps: There is no built-in memory system — each act()/observe()/extract() call is stateless with respect to the LLM. The full snapshot is re-captured on each call. Variables (%varName% placeholders) can be substituted into action arguments before execution.
Skyvern-AI/skyvern
answeredSkyvern has three major agent loop implementations, selectable per task:
Legacy step engine (V1/V2). Located in skyvern/forge/agent.py. The loop (execute_step at line 3653) is: scrape the page → build prompt with element tree + screenshots → call LLM → parse actions → execute each action via the action handler → verify goal completion → repeat or terminate. Each iteration is one "step" with scraped page state. The LLM response is parsed into a list of Action objects (via parse_actions in parse_actions.py) which are then dispatched to ActionHandler. After action execution, the loop runs complete_verify — a separate LLM call that checks whether the user's goal was achieved. Stop conditions: COMPLETE or TERMINATE action emitted by the model, or budget exhaustion (max steps, max retries). The V2 variant includes message history across steps via llm_messages_builder_with_history.
Task V3 engine (persistent-conversation tool-loop). Located in skyvern/forge/taskv3/engine.py and loop.py. This is fundamentally different: it runs one persistent LLM conversation where the model calls tools (not a fixed prompt + actions) in a tool-use loop. Perception is a tool the model calls (observe), not automatically injected. Tools are defined as ToolSpec objects in tools.py (click, type, navigate, scroll, etc.). The loop calls run_agent_tool_loop (loop.py:1-13), which threads tool results back as tool-role messages. It is capped by DEFAULT_MAX_TURNS (80), DEFAULT_MAX_TOOL_CALLS (300), a wall-clock deadline (1800s), and a token budget (1.5M). Goal checking runs via GoalJudge (goal_check.py) with configurable verification. An unlisted_reask mechanism lets the model ask the user about unprompted decisions.
Third-party engines. CUA (OpenAI/Anthropic computer-use) and UI-TARS are supported as alternative engines. CUA tasks pass an existing OpenAIResponse object into execution (agent.py:3669). Yutori Navigator is a separate LLM caller for navigation-specific applications.
Across all loops, the SkyvernContext object carries step state, error codes, secrets, TOTP state, and multi-field TOTP tracking (multi-fill OTP splitting). The step/action history is persisted to the database for debugging and retry.
browser-use/jev-ultrafast
answeredThe agent loop lives in Agent (agent.py:12-165). Initialization (__init__, line 12-41) takes a URL and goals, starts a Browser session, observes the first page, and sets up a state dict containing the goal plan, page state, history, and counters. The public run() method (line 163-165) yields states from command("tick") while status is not "done" or "blocked".
Each tick (line 55-64) runs two phases: predict then act. predict (line 65-85) calls model.choose(), which sends a single HTTP POST to https://api.typesafe.ai/v1/systemone (model.py:119) containing: the page URL/title/text, the indexed element table (with roles, values, ARIA states), the goal, and the last 10 history entries (model.py:107-117). The request poses one operation question (CLICK/TYPE_TEXT/SELECT/SCROLL_UP/SCROLL_DOWN/WAIT/DONE/BLOCKED) plus one target question per eligible operation — two decision layers in one round trip (README:34-50). The TypeSafe model returns choice probabilities per head; the chosen target head is validated via validate_choice() and only that head's selection runs (model.py:120-133). If the operation is TYPE_TEXT, a separate call to a small OpenAI-compatible model (field_text(), model.py:160-198) generates the text value.
Act (line 86-161) consumes the decision (setting it to None to prevent double-clicks; line 91), executes via Browser.act() (browser.py:100-107), appends to history (line 121-141), and reobserves the page. Stop conditions: DONE/BLOCKED selection (agent.py:93-98), reaching MAX_STEPS (60; agent.py:102-104 and questions.py:26), or 3 consecutive non-wait actions that caused no page change (agent.py:153-158). The predictor-phase budget is MAX_STEPS * 2 model calls (agent.py:75-76). History persists between steps and the last 10 entries are included in each predict request.
browser-use/browser-harness
answeredbrowser-harness does not implement an agent loop, planner, or executor. It is a browser-control harness, not an agent framework.
What it is: The README states "Connect an LLM directly to your real browser through one editable CDP websocket." The project provides the transport layer — CDP helpers, a daemon for persistent connections, IPC for CLI and MCP access — but the agent loop itself is external. The calling agent (Claude Code, Codex, or any MCP client) is responsible for planning, tool-call orchestration, stop conditions, and inter-step memory.
MCP server as tool interface: The
mcp_server.pyfile (lines 138-291) exposes each browser helper as a named MCP tool (browser_click,browser_type,browser_goto,browser_screenshot, etc.). An MCP client calls these tools sequentially in its own loop. The daemon preserves the attached tab and CDP session across calls, providing continuity without the harness tracking steps.Helper tracing (observation only):
run.py:145-178implements_traced()which wraps every helper call to record: the helper name, truncated args (300 chars), duration in seconds, and any error message. This trace (_helper_trace) is capped at 500 entries (_MAX_TRACED_STEPSat line 145) and is used purely for telemetry, not for agent memory or loop control. The recorder (recorder.py) captures screenshots and event traces for human review and video production, not for agent planning.No planner/executor split: There is no
plannervsexecutordistinction, no tool-call schema (beyond the MCP tool definitions), and no stop-condition logic. The caller decides when to stop. The harness provideswait(),wait_for_load(),wait_for_element(), andwait_for_network_idle()as building blocks the caller can use in its own loop.CLI entry point:
run.py:240-302(main()) reads a heredoc script, auto-bootstraps the daemon, andexec()s the script. Each invocation is one-shot — there's no built-in iterative loop.
_traced() wrapper is not telemetry-only; after every successful helper call it also invokes recorder.observe, which writes a frame and an events.jsonl line when recording is enabled (run.py L174).browser-use/workflow-use
answeredThe primary execution model is a deterministic step loop, not an LLM agent loop. In Workflow.run() (service.py:851), the workflow iterates over self.schema.steps, resolving placeholder variables from a context dict using Python str.format(), then executing each step via _execute_step. Each step is a Pydantic discriminated union (WorkflowStep = DeterministicWorkflowStep | AgenticWorkflowStep). Deterministic steps are dispatched by type field (navigation, click, input, extract, etc.) and run through either the WorkflowController or the SemanticWorkflowExecutor — no LLM involvement. In run_with_no_ai() (service.py:1047), only semantic execution is used.
Agent steps: When a step has type: 'agent', _run_agent_step (service.py:329) constructs a browser_use Agent with the step's task as the task and a message_context showing the last 2, current, and next 2 steps for contextual awareness. An override_system_message from agent_step_system_prompt.md controls agent behavior. The agent runs with its own WorkflowStepAgentController and returns an AgentHistoryList.
Tool-call schema: For deterministic steps, the controller uses create_action_model from browser-use's registry to build a Pydantic action model, then calls controller.act(action_model, browser, ...) (service.py:235–244). No LLM tool calling is involved — the schema is purely for validation.
Stop conditions: The loop supports a cancel_event (asyncio.Event) for external cancellation (service.py:904–906). An output_model parameter with a Pydantic class drives an LLM-based conversion pass at the end (_convert_results_to_output_model) that aggregates all extracted_content from step results and uses the LLM to parse them into the target model (service.py:723–769). The schema validator requires the last step to be an extract or extract_page_content type (schema/views.py:240–256).
Memory between steps: A plain self.context: dict[str, Any] is maintained across the run. Steps can declare an output key (a string naming a context variable), and _store_output (service.py:586) stores either the JSON-parsed extracted_content from ActionResult or the last AgentHistoryList content into that key. Downstream steps reference values via Python format placeholders like {output_variable_name}.
hyperbrowserai/HyperAgent
answeredThe core agent loop is runAgentTask() in src/agent/tools/agent.ts:208. It is a single-step loop with no separate planner/executor distinction — each iteration captures DOM state, builds messages, invokes the LLM for one action, executes it, and repeats. Each LLM call returns a structured output validated via Zod: {thoughts: string, memory: string, action: union-schema} (src/types/agent/types.ts:6-21). The thoughts field captures the model's reasoning, memory accumulates state changes (e.g., "Clicked login button → login form appeared"), and action selects from available action types via a Zod discriminated union built by getActionSchema() (src/agent/tools/agent.ts:100).
Messages are constructed by buildAgentStepMessages() (src/agent/messages/builder.ts:9) which appends: the final goal, current URL, variables, previous action history (assistant thought/memory/action → user result), the DOM tree, and optionally a composited screenshot with scroll info. The system prompt (src/agent/messages/system-prompt.ts) describes input/output format, available actions, and guidelines (one action per step, use wait when unsure, avoid loops).
Stop conditions are checked at each iteration: TaskStatus.PAUSED sleeps 100ms and continues; endTaskStatuses (COMPLETED, FAILED, CANCELLED) breaks; maxSteps threshold cancels the task (src/agent/tools/agent.ts:303-306); and a consecutive failure/waits counter of 5 (MAX_CONSECUTIVE_FAILURES_OR_WAITS) fails the task if exceeded (src/agent/tools/agent.ts:267). The loop also tracks schema validation errors — up to 3 are fed back into the next step's messages for cross-step learning (src/agent/tools/agent.ts:400-413). LLM structured output has up to 3 retry attempts per step with Zod error feedback appended as user messages (src/agent/tools/agent.ts:424-508).
awlevin/typesafe-computer-use
answeredThe agent loop lives in runner.py:run(). It is a synchronous step loop: one capture + percept + decide + act cycle per iteration, up to --steps (default 100).
Step structure: run_step captures the screen (screenshot, app, window, field, URL), runs perceive() to produce the item list, constructs the state dict with goal, date context, previous actions, tried actions, and screen items, then calls decide(). That is a single TypeSafe system_one request with up to four Choice questions: kind (which action), item (which on-screen item — only for click_item), site (which website — only for use_browser), and offscreen (which hidden control — only for press_offscreen). The responses carry full probability distributions and calibrated confidence scores. (runner.py:284–337, decide.py:204–256)
Stop conditions are checked in resolve() after the decision: (1) done or none — goal achieved or impossible; (2) confidence below --min-confidence (0.4); (3) dry run (--act not passed). Then comes the deterministic action via perform(). (runner.py:340–369)
Stall detection uses a screen signature — the tuple of (app, URL, focused field, (text, row) pairs in reading order). Two captures differing by ≤1 line and ≤1-in-10 lines count as the same screen. Three consecutive idle actions (screen unchanged) or two consecutive repeated actions (same action on same screen) stop the run. Three stalls without reaching a new page produce stuck, which is final. (runner.py:372–417, models.py:91–117)
Writer handoff: When the classifier stops, hand_off() calls the writer model (the stronger CLICKER_ANSWER_MODEL, default claude-sonnet-5) with the screenshot, all screen text, earlier screens' text, the stop reason, and earlier stops with their focuses. The writer returns {achieved, answer, focus, question}. If the goal isn't reached, it can set a focus (one concrete next action for the classifier, e.g. "Click the 'Sort by price' button") and the loop resumes with that focus in state. Or it can ask a question for the user. Up to --handoffs 10 handoffs and 3 questions per run. A focus that produces no action leaves the prior answer standing. (runner.py:157–220, writer.py:332–423)
Memory between steps: The classifier receives the last 8 actions as previous_actions, the actions already tried on the current screen as already_tried_on_this_screen, and Guidance (current focus + user replies from the handoff). The writer gets the same plus earlier stops and earlier screens' text. The OCR cache carries one step's raw lines into the next via OcrCache. (decide.py:128–162, runner.py:87–96)
omdsh-dev/dsh-browser
answeredThe agent loop is owned by DeepSeek Harness itself - this repository is a plugin providing browser tools that DSH calls. The bridge registers tools via registerBrowserTools() (tools.ts:83-101) using defineTool() from @deepseek-ai/dsh-tools. Each tool declares typed parameters and timeoutMs. When DSH calls a tool, the bridge dispatches a tool.call frame over the WebSocket (server.ts:226-233) to the connected extension. The extension background receives it in routeToolCall() (background/index.ts:1058-1199), resolves the controlled tab via TabAffinityController (tab-affinity.ts), dispatches to the content script, and sends tool.result back. In-flight calls have a per-call timeout (default 90s, index.ts:56) tracked by setTimeout in BridgeServer.pendingTools (server.ts:111-115). The tool.cancel frame (protocol.ts:101-102) withdraws timed-out or cancelled calls. DSH maintains history between steps; the bridge adds a system-prompt section telling the model to call browser_snapshot on demand rather than hoarding page text (index.ts:262-272). Tab-affinity management ensures manual tab switches create a handoff decision that blocks dispatch until resolved (tab-affinity.ts:6-12). Session-to-tab bindings persist via PageSessionContextTracker (session-continuity.ts:40-88). The TransientEventCache (transient-events.ts:9-53) preserves panel state across reconnects. Sessions are deferred via withSessionDeferral() (session-deferral.ts:54-172) so they materialize only on first prompt.
droidrun/mobile-jev
answeredThe agent loop lives in runAgent() (agent.mjs:9-190). One agent loop step: observe → policy.decide → validate → (if execute) device.act → observe again → check stop conditions.
Step loop: Runs up to maxSteps iterations (default 10, max 100), with an extended attempt budget of maxSteps × 2 + 4 to accommodate stale-retry re-observations (agent.mjs:76). Each iteration calls policy.decide() (agent.mjs:78-85) which returns a decision with status and optionally an action.
Planner vs executor: Planning is a single-stage monolithic call — there is no separate planner/executor. TypeSafePolicy.decide() (policy.mjs:169-304) builds one JSON body containing state (goal, current app, editable status, visible text, an element index table, and the last 8 actions from history) plus questions (the operation choice + speculative target questions). This is sent as one request to the TypeSafe API (https://api.typesafe.ai/v1/systemone, policy.mjs:222-224).
Tool-call schema: The model receives choice-type questions with criteria maps. The operation question (policy.mjs:84-110) lists candidate operations: OPEN_APP, TAP, SCROLL_DOWN/UP/LEFT/RIGHT, TYPE_TEXT, system nav (BACK, HOME, ENTER), WAIT, DONE, BLOCKED — each with a human-readable description. Compatible targets (tap_target, scroll_target, text_value, app_target) are speculatively answered in the same request but only the selected branch is consumed (policy.mjs:237-258). Response validation via validateChoice() (policy.mjs:8-26) checks probability distributions sum to ≈1 and that the chosen item has the highest probability.
Stop conditions (agent.mjs:89-101): done (model says DONE), blocked (model says BLOCKED), step_limit (actions ≥ maxSteps), stuck (same action+observation fingerprint repeated), loading_timeout (consecutive WAITs exceed waitTimeoutMs, default 15s), unstable_screen (3 consecutive stale observations), decision_limit (budget exhausted), input_unverified (text not confirmed in field).
Memory between steps: The history array (agent.mjs:41) stores the last 8 action entries with operation, label, text, and screenChanged flag, passed into the next decide call (policy.mjs:208-213). The repeated set (agent.mjs:42) tracks observation.fingerprint:action JSON to detect action loops. Actions are logged before the post-action observation (agent.mjs:141-147) so a failed read cannot erase an executed action.
jkudish/jev-browser
answeredThe agent loop is a code-owned step loop in the navigate() function (src/navigate.ts:757-1066). Code controls the loop structure, budgets, and stop gates; the Jev model provides three independent judgments per step.
Step loop: a for loop runs up to maxSteps (default 24, src/navigate.ts:469). Each iteration:
- Check remaining time budget (deadline via
AbortController,src/navigate.ts:759) - Bot-protection probe — DOM-only detection of Cloudflare interstitials; if found, a settle window (up to 8s) checks if it auto-clears, otherwise the run stops with
blocked(src/navigate.ts:769-777) - Extract page — DOM extraction + action-space building (
src/navigate.ts:779-794) - Ask Jev — one primary call with three questions via the fan-out pattern (
src/navigate.ts:811-823): a Choice (which action), a goal_done Noul (is the goal achieved?), and a stuck Noul (is progress stalled?). The questions are independent — they cannot see each other's answers (src/questions.ts:14-26) - Stop gates — checked BEFORE action execution:
donechoice,goal_done > 0.85,stuck > 0.85after step 2 (src/navigate.ts:827-841) - Repeat-no-op recovery — if the same action repeated with no effect, switch to the next-best option from the Choice distribution (
src/navigate.ts:846-857) - Execute action — dispatch to Playwright (
src/navigate.ts:868-1012) - Settle — wait for DOM stability (two identical fingerprints) with a 1.5s cap (
src/navigate.ts:1019) - Tab adoption — if a new tab opened, switch to it (
src/navigate.ts:1020-1024) - Compare state — detect page changes for the trace and repeat detection (
src/navigate.ts:1027-1051)
Planner vs executor: there is no separate planner. Jev is the planner (one step ahead) and also the evaluator (goal/stuck). There is no memory between steps beyond history (the action/outcome pairs sent in each step's state) and lastRedundant/lastExecuted for repeat detection.
Select actions add a second Jev call for the dropdown option (src/navigate.ts:953-961).
Stop conditions (checked in order): agent chooses done, goal_done > 0.85, stuck > 0.85 and step > 2, max_steps, timeout, or blocked. The done and goal_achieved statuses are independent judgments — agreement between them is a trustworthy finish.
savka777/jev-use
answeredThe agent loop lives in AppModel.run() (JevDesktopApp.swift:397) and takes two forms. Default loop (no planner key): runCycles() (JevDesktopApp.swift:613-1010) runs up to 14 cycles. Each cycle: captures the Accessibility tree → builds a CycleState with elements, available apps/folders/sites/menus, recent actions, and dictation → sends one JevClient.cycle() request (Decision.swift:289) that asks for an operation (choice) plus speculative targets (choices for click_target, type_target, app_target, etc.) and several yes/no questions (finishes, create_first, every_window, counted) in a single model call → executes the chosen action → detects screen change → loops until DONE, BLOCKED, WAIT, or exhaustion. Planner path (with OpenRouter key): Planner.plan() (Planner.swift:137) sends the utterance to OpenRouter with a JSON schema (response_format: json_schema, Planner.swift:110-111) to decompose into ordered PlanStep kinds (open_app, open_url, click, type_text, press_key, etc.). Then each step is grounded via a narrow JevClient.ground() call (JevDesktopApp.swift:560) that asks Jev to select the correct on-screen target. Deterministic steps (press key, scroll, skip, open URL) execute without any model call (JevDesktopApp.swift:489-512). Stop conditions: DONE, BLOCKED, WAIT; three consecutive no-change actions stop; same pick three times stops; a 14-cycle hard cap. Memory between steps: recentActions holds the last 10 actions (Decision.swift:206). priorCommand and priorAction carry context across clarification questions (JevDesktopApp.swift:89-90). The JevClient.session is a keep-alive TLS connection (Decision.swift:306-310).
PlannerEnabled user default (set only via defaults write), so the default for every user is the per-cycle loop. WAIT is not a stop condition: it sleeps 0.4 s and the loop continues.razaanstha/ulka
answeredThe agent runs a two-tier loop: an outer FX (Helium) planner and an inner Jev subgoal executor. Outer FX loop (fx-agent.ts): runFxBrowser() creates an FX agent (powered by libfx WASM runtime) with a fixed set of tools: observe_browser, navigate_browser, browser_subgoal, search_web, plan_task, complete_task, read_page, extract_page, act_action, native_tabs, webmcp_call, ask_user, list_downloads. The FX agent is an LLM that plans and calls tools in a loop — it can plan_task to track milestones, browser_subgoal to delegate atomic work, and complete_task to verify. The loop runs up to 3 recovery attempts if verification fails (fx-agent.ts:280-330). Tool calls are capped at 24 (expanded to 36-48 when a plan with 3+ milestones exists) (fx-agent.ts:75,260). Inner Jev loop (agent-runner.ts): AgentRunner.run() implements a step loop for atomic subgoals. Each iteration: (1) observe page via CdpObserver.observe() or waitForChange(), (2) ask Jev for a decision via VercelJevDecisionEngine.decide(), (3) generate text if TYPE_TEXT, (4) check action approval policy, (5) execute via BrowserExecutor.execute(), (6) wait for page change via waitForChange(), (7) repeat until DONE or blocked. Jev decision-making (vercel-jev.ts): The VercelJevDecisionEngine.buildActionSpace() method constructs an ActionSpace from the snapshot — a map of valid operations to human-readable descriptions, and operation-specific target lists. This space is sent to the typesafe-ai/jev evaluation model via Gateway's HTTP API (SDK experimental_evaluate or raw HTTP fallback). Jev applies decisionRules() context (vercel-jev.ts:22-29) that adds combobox, date, and context rules when relevant. The Jev response must produce a valid choice with well-formed probabilities (summing to ~1, highest selected) (vercel-jev.ts:278-295). Stop conditions include: step limits (30 actions, 60 model calls), action repetition detection (hasIneffectiveRepetition, hasActionCycle in history.ts), excessive scroll-to-now-content (3 empty scrolls), page-state revisits (3 visits to same state), repeated stale targets (3 consecutive StaleDecisionError), and tool error cascades. Memory between steps is tracked via TaskMemory (agent-runner.ts:28-36): an action history array, attempts map (action key → count), stateVisits map (progress state → count), and an actionCache for CLICK/SELECT replay across subgoals.
browser_subgoal runs an AgentRunner capped at 8 actions and 16 model calls (runJevSubgoal in background.ts), and in subgoal mode the runner returns an unverified checkpoint after a URL change, typing, Escape or Jev's DONE.lahfir/agent-desktop
not applicableThis repository does not implement an agent loop, planner, or executor. It is a stateless CLI tool (59 commands in commands/mod.rs) that an external AI agent invokes per interaction—the observation-action loop lives in the calling agent, not in this tool. The binary processes CLI input, executes one command via dispatch() (src/dispatch/mod.rs:48-112), produces one JSON envelope, and exits. It has no tool-call schema for LLMs, no memory between steps (beyond optional filesystem sessions for trace/ref persistence), and no stop conditions. The public API re-export (lib.rs:156-279) confirms all exports are types/traits/commands for tool building, not loop infrastructure. The CLAUDE.md document explicitly states this design: 'agent-desktop is NOT an AI agent. It is a tool that AI agents invoke.'
ekzhang/openjev-sglang
not applicableThere is no agent loop, planner, executor, or multi-step reasoning chain in this project. Every request is a single stateless classification: render the chat template once, split into a common prefix and question-specific suffixes, send each branch as an independent one-token generation, and return the renormalized logprobs. The only loop is the concurrent-fan-out pattern in service.py:74-85 where all N branches fire simultaneously via asyncio.gather. There is no memory between requests, no step loop, no planning phase, and no tool-call schema for an LLM to invoke. The system has exactly one endpoint, /v1/systemone, for one-shot evaluation.
← How are actions executed and how are elements targeted? · How are failures, retries and self-healing handled? →