b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Shared helpers for classifying tool result payloads."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import Any
|
|
|
|
|
|
FILE_MUTATING_TOOL_NAMES = frozenset({"write_file", "patch"})
|
|
|
|
|
|
# Tools whose interrupted/dangling execution is safe to discard because they
|
|
# cannot mutate either external state or Hermes session state. Unknown/plugin/
|
|
# MCP tools stay effect-capable by default.
|
|
NO_EFFECT_TOOL_NAMES = frozenset({
|
|
"read_file", "search_files", "session_search", "skill_view", "skills_list",
|
|
"web_extract", "web_search", "vision_analyze", "browser_snapshot",
|
|
"browser_get_images", "browser_console", "read_terminal",
|
|
})
|
|
|
|
|
|
def tool_may_have_side_effect(tool_name: str) -> bool:
|
|
return tool_name not in NO_EFFECT_TOOL_NAMES
|
|
|
|
|
|
def file_mutation_result_landed(tool_name: str, result: Any) -> bool:
|
|
"""Return True when a file mutation result proves the write landed."""
|
|
if tool_name not in FILE_MUTATING_TOOL_NAMES or not isinstance(result, str):
|
|
return False
|
|
try:
|
|
data = json.loads(result.strip())
|
|
except Exception:
|
|
return False
|
|
if not isinstance(data, dict) or data.get("error"):
|
|
return False
|
|
if tool_name == "write_file":
|
|
return "bytes_written" in data
|
|
if tool_name == "patch":
|
|
return data.get("success") is True
|
|
return False
|