feat: harden agent verification and runtime contracts

Introduce two-gate checker settlement, explicit graph visibility and checkpoints, structured LLM reliability, centralized action specifications, and corresponding tests and design documentation.
This commit is contained in:
somew1nd committed 2026-08-31 20:42:24 -07:00
1 parent ddfa420945
commit cbe8f4f0c6
106 files changed
+11542 -4445

No files matched your search

+11 -48
View File
@@ -17,10 +17,8 @@ from typing import Any, Literal
from langchain_core.messages import ToolMessage
from langchain_core.tools import BaseTool
from langgraph.types import Command
from pydantic import BaseModel, Field
from artemis.constants import VALIDATOR_MESSAGES_KEY
from artemis.context import ArtemisContext
from artemis.controllers.unified_controller import UnifiedMobileController
from artemis.data_engine.trace import trace_langchain_tool
@@ -206,19 +204,12 @@ class ClickTool(ArtemisTool):
success = False
outcome = f"Error during click: {e}"
if st and callable(getattr(st, "asanitize_update", None)):
tool_message = ToolMessage(
if st is not None:
return ToolMessage(
tool_call_id=tcid or "",
content=outcome,
status="success" if success else "error",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={VALIDATOR_MESSAGES_KEY: [tool_message]},
agent="validator",
)
)
return outcome
@@ -306,19 +297,12 @@ class LongPressTool(ArtemisTool):
success = False
outcome = f"Error during long press: {e}"
if st and callable(getattr(st, "asanitize_update", None)):
tool_message = ToolMessage(
if st is not None:
return ToolMessage(
tool_call_id=tcid or "",
content=outcome,
status="success" if success else "error",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={VALIDATOR_MESSAGES_KEY: [tool_message]},
agent="validator",
)
)
return outcome
@@ -414,19 +398,12 @@ class InputTextTool(ArtemisTool):
success = False
outcome = f"Error during input text: {e}"
if st and callable(getattr(st, "asanitize_update", None)):
tool_message = ToolMessage(
if st is not None:
return ToolMessage(
tool_call_id=tcid or "",
content=outcome,
status="success" if success else "error",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={VALIDATOR_MESSAGES_KEY: [tool_message]},
agent="validator",
)
)
return outcome
@@ -545,7 +522,7 @@ class SwipeTool(ArtemisTool):
if kind == "direction" and isinstance(target, str):
indexed_elems = getattr(state, "indexed_elements", None) if state else None
ui_hier = getattr(state, "ui_tree", None) if state else None
ui_hier = getattr(state, "latest_ui_hierarchy", None) if state else None
start_x, start_y, end_x, end_y, smart_dur = compute_smart_swipe_coordinates(
direction=target,
target=params.get("target"),
@@ -575,19 +552,12 @@ class SwipeTool(ArtemisTool):
success = False
outcome = f"Error during swipe: {e}"
if st and callable(getattr(st, "asanitize_update", None)):
tool_message = ToolMessage(
if st is not None:
return ToolMessage(
tool_call_id=tcid or "",
content=outcome,
status="success" if success else "error",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={VALIDATOR_MESSAGES_KEY: [tool_message]},
agent="validator",
)
)
return outcome
@@ -664,19 +634,12 @@ class PressKeyTool(ArtemisTool):
success = False
outcome = f"Error during press key: {e}"
if st and callable(getattr(st, "asanitize_update", None)):
tool_message = ToolMessage(
if st is not None:
return ToolMessage(
tool_call_id=tcid or "",
content=outcome,
status="success" if success else "error",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={VALIDATOR_MESSAGES_KEY: [tool_message]},
agent="validator",
)
)
return outcome
+2 -13
View File
@@ -16,11 +16,9 @@ from typing import Any
from langchain_core.messages import ToolMessage
from langchain_core.tools import BaseTool
from langgraph.types import Command
from pydantic import BaseModel, Field
from artemis.agents.hopper.hopper import HopperOutput, hopper
from artemis.constants import VALIDATOR_MESSAGES_KEY
from artemis.context import ArtemisContext
from artemis.controllers.platform_specific_commands_controller import (
list_packages_async,
@@ -176,23 +174,14 @@ class LaunchAppTool(ArtemisTool):
outcome = f"Error during launch app: {e}"
error_msg = str(e)
if st and callable(getattr(st, "asanitize_update", None)):
if st is not None:
additional_kwargs = {} if success else ({"error": error_msg} if error_msg else {})
tool_message = ToolMessage(
return ToolMessage(
tool_call_id=tcid or "",
content=outcome,
additional_kwargs=additional_kwargs,
status="success" if success else "error",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={
VALIDATOR_MESSAGES_KEY: [tool_message],
},
agent="validator",
)
)
return outcome
+2 -13
View File
@@ -19,10 +19,8 @@ from typing import Any
from langchain_core.messages import ToolMessage
from langchain_core.tools import BaseTool
from langgraph.types import Command
from pydantic import BaseModel
from artemis.constants import VALIDATOR_MESSAGES_KEY
from artemis.context import ArtemisContext
from artemis.data_engine.trace import trace_langchain_tool
from artemis.drivers.base import BaseDeviceDriver
@@ -169,8 +167,8 @@ class OcrRecognitionTool(ArtemisTool):
has_failed = True
error_message = f"Failed to perform OCR: {str(e)}"
if st and callable(getattr(st, "asanitize_update", None)):
tool_message = ToolMessage(
if st is not None:
return ToolMessage(
tool_call_id=tcid or "",
content=ocr_recognition_wrapper.on_failure_fn(error_message)
if has_failed
@@ -178,15 +176,6 @@ class OcrRecognitionTool(ArtemisTool):
additional_kwargs={"error": error_message} if has_failed else {},
status="error" if has_failed else "success",
)
return Command(
update=await st.asanitize_update(
ctx=ctx,
update={
VALIDATOR_MESSAGES_KEY: [tool_message],
},
agent="validator",
)
)
if has_failed:
return ocr_recognition_wrapper.on_failure_fn(error_message)