Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion openzero/brain/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,8 @@ def local_reply_token_budget(prompt: str, agent_mode: str = "chat") -> int:
)
if any(marker in text for marker in concise_markers):
return 96
if "**[moltbot browser]**" in text:
return 192
return 1024 if str(agent_mode or "").lower() == "terminal" else 768


Expand Down Expand Up @@ -4911,6 +4913,14 @@ def voice_transcribe():
return jsonify(result)


def autonomous_checkpoint_tool_result(action: Dict[str, object]) -> str:
"""Keep browser evidence useful without overflowing the local model context."""

result = str(action.get("result") or "")
if str(action.get("tool") or "") == "moltbot_browse" and len(result) > 5000:
return result[:5000].rstrip() + "\n...[browser result compacted for local summary]..."
return result

def deterministic_browser_inspection_reply(state: Dict[str, object]) -> str:
"""Return the initial read-only browser action without spending a model call."""

Expand Down Expand Up @@ -5309,7 +5319,7 @@ def execute_autonomous_run(

state = AUTONOMOUS_RUN_STORE.checkpoint_action_result(
run_id,
current_prompt=f"Tool proposal/result:\n{action_result}",
current_prompt=f"Tool proposal/result:\n{autonomous_checkpoint_tool_result(action)}",
last_safe_result=action_result,
usage_delta={
"tool_calls": 0
Expand Down
3 changes: 3 additions & 0 deletions openzero/tests/test_autonomous_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,9 @@ def test_plain_conversation_and_model_format_recovery_are_guarded(self):
self.assertIn("def model_reply_retry_reason(", self.source)
self.assertIn('"model_format_retry"', self.source)
self.assertIn("def local_reply_token_budget(", self.source)
self.assertIn('if "**[moltbot browser]**" in text:', self.source)
self.assertIn("def autonomous_checkpoint_tool_result(", self.source)
self.assertIn("browser result compacted for local summary", self.source)
self.assertIn("max_predict=local_reply_token_budget(prompt, agent_mode)", self.source)
self.assertIn('"think": False', self.source)
self.assertIn("The local model returned no visible answer.", self.source)
Expand Down
Loading