feat(browser): make snapshot threshold configurable
This commit is contained in:
@@ -568,11 +568,12 @@ def camofox_navigate(url: str, task_id: Optional[str] = None) -> str:
|
||||
)
|
||||
snapshot_text = snap_data.get("snapshot", "")
|
||||
from tools.browser_tool import (
|
||||
SNAPSHOT_SUMMARIZE_THRESHOLD,
|
||||
get_browser_snapshot_threshold,
|
||||
_truncate_snapshot,
|
||||
)
|
||||
if len(snapshot_text) > SNAPSHOT_SUMMARIZE_THRESHOLD:
|
||||
snapshot_text = _truncate_snapshot(snapshot_text)
|
||||
threshold = get_browser_snapshot_threshold()
|
||||
if len(snapshot_text) > threshold:
|
||||
snapshot_text = _truncate_snapshot(snapshot_text, max_chars=threshold)
|
||||
result["snapshot"] = snapshot_text
|
||||
result["element_count"] = snap_data.get("refsCount", 0)
|
||||
except Exception:
|
||||
@@ -654,12 +655,13 @@ def camofox_snapshot(full: bool = False, task_id: Optional[str] = None,
|
||||
# line boundaries, store the full tree to cache/web, append a
|
||||
# read_file pointer.
|
||||
from tools.browser_tool import (
|
||||
SNAPSHOT_SUMMARIZE_THRESHOLD,
|
||||
get_browser_snapshot_threshold,
|
||||
_truncate_snapshot,
|
||||
)
|
||||
|
||||
if len(snapshot) > SNAPSHOT_SUMMARIZE_THRESHOLD:
|
||||
snapshot = _truncate_snapshot(snapshot)
|
||||
threshold = get_browser_snapshot_threshold()
|
||||
if len(snapshot) > threshold:
|
||||
snapshot = _truncate_snapshot(snapshot, max_chars=threshold)
|
||||
|
||||
return json.dumps({
|
||||
"success": True,
|
||||
@@ -970,4 +972,3 @@ def camofox_console(clear: bool = False, task_id: Optional[str] = None) -> str:
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user