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

+3 -12
View File
@@ -23,14 +23,13 @@ from collections.abc import Awaitable, Callable, Coroutine
from contextvars import ContextVar, Token
from contextlib import aclosing
import functools
import hashlib
import logging
from pathlib import Path
import re
import sys
import time
from typing import Any, Literal, TypeVar, overload
from uuid import UUID, uuid4
from uuid import uuid4
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
@@ -48,6 +47,7 @@ from artemis.config import (
from artemis.context import ArtemisContext
from artemis.data_engine.trace import CURRENT_TRACE_ID, DataEngineCallbackHandler
from artemis.llm.diagnostics import ACTIVE_ATTEMPT, RequestAttempt, error_text, input_images
from artemis.llm.cache_affinity import cache_affinity_options
from artemis.llm.reliability import (
CircuitBreaker,
FailureCategory,
@@ -637,16 +637,7 @@ class RobustChatModelWrapper:
def _prepare_model_call(self, args: tuple, kwargs: dict) -> tuple[tuple, dict]:
model_name = self.endpoint.model_name if self.endpoint else None
engine = getattr(self.ctx, "data_engine", None)
session = getattr(self.ctx, "exploration_id", None) or getattr(
engine, "current_session_id", None
)
if isinstance(session, (str, UUID)) and str(session):
identity = f"{session}:{self.role or 'model'}:{model_name}"
kwargs = {
"prompt_cache_key": "artemis:" + hashlib.sha256(identity.encode()).hexdigest()[:40],
**kwargs,
}
kwargs = cache_affinity_options(self.ctx, self.role, model_name, kwargs)
if (
args
and isinstance(args[0], (list, tuple))