fix: improve cross-device evidence and exploration lifecycle

Align Responses cache affinity across execution and summary calls, preserve required checks and evidence uncertainty, and allow safe deletion of inactive explorations while retaining independent reruns.

Validation: backend suite passed except intentional prompt golden drift, then all 17 transcript tests passed after snapshot refresh; 268 frontend tests and production build passed; Ruff, quality ratchet and core type checks passed.
This commit is contained in:
chenmingxuan committed 2026-10-17 19:43:20 +08:00
1 parent f1bb5d02aa
commit 2328a4df0c
32 files changed
+748 -79

No files matched your search

+9 -1
View File
@@ -504,8 +504,16 @@ class StepCapsuleLens(StepLens):
return parsed
async def _invoke(self, llm: Any, messages: list[BaseMessage], model_label: str):
from artemis.llm.cache_affinity import cache_affinity_options
request_messages = adapt_responses_messages(messages, model_label)
response = await asyncio.wait_for(llm.ainvoke(request_messages), timeout=90.0)
response = await asyncio.wait_for(
llm.ainvoke(
request_messages,
**cache_affinity_options(self._ctx, "lens:step_capsule", model_label),
),
timeout=90.0,
)
# Raw-model bypass metering (gateway-wrapped models meter themselves);
# capsule prompts are small and are kept out of the session meter's
# last_prompt_tokens (the compaction base itself is operator-owned on
+3 -2
View File
@@ -1,5 +1,5 @@
# ROLE
You are the Segment Capsule writer for a mobile automation agent's history compression. You receive one contiguous segment of executed steps and produce the two LLM-authored bands of the segment's history chunk:
You are the Segment Capsule writer for a mobile and computer automation agent's history compression. You receive one contiguous segment of executed steps and produce the two LLM-authored bands of the segment's history chunk:
- Band ① — Synopsis & effects: what this segment was doing, what was actually done, and what effects/artifacts it left behind, plus structured fields.
- Band ② — Compressed step summary: an interval narrative ("Steps xx–xx did ..., Step xx did ...") covering every step of the segment.
@@ -21,7 +21,8 @@ A turn block without a transcript falls back to a reasoning excerpt; treat it th
2. **First-person perspective**: write from the agent's perspective using "I". Never "the agent" / "the operator".
3. **Planned iterations are not anomalies**: systematic processing of different candidate items, or periodic polling cycles under a `[Loop]` / `[Loop:continuous]` milestone, is planned progress — record it objectively (e.g. "polling round #2"). Only flag a loop when the exact same target is repeated without progress or states oscillate blindly; then record the pattern and count factually.
4. **Preserve, don't abstract**: be deliberately detailed and stay close to the source wording. Prefer longer output over abstracting facts beyond recognition. Faithfully carry visible text, codes, prices, account names, file names, error banners — and the concrete content of tool results the operator relied on (an explorer's answer, a recalled step, a note's contents, a command's output).
5. **Fact priority**: user instructions > validator/controller recorded results > tool results returned to the operator (explorer / recall / notes / ADB) > UI/OCR deltas > visual transition summaries > the operator's reasoning.
5. **Requirements are not observations**: user instructions govern what to do, not what happened. Controller receipts establish delivery, not goal achievement. Preserve recorded observations with device/window/page and step attribution; distinguish UI/OCR readings, visual summaries, tool reports and operator hypotheses. Conflicting or unreadable critical text stays unresolved with its competing sources; do not silently choose a spelling or merge different devices' observations into one fact.
6. **Requirement continuity**: preserve outstanding required checks, blockers and evidence links in the existing fields. Carry observed requirement facts in `verified_facts` with source/step; keep missing checks and contradictions in `unresolved`. Planned actions, user expectations and checked plan boxes alone cannot promote an item to verified. Do not repeat the same checklist across all bands.
# BAND ① REQUIREMENTS
Band ① is the segment-level account; band ② below it is the interval-level account. The two bands must not say the same thing twice: ① never re-lists what the intervals of ② already narrate, and it should come out shorter than ② (the `doing` + `did` + `effect` prose together — not counting the structured fields — shorter than the ② intervals together).