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

+36
View File
@@ -29,6 +29,7 @@ import asyncio
from artemis.config.settings import settings
import base64
from pathlib import Path
import sqlite3
from typing import Any
from uuid import UUID
@@ -231,6 +232,7 @@ class VisualStepSummarizer(StepMemoryService):
focus: dict[str, str] | None = None,
post_ui_elements_text: str | None = None,
observation_settled: bool | None = None,
receipt_only: bool = False,
) -> None:
"""Dispatches an asynchronous summarization task without blocking the caller.
@@ -252,6 +254,16 @@ class VisualStepSummarizer(StepMemoryService):
else:
key = action_key if action_key is not None else step_number
if action_name.startswith("plug_"):
from artemis.config.constants import PLUGIN_SUMMARY_TEXT_CHARS
from artemis.plugins.prompt_budget import bounded_result_text
exec_outcome = bounded_result_text(exec_outcome, limit=PLUGIN_SUMMARY_TEXT_CHARS)
if post_ui_elements_text:
post_ui_elements_text = bounded_result_text(
post_ui_elements_text, limit=PLUGIN_SUMMARY_TEXT_CHARS
)
payload = {
"step_number": step_number,
"action_name": action_name,
@@ -264,6 +276,30 @@ class VisualStepSummarizer(StepMemoryService):
"post_ui_elements_text": post_ui_elements_text,
"observation_settled": observation_settled,
}
if receipt_only:
from artemis.config.constants import PLUGIN_SUMMARY_TEXT_CHARS
from artemis.plugins.prompt_budget import bounded_result_text
summary = (
f"步骤 {step_number}:只读观察 {action_name};未执行写操作。"
"以下为工具返回摘录,截图仍在本步骤证据中;不代表视觉验收通过。\n"
+ bounded_result_text(exec_outcome, limit=PLUGIN_SUMMARY_TEXT_CHARS)
)
# Evidence has already been persisted by the caller. As with a
# completed visual summary, do not retain every frame in memory.
payload.update(pre_img_bytes=None, post_img_bytes=None, focus=None)
self._step_inputs[key] = payload
self._summaries[key] = summary
for alias in aliases:
self._aliases[alias] = key
if data_engine_step_id is not None and self.ctx.data_engine:
try:
self.ctx.data_engine.update_step_summary(
data_engine_step_id, summary, status="ready", source="tool_receipt"
)
except (OSError, ValueError, sqlite3.Error) as de_err:
logger.debug(f"DataEngine receipt summary update skipped: {de_err}")
return
self.submit(key, payload, aliases=aliases)
@staticmethod