fix: improve cross-device evidence, request diagnostics and prompt efficiency

This commit is contained in:
chenmingxuan committed 2026-10-17 14:55:45 +08:00
1 parent 621f30e437
commit a66803651a
60 files changed
+3097 -160

No files matched your search

+3 -1
View File
@@ -1314,10 +1314,12 @@ class DataEngine:
def get_step_image_path(self, step_number: int, which: str = "pre") -> Path | None:
"""Read-only path of a step's pre/post screenshot, if recorded."""
from artemis.data_engine.step_evidence import step_image_name
step = self.get_step_record(step_number)
if step is None:
return None
image_name = step.pre_image_name if which == "pre" else step.post_image_name
image_name = step_image_name(step, which)
if not image_name:
return None
path = self.get_image_path(image_name)
+3 -1
View File
@@ -85,10 +85,12 @@ class OfflineHistoryReader:
return self.global_base_dir / "images" / f"{image_name}.jpg"
def get_step_image_path(self, step_number: int, which: str = "pre") -> Path | None:
from artemis.data_engine.step_evidence import step_image_name
step = self.get_step_record(step_number)
if step is None:
return None
image_name = step.pre_image_name if which == "pre" else step.post_image_name
image_name = step_image_name(step, which)
if not image_name:
return None
path = self.get_image_path(image_name)
+34
View File
@@ -0,0 +1,34 @@
"""Resolve a step's images from the resource that actually produced them."""
from typing import Any
def step_image_name(step: Any, which: str) -> str | None:
def field(name):
return step.get(name) if isinstance(step, dict) else getattr(step, name, None)
result = field("last_execution_result")
execution = result.get("execution") if isinstance(result, dict) else None
actions = execution if isinstance(execution, list) else field("action_taken")
if isinstance(actions, dict):
actions = [actions]
actions = actions if isinstance(actions, list) else []
plugins = [
action
for action in actions
if isinstance(action, dict)
and (action.get("plugin_id") or str(action.get("action", "")).startswith("plug_"))
]
if not plugins:
return field(f"{which}_image_name")
# A burst may span several resources. Its per-call evidence must not be
# presented as a before/after pair on one screen.
if len(actions) != 1:
return None
action = plugins[0]
if isinstance(execution, list) or f"{which}_image_name" in action:
if which == "pre" and not action.get("pre_image_valid"):
return None
return action.get(f"{which}_image_name")
# Older Flash records already stored source-specific images at step level.
return field(f"{which}_image_name")
+3
View File
@@ -990,6 +990,9 @@ class StorageManager:
WHEN excluded.status = 'running' AND traces.status IN ('success', 'failed') THEN traces.payload
ELSE excluded.payload
END
WHERE traces.type != 'llm_diagnostic'
OR COALESCE(json_extract(excluded.payload, '$.sequence'), 0)
> COALESCE(json_extract(traces.payload, '$.sequence'), -1)
""",
(
str(trace.trace_id),