Skip to content

Commit 4aa3490

Browse files
author
SentienceDEV
committed
browser use integration plugin
1 parent 59125ce commit 4aa3490

File tree

6 files changed

+680
-3
lines changed

6 files changed

+680
-3
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ All notable changes to the Sentience Python SDK will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
### 2026-02-13
11+
12+
#### Expanded deterministic verifications (adaptive resnapshotting)
13+
14+
When you use `.eventually()` for deterministic checks, you can now **automatically increase the snapshot element limit across retries**. This helps on long / virtualized pages where a small snapshot limit can miss the target element, causing a false failure.
15+
16+
- **AgentRuntime verifications**: `AssertionHandle.eventually(..., snapshot_limit_growth=...)`
17+
- **Expect-style verifications**: `with_eventually(..., snapshot_limit_growth=...)`
18+
- **Commit**: `59125ce19001c457336dccbb3c9463560bd00245`
19+
20+
**Example**
21+
22+
```python
23+
from predicate.verification import exists
24+
25+
# Grow snapshot limit on each retry until the element appears.
26+
await dbg.check(exists("text~'Checkout'"), label="checkout_visible", required=True).eventually(
27+
timeout_s=12,
28+
snapshot_limit_growth={
29+
"start_limit": 60,
30+
"step": 40,
31+
"max_limit": 220,
32+
"apply_on": "only_on_fail", # default; or "all"
33+
},
34+
)
35+
```
36+
837
## [0.12.0] - 2025-12-26
938

1039
### Added

predicate/backends/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@
9797
)
9898
from .playwright_backend import PlaywrightBackend
9999
from .protocol import BrowserBackend, LayoutMetrics, ViewportInfo
100-
from .sentience_context import SentienceContext, SentienceContextState, TopElementSelector
100+
from .sentience_context import (
101+
PredicateContext,
102+
PredicateContextState,
103+
SentienceContext,
104+
SentienceContextState,
105+
TopElementSelector,
106+
)
101107
from .snapshot import CachedSnapshot, snapshot
102108

103109
__all__ = [
@@ -117,6 +123,9 @@
117123
# SentienceContext (Token-Slasher Context Middleware)
118124
"SentienceContext",
119125
"SentienceContextState",
126+
# PredicateContext (rebrand alias)
127+
"PredicateContext",
128+
"PredicateContextState",
120129
"TopElementSelector",
121130
# Backend-agnostic functions
122131
"snapshot",

predicate/backends/sentience_context.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
Example usage:
88
from browser_use import Agent
9-
from predicate.backends import SentienceContext
9+
from predicate.backends import PredicateContext
1010
11-
ctx = SentienceContext(show_overlay=True)
11+
ctx = PredicateContext(show_overlay=True)
1212
state = await ctx.build(agent.browser_session, goal="Click the first Show HN post")
1313
if state:
1414
agent.add_context(state.prompt_block) # or however browser-use injects state
@@ -469,3 +469,12 @@ def _compress_href(self, href: str | None) -> str:
469469
pass
470470

471471
return "item"
472+
473+
474+
# ---------------------------------------------------------------------------
475+
# Predicate-named counterparts (canonical moving forward).
476+
# Keep Sentience* names for backward compatibility.
477+
# ---------------------------------------------------------------------------
478+
479+
PredicateContext = SentienceContext
480+
PredicateContextState = SentienceContextState
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
Browser Use integration (Predicate plugin).
3+
4+
This package provides a low-friction integration layer that lets browser-use users
5+
attach Predicate's deterministic verification (AgentRuntime / PredicateDebugger)
6+
to existing Browser Use agent loops via lifecycle hooks and optional tools.
7+
8+
Public surface is intentionally small and may evolve.
9+
"""
10+
11+
from __future__ import annotations
12+
13+
from typing import TYPE_CHECKING, Any
14+
15+
if TYPE_CHECKING: # pragma: no cover
16+
from .plugin import (
17+
PredicateBrowserUsePlugin,
18+
PredicateBrowserUsePluginConfig,
19+
PredicateBrowserUseVerificationError,
20+
StepCheckSpec,
21+
)
22+
23+
__all__ = [
24+
"PredicateBrowserUsePlugin",
25+
"PredicateBrowserUsePluginConfig",
26+
"PredicateBrowserUseVerificationError",
27+
"StepCheckSpec",
28+
]
29+
30+
31+
def __getattr__(name: str) -> Any: # pragma: no cover
32+
if name in __all__:
33+
from .plugin import ( # local import keeps linting/packaging robust
34+
PredicateBrowserUsePlugin,
35+
PredicateBrowserUsePluginConfig,
36+
PredicateBrowserUseVerificationError,
37+
StepCheckSpec,
38+
)
39+
40+
return {
41+
"PredicateBrowserUsePlugin": PredicateBrowserUsePlugin,
42+
"PredicateBrowserUsePluginConfig": PredicateBrowserUsePluginConfig,
43+
"PredicateBrowserUseVerificationError": PredicateBrowserUseVerificationError,
44+
"StepCheckSpec": StepCheckSpec,
45+
}[name]
46+
raise AttributeError(name)
47+

0 commit comments

Comments
 (0)