refactor(goal): sustain one ReAct run until the goal closes (#6538)

* refactor(goal): sustain one ReAct run until the goal closes

Keep active goals in the same runner beyond the ordinary iteration limit, with a final answer after successful closure. Remove cross-turn goal handoffs, continuation allowances and rollback bookkeeping while preserving input authorization, recovery, cancellation and terminal lifecycle ownership.

Contributes to NAN-392

Co-authored-by: chengyongru <chengyongru.ai@gmail.com>

* test(goal): consolidate sustained-run regression coverage

Retain lifecycle, history, usage, provider-state privacy and checkpoint cancellation assertions in the existing long-run scenarios. Remove duplicate smoke cases and parameter combinations that do not exercise distinct behavior; keep real Gateway, authorization and generation regressions.
This commit is contained in:
chengyongruandchengyongru authored and GitHub committed 2026-11-03 22:47:00 +08:00
1 parent 3545539128
commit 62c2ed4e7e
68 files changed
+2683 -1421

No files matched your search

+19 -2
View File
@@ -53,12 +53,16 @@ class SessionState:
workers: int = _DEFAULT_WORKERS,
on_delete: Callable[[str], None] | None = None,
types: SessionTypes | None = None,
generation_exclusions: set[str] | None = None,
) -> None:
if capacity < 1:
raise ValueError("session operation capacity must be positive")
if workers < 1:
raise ValueError("session operation worker count must be positive")
self._types = types if types is not None else SessionTypes()
self._generation_exclusions: set[str] = (
generation_exclusions if generation_exclusions is not None else set()
)
self._store = store
self._on_delete = on_delete
self._snapshots: dict[str, Session] = {}
@@ -426,6 +430,15 @@ class SessionState:
return self._draft(session)
return await self._execute(key, read, write=False)
async def read_header(self, key: str) -> Session | None:
"""Read committed identity and metadata without creating a session."""
def read() -> Session | None:
session = self._load(key, history=False)
if session is None:
return None
return replace(session, messages=[], provider_state=None, _baseline=None)
return await self._execute(key, read, write=False)
async def get(self, key: str) -> Session:
"""Read an existing conversation; create missing state on the writer."""
return await self._get(key, history=True)
@@ -661,7 +674,7 @@ class SessionState:
await self._submit_draft(session)
async def finish_turn(self, session: Session) -> None:
"""Commit the assembled transcript and clear its recovery markers."""
"""Commit the assembled transcript and clear its recovery checkpoint."""
session.metadata.pop(_PENDING_KEY, None)
session.metadata.pop(_CHECKPOINT_KEY, None)
await self._submit_draft(session)
@@ -997,7 +1010,9 @@ class SessionState:
source = self._load(source_key)
if source is None:
return None
target = fork_session(source, target_key, before_user_index)
target = fork_session(
source, target_key, before_user_index, exclude_metadata=frozenset(self._generation_exclusions),
)
if target is None:
return None
if title:
@@ -1145,6 +1160,8 @@ class SessionState:
session.metadata = deepcopy(old.metadata)
for name in (*_RESERVED_KEYS, "webui_recovery", "_last_summary", "_stopped_at_iteration_limit"):
session.metadata.pop(name, None)
for name in self._generation_exclusions:
session.metadata.pop(name, None)
if session.policy.persist:
self._store.delete(key, preserve_archive=True)
self._commit(session)