Skip to content

Commit d61e845

Browse files
author
SentienceDEV
committed
fix model name
1 parent 6afb67d commit d61e845

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

sentience/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def act(
203203
{
204204
"prompt_tokens": llm_response.prompt_tokens,
205205
"completion_tokens": llm_response.completion_tokens,
206-
"model": llm_response.model,
206+
"model": llm_response.model_name,
207207
"response": llm_response.content[:200], # Truncate for brevity
208208
},
209209
step_id=step_id,

sentience_python.egg-info/PKG-INFO

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.4
22
Name: sentience-python
3-
Version: 0.11.0
3+
Version: 0.12.0
44
Summary: Python SDK for Sentience AI Agent Browser Automation
55
Author: Sentience Team
66
License: MIT
@@ -485,6 +485,86 @@ cd sentience-chrome
485485
- Check visibility: `element.in_viewport and not element.is_occluded`
486486
- Scroll to element: `browser.page.evaluate(f"window.sentience_registry[{element.id}].scrollIntoView()")`
487487

488+
## Advanced Features (v0.12.0+)
489+
490+
### Agent Tracing & Debugging
491+
492+
The SDK now includes built-in tracing infrastructure for debugging and analyzing agent behavior:
493+
494+
```python
495+
from sentience import SentienceBrowser, SentienceAgent
496+
from sentience.llm_provider import OpenAIProvider
497+
from sentience.tracing import Tracer, JsonlTraceSink
498+
from sentience.agent_config import AgentConfig
499+
500+
# Create tracer to record agent execution
501+
tracer = Tracer(
502+
run_id="my-agent-run-123",
503+
sink=JsonlTraceSink("trace.jsonl")
504+
)
505+
506+
# Configure agent behavior
507+
config = AgentConfig(
508+
snapshot_limit=50,
509+
temperature=0.0,
510+
max_retries=1,
511+
capture_screenshots=True
512+
)
513+
514+
browser = SentienceBrowser()
515+
llm = OpenAIProvider(api_key="your-key", model="gpt-4o")
516+
517+
# Pass tracer and config to agent
518+
agent = SentienceAgent(browser, llm, tracer=tracer, config=config)
519+
520+
with browser:
521+
browser.page.goto("https://example.com")
522+
523+
# All actions are automatically traced
524+
agent.act("Click the sign in button")
525+
agent.act("Type 'user@example.com' into email field")
526+
527+
# Trace events saved to trace.jsonl
528+
# Events: step_start, snapshot, llm_query, action, step_end, error
529+
```
530+
531+
**Trace Events Captured:**
532+
- `step_start` - Agent begins executing a goal
533+
- `snapshot` - Page state captured
534+
- `llm_query` - LLM decision made (includes tokens, model, response)
535+
- `action` - Action executed (click, type, press)
536+
- `step_end` - Step completed successfully
537+
- `error` - Error occurred during execution
538+
539+
**Use Cases:**
540+
- Debug why agent failed or got stuck
541+
- Analyze token usage and costs
542+
- Replay agent sessions
543+
- Train custom models from successful runs
544+
- Monitor production agents
545+
546+
### Snapshot Utilities
547+
548+
New utility functions for working with snapshots:
549+
550+
```python
551+
from sentience import snapshot
552+
from sentience.utils import compute_snapshot_digests, canonical_snapshot_strict
553+
from sentience.formatting import format_snapshot_for_llm
554+
555+
snap = snapshot(browser)
556+
557+
# Compute snapshot fingerprints (detect page changes)
558+
digests = compute_snapshot_digests(snap.elements)
559+
print(f"Strict digest: {digests['strict']}") # Changes when text changes
560+
print(f"Loose digest: {digests['loose']}") # Only changes when layout changes
561+
562+
# Format snapshot for LLM prompts
563+
llm_context = format_snapshot_for_llm(snap, limit=50)
564+
print(llm_context)
565+
# Output: [1] <button> "Sign In" {PRIMARY,CLICKABLE} @ (100,50) (Imp:10)
566+
```
567+
488568
## Documentation
489569

490570
- **📖 [Amazon Shopping Guide](../docs/AMAZON_SHOPPING_GUIDE.md)** - Complete tutorial with real-world example

sentience_python.egg-info/SOURCES.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ pyproject.toml
55
sentience/__init__.py
66
sentience/actions.py
77
sentience/agent.py
8+
sentience/agent_config.py
89
sentience/base_agent.py
910
sentience/browser.py
1011
sentience/cli.py
1112
sentience/conversational_agent.py
1213
sentience/expect.py
14+
sentience/formatting.py
1315
sentience/generator.py
1416
sentience/inspector.py
1517
sentience/llm_provider.py
@@ -19,7 +21,10 @@ sentience/read.py
1921
sentience/recorder.py
2022
sentience/screenshot.py
2123
sentience/snapshot.py
24+
sentience/tracing.py
25+
sentience/utils.py
2226
sentience/wait.py
27+
sentience/schemas/trace_v1.json
2328
sentience_python.egg-info/PKG-INFO
2429
sentience_python.egg-info/SOURCES.txt
2530
sentience_python.egg-info/dependency_links.txt
@@ -32,8 +37,10 @@ spec/sdk-types.md
3237
spec/snapshot.schema.json
3338
tests/test_actions.py
3439
tests/test_agent.py
40+
tests/test_agent_config.py
3541
tests/test_bot.py
3642
tests/test_conversational_agent.py
43+
tests/test_formatting.py
3744
tests/test_generator.py
3845
tests/test_inspector.py
3946
tests/test_query.py
@@ -44,4 +51,6 @@ tests/test_smart_selector.py
4451
tests/test_snapshot.py
4552
tests/test_spec_validation.py
4653
tests/test_stealth.py
54+
tests/test_tracing.py
55+
tests/test_utils.py
4756
tests/test_wait.py

0 commit comments

Comments
 (0)