Commit Graph

8766 Commits

Author SHA1 Message Date
Saurav Panda d795dbe0f8 Update pyproject.toml 2026-02-05 20:54:38 -08:00
laithrw 96dcc2c475 fix: hide StructuredOutputAction.success from LLM schema to prevent field name collisions (#4044)
- When a user's output_model_schema has a field called success, the LLM
sees success at two nesting levels in the done action and gets confused.
It flattens them and drops data entirely
- bu-1-0 fails every time; bu-2-0 handles it fine
- Fix hides success from the schema sent to the LLM while keeping the
field on the model

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Hide StructuredOutputAction.success from the LLM-exposed JSON schema to
avoid collisions when user output models also define success. This
prevents the LLM from flattening fields and dropping data in done
responses.

- **Bug Fixes**
- Strip 'success' from StructuredOutputAction JSON schema via
json_schema_extra so the LLM only sees the user data schema.
- Keep success on the server model; done continues to serialize only
params.data (no breaking change).

<sup>Written for commit 04da1fd30c.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-05 23:49:09 -05:00
laithrw d86be39eeb Merge branch 'main' into fix/structured-output-schema-collision 2026-02-05 23:44:03 -05:00
Saurav Panda ed2f5bd3ac added message compaction for agent (#4042)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds automatic message compaction to keep the agent’s prompt small when
history grows large. This reduces token usage and prevents runaway
context size.

- **New Features**
- Configurable MessageCompactionSettings (step cadence, char/token
thresholds, keep_last_items, summary_max_chars, optional
include_read_state, optional compaction_llm).
- Summarizes long histories into compacted_memory and injects it at the
top of the prompt; keeps the first item and the last N items.
- Compaction runs during context prep, triggered on step intervals with
a char/token threshold floor.
- Sensitive data is filtered before compaction; token cost tracking
includes the compaction LLM.
- New state fields track compaction metadata; added prepare_step_state
and skip_state_update to avoid redundant updates.

<sup>Written for commit d1c9a38c00.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-05 20:32:04 -08:00
Saurav Panda d1c9a38c00 Merge branch 'main' into message-compaction 2026-02-05 20:29:03 -08:00
Saurav Panda 6b9910a546 changed the threshold for compaction 2026-02-05 16:41:08 -08:00
Laith Weinberger 04da1fd30c strip success from JSON schema so invisible to the LLM, avoiding confusion 2026-02-05 16:49:36 -05:00
Saurav Panda 79501fe2cd added message compaction for agent 2026-02-05 12:26:11 -08:00
Saurav Panda 257f89ac01 added milder nudge for action loop (#4039)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Softened the action-loop and page-stagnation nudges to be
awareness-focused, keeping detection thresholds unchanged and removing
directive language.

- **Refactors**
- Reworded loop nudges at 5/8/12 repeats to use “Heads up” and encourage
checking progress.
- Made page-stagnation message gentler and suggest trying a different
element or approach.
- Updated tests to match new phrasing and confirm no “done” or “cannot
be completed” directives.

<sup>Written for commit 3c57cdc756.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-05 12:14:15 -08:00
Saurav Panda 3c57cdc756 Merge branch 'main' into update-action-loop-prompt 2026-02-05 12:08:33 -08:00
Saurav Panda c0a9cb5cc7 updated default max step to 500 (#4040)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Increased the default max_steps from 100 to 500 in agent run and
run_sync to allow longer executions by default.
This lets agents complete more complex tasks without needing manual
configuration.

<sup>Written for commit 995cb0176b.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-05 11:33:30 -08:00
Saurav Panda 995cb0176b updated default max step to 500 2026-02-05 11:20:47 -08:00
Saurav Panda bb5914f251 added milder nudge for action loop 2026-02-05 11:17:20 -08:00
laithrw b4a423edb0 fix: correct docker build context path in build-base-images.sh (#4018)
The build context on line 27 was set to ../../.. but the script cd's
into docker/ at the start, so only .. is needed to reach the repo root.
Running it as-is would point docker build to the wrong directory and
fail.

Fixes #4011

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixed the Docker build context in docker/build-base-images.sh to use ..
instead of ../../.. because the script runs from docker/. This points
builds at the repo root and avoids failures; fixes #4011.

<sup>Written for commit 1d9ae7e8ca.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-04 21:46:32 -05:00
laithrw 1d9ae7e8ca Merge branch 'main' into fix/docker-build-context-path 2026-02-04 21:44:25 -05:00
laithrw 69cb06d545 fix(#3657): agent not switching tabs after new opened (#4034)
Include in agent context that new tab was opened

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Notify the agent when a click opens a new browser tab so it knows to
switch to it. Addresses #3657 where the agent stayed on the old tab
after actions that opened a new page.

- **Bug Fixes**
- Detect new tabs by comparing tab IDs before and after clicks in
_click_by_coordinate and _click_by_index.
- Append a note to the action memory with the new tab’s short ID,
prompting the agent to switch.

<sup>Written for commit 99be7b1b48.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-04 21:26:35 -05:00
laithrw 99be7b1b48 Merge branch 'main' into fix/no-tab-switch 2026-02-04 21:24:34 -05:00
laithrw 5d19f5704a Add HarRecordingWatchdog for HTTPS HAR capture (#3543)
#3063

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Add HarRecordingWatchdog to capture HTTPS network traffic via CDP and
write a HAR 1.2 file on browser shutdown. Auto-attaches when
browser_profile.record_har_path is set and supports configurable content
storage and capture modes.

- **New Features**
- Records HTTPS requests/responses (bodies and request postData) and
saves to browser_profile.record_har_path on stop.
- Supports record_har_content: embed (text or base64), attach (sidecar
dir: <har_stem>_har_parts), or omit.
- Supports record_har_mode: full or minimal (main doc + same-origin
subresources).
- Adds browser/version metadata, page refs, and DOMContentLoaded/load
timings.

- **Migration**
  - Set browser_profile.record_har_path to enable.
- Optional: configure record_har_content (embed|attach|omit) and
record_har_mode (full|minimal).

<sup>Written for commit 9d81f64b2e.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Introduce HarRecordingWatchdog to capture HTTPS traffic via CDP and
write a HAR 1.2 file on shutdown, configurable for content storage and
capture scope, and auto-attached to sessions.
> 
> - **Watchdogs**:
>   - **HarRecordingWatchdog (new)**:
> - Captures HTTPS requests/responses via CDP (`Network`, `Page`) and
writes HAR 1.2 on `BrowserStopEvent`.
> - Configurable: `record_har_content` (embed/attach/omit) with sidecar
dir for attach; `record_har_mode` (full/minimal).
> - Records response bodies, headers, sizes, compression, timings;
includes pages with titles and DOMContentLoaded/load metrics; embeds
browser metadata.
> - **Session Integration**:
> - Import, initialize, and attach `HarRecordingWatchdog` in
`BrowserSession.attach_all_watchdogs()` (auto-enabled when
`record_har_path` is set).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b53a593d33. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-02-04 21:19:35 -05:00
laithrw 9d81f64b2e Merge branch 'main' into kalil0321/har_watchdog 2026-02-04 21:17:10 -05:00
Laith Weinberger 7455b3c1af deduplicate code; allow CDP events to propagate; error handling 2026-02-04 21:14:14 -05:00
Laith Weinberger d66181cdc6 notify agent if new tab opened 2026-02-04 21:02:13 -05:00
Saurav Panda f21bbb3f31 increased threshold for loop detection (#4033)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Raised loop detection thresholds and expanded the window to reduce false
positives and make nudges less aggressive. Also updated the simple judge
to include today's date so recent timestamps aren’t flagged as
fabricated.

- **Refactors**
- Increased default loop_detection_window from 10 to 20; repetition
thresholds now trigger at 5/8/12, and page stagnation at 5 consecutive
identical pages.
- Improved action hashing: renamed click_element/input_text to
click/input for hashing, scroll hashes include element index, and
wait/done/go_back actions are excluded from loop tracking.

- **Bug Fixes**
- Fewer false-positive loop warnings, especially around waits, terminal
actions, and repeated scrolls.
- Critical loop message no longer instructs calling “done”; it suggests
trying a different approach or reporting progress.
- Judge prompt includes today’s date and clarifies that near-current
timestamps are not fabricated, reducing false failures.

<sup>Written for commit 332694bf1a.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-04 17:20:18 -08:00
Saurav Panda 332694bf1a Added date info to simple judge 2026-02-04 17:04:39 -08:00
Saurav Panda cec4aea3bc increased threshold for loop detection 2026-02-04 16:34:42 -08:00
Saurav Panda 257b834273 improve text field handling (#4023)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Improves text input reliability by auto-fixing concatenated values when
clearing fails and by adding a short delay for JS-driven autocomplete
fields to let suggestions appear.

- **Bug Fixes**
- Auto-retry: if clear=True and readback shows old+new text, set the
value via the element’s native setter and dispatch input/change events
to match the intended text.
- Autocomplete/combobox: detect these fields and wait 400ms after typing
so the dropdown can populate before the next action. Skip delay for
native datalist inputs.

<sup>Written for commit d24dea0aa4.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-03 18:39:44 -08:00
Saurav Panda d24dea0aa4 Merge branch 'main' into improve-input-field-handling 2026-02-03 18:22:19 -08:00
Saurav Panda 5d7ff041d3 improved concatenation heuristic 2026-02-03 18:02:58 -08:00
Saurav Panda 4d69796045 Action Loop detection (#4027)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds behavioral loop detection to the agent with escalating context
nudges when actions repeat or the page doesn’t change, reducing wasted
steps. Includes normalized action hashing and page fingerprints, with
settings to enable and size the detector.

- **New Features**
- Added ActionLoopDetector with a rolling window to track action
repetition and page stagnation; nudges at 3/5/8 repeats and after 3
stagnant pages.
- Introduced PageFingerprint and normalized action hashing for search,
click, input, navigate, and scroll.
- Integrated into Agent: new settings (loop_detection_window,
loop_detection_enabled), records actions/page state, and injects nudges
into context messages.
- Added comprehensive tests covering hashing, detector behavior, page
stagnation, and agent integration.

<sup>Written for commit bbf3cc0164.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-03 17:20:12 -08:00
Saurav Panda bbf3cc0164 Merge branch 'main' into action-detection-loop 2026-02-03 17:18:06 -08:00
Saurav Panda b96b9436fc fixed agent loop detection 2026-02-03 16:00:08 -08:00
Saurav Panda bd4ead5d2e Action Loop detection 2026-02-03 15:19:59 -08:00
laithrw 045ad9d170 feat: read_long_content action for long webpages and files (#3994)
Made read_file smarter for PDFs - instead of just reading the first 20
pgs, it reads up to 60k chars and uses IDF scoring to prioritize pgs w
unique content

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds read_long_content to quickly find and extract relevant info from
long webpages and files. Also upgrades PDF reading to prioritize
distinctive pages and respect a 60k-char budget with clear page markers.

- **New Features**
- read_long_content: intelligently reads the current page or files,
extracts 3–5 search terms from the goal, and returns only the most
relevant sections (or PDF pages) up to ~50k chars.
- Smarter PDF reading: reads all content when under 60k chars; otherwise
scores pages using IDF, always includes page 1, and adds page markers
plus a truncation note with skipped pages.

- **Bug Fixes**
- Restricted read_long_content file access to whitelisted paths
(available_file_paths or downloaded files) to mitigate injection risks.
- Prevented negative slice indices when fitting the last page into the
remaining char budget and truncated overbudget pages instead of dropping
them.

<sup>Written for commit f9c36f11a4.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-03 18:02:56 -05:00
Laith Weinberger f9c36f11a4 lint 2026-02-03 17:59:24 -05:00
laithrw bcb5a2ad63 Merge branch 'main' into feat/smart-pdf-reading 2026-02-03 17:44:37 -05:00
laithrw 07241b58c9 fix(#3619): add hidden content hints for iframes in DOM context (#3941)
Resolves 3619. Elements in iframes beyond viewport threshold are
filtered from selector_map, causing agents to scroll excessively and
blindly to find them.

Added hints to the LLM context indicating hidden content:
- "N more interactive elements below - scroll to reveal" when
buttons/inputs are hidden
- "more content below viewport - scroll to reveal" when only
text/content is hidden

The hints also include the locations of each element, mapping distance
directly to the scroll(pages=N) action, allowing the agent to jump
directly to hidden content instead of scrolling incrementally.

Example:
... (3 more elements below - scroll to reveal):
<button> "Target Button Far Down" ~5.3 pages down
      <button> "Submit Final Form Button" ~7.3 pages down


<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes #3619 by adding iframe hidden content hints in the DOM context so
agents know exactly how far to scroll instead of searching blindly. Also
makes the viewport threshold configurable.

- **New Features**
- Collect hidden interactive elements per iframe and store details (tag,
text, pages down) in hidden_elements_info.
- Serializer adds context lines: "... (N more elements below - scroll to
reveal)" with per-element hints like <tag> "text" ~X pages down, or a
generic "... (more content below viewport - scroll to reveal)" when only
non-interactive content is hidden.
- New viewport_threshold option in DOM service (default 1000px). Set to
None to disable viewport-based filtering.

<sup>Written for commit a511ba2f1e.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-03 17:44:02 -05:00
Laith Weinberger 799e714c2b mitigate injection; don't drop overbudget pages
- restricted read_long_content file access to only paths in available_file_paths or browser_session.download_files to mitigate injection
- made PDF page selection truncate pages that exceed char budget instead of dropping them entirely
- fixed truncation hint in file_system.py to reference read_long_context instead of search_page
2026-02-03 17:42:02 -05:00
laithrw a511ba2f1e Merge branch 'main' into 3619 2026-02-03 17:32:46 -05:00
Saurav Panda 2a5768f3da fixed pyright issues 2026-02-03 13:02:03 -08:00
Saurav Panda 749fa56d1a improve text field handling 2026-02-03 12:52:56 -08:00
Laith Weinberger 38fb5b12df Merge remote-tracking branch 'origin/main' into feat/smart-pdf-reading 2026-02-03 14:15:49 -05:00
Shobhit Sahani 51dbeff043 fix: correct docker build context path in build-base-images.sh
Build context was set to ../../.. but the script cd's into docker/ on
line 31, so only .. is needed to reach the repo root. This caused the
build to fail when running from the repo root.

Fixes #4011

fix: add missing newline at end of file

fix: remove accidental heredoc wrapper from build script
2026-02-03 11:23:20 +00:00
Saurav Panda 4d5794ad7d updated agent success with simple judge (#4014)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds a lightweight, always-on judge that validates agent success using
only the task and final response to reduce false positives. The full
judge now logs verdicts without changing success; the simple judge can
override success when requirements aren’t met.

- **New Features**
- Simple judge: text-only check runs at completion and flips success to
failure when the final result doesn’t fully satisfy the task; adds a
brief note to extracted content.
- New SimpleJudgeResult schema and construct_simple_judge_messages
helper.

- **Refactors**
- Full judge no longer overrides success; it attaches verdicts and logs
differences for telemetry comparison.
- Simple judge runs only when the agent self-reports success and ignores
errors to avoid unintended overrides.

<sup>Written for commit da5b4237ba.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-02 23:04:30 -08:00
Saurav Panda da5b4237ba fixed lint issue 2026-02-02 23:01:52 -08:00
Saurav Panda 0dba38ed95 Merge branch 'main' into align-agent-success-with-judge 2026-02-02 22:16:11 -08:00
Saurav Panda 8565c7d267 updated agent success with simple judge 2026-02-02 22:14:45 -08:00
Saurav Panda c94f5b3d27 align agent success with simple judge (#4009)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Agent-reported success is now overridden by the simple judge. Prompts
require verification before calling done; if the judge flags failure, we
trigger one extra retry and handle no-task cases safely.

- **New Features**
- Added detailed pre_done_verification rules to standard, no_thinking,
anthropic_flash, flash, and flash_anthropic prompts.
- Judge-driven retry: one automatic retry when the simple judge
evaluates failure; safe fallback when the judge receives no task.

<sup>Written for commit bce72138c4.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-02 21:57:56 -08:00
Saurav Panda 65405d8a79 Merge branch 'main' into align-agent-success-with-judge 2026-02-02 21:50:02 -08:00
Saurav Panda bce72138c4 fixed lint issue 2026-02-02 21:49:48 -08:00
Saurav Panda ba64bcc2ad added basic planing to agents (#4008)
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Adds basic inline planning to agents. Agents now create a high‑level
plan, track progress, and can replan after stalls, improving reliability
and clarity.

- **New Features**
- Planning on by default with three settings: enable_planning,
planning_replan_on_stall, and planning_exploration_limit.
- New state: plan (list of steps), current step index, plan generation
step.
- Model output supports optional fields: current_plan_item and
plan_update. Flash mode disables planning and removes these fields.
- Plan is rendered into the agent context (<plan>) with status markers
([x], [>], [ ], [-]) and updates are applied after each step.
- Nudges: replan after N consecutive failures, and planning nudge after
N steps without a plan.
  - System prompts updated with planning instructions.
- Added CI tests for plan creation, advancement, replanning, rendering,
nudges, schemas, and edge cases.

- **Migration**
- No breaking changes. Planning is enabled by default; disable with
enable_planning=False.
- current_plan_item and plan_update are optional; consumers don’t need
changes.
  - Set planning_replan_on_stall=0 to disable replan nudges.
- Set planning_exploration_limit=0 to disable planning exploration
nudges.

<sup>Written for commit 4d5976c427.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
2026-02-02 21:49:19 -08:00
Saurav Panda 4d5976c427 Merge branch 'main' into improve-agent-planning 2026-02-02 21:45:06 -08:00