Skip to content

Commit 7cbef31

Browse files
author
SentienceDEV
committed
updated readme
1 parent 887ca96 commit 7cbef31

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sentience Python SDK
22

3-
**Semantic geometry grounding for deterministic, debuggable AI web agents with time-travel traces.**
3+
**Semantic snapshots and Jest-style assertions for reliable AI web agents with time-travel traces**
44

55
## 📦 Installation
66

@@ -22,6 +22,55 @@ pip install transformers torch # For local LLMs
2222
pip install -e .
2323
```
2424

25+
## Jest for AI Web Agent
26+
27+
### Semantic snapshots and assertions that let agents act, verify, and know when they're done.
28+
29+
Use `AgentRuntime` to add Jest-style assertions to your agent loops. Verify browser state, check task completion, and get clear feedback on what's working:
30+
31+
```python
32+
import asyncio
33+
from sentience import AsyncSentienceBrowser, AgentRuntime
34+
from sentience.verification import url_contains, exists, all_of
35+
from sentience.tracing import Tracer, JsonlTraceSink
36+
37+
async def main():
38+
# Create tracer
39+
tracer = Tracer(run_id="my-run", sink=JsonlTraceSink("trace.jsonl"))
40+
41+
# Create browser and runtime
42+
async with AsyncSentienceBrowser() as browser:
43+
page = await browser.new_page()
44+
runtime = await AgentRuntime.from_sentience_browser(
45+
browser=browser,
46+
page=page,
47+
tracer=tracer
48+
)
49+
50+
# Navigate and take snapshot
51+
await page.goto("https://example.com")
52+
runtime.begin_step("Verify page loaded")
53+
await runtime.snapshot()
54+
55+
# Run assertions (Jest-style)
56+
runtime.assert_(url_contains("example.com"), label="on_correct_domain")
57+
runtime.assert_(exists("role=heading"), label="has_heading")
58+
runtime.assert_(all_of([
59+
exists("role=button"),
60+
exists("role=link")
61+
]), label="has_interactive_elements")
62+
63+
# Check task completion
64+
if runtime.assert_done(exists("text~'Example'"), label="task_complete"):
65+
print("✅ Task completed!")
66+
67+
print(f"Task done: {runtime.is_task_done}")
68+
69+
asyncio.run(main())
70+
```
71+
72+
**See example:** [`examples/agent_runtime_verification.py`](examples/agent_runtime_verification.py)
73+
2574
## 🚀 Quick Start: Choose Your Abstraction Level
2675

2776
Sentience SDK offers **three abstraction levels** - use what fits your needs:

0 commit comments

Comments
 (0)