fix(markdown): a rewritten assistant reply reseeds the session instead of resuming it

This commit is contained in:
hh
2026-08-29 01:37:52 +02:00
parent 5cd18fa2d7
commit 0cc2c5291f
5 changed files with 60 additions and 15 deletions
+8 -2
View File
@@ -296,6 +296,7 @@ class ClaudeSdkBackend:
system: str | None = None, # noqa: ARG002 - the agent owns its prompt
conversation_id: str | None = None,
session_id: str | None = None,
reseed: bool = False,
capture: TurnCapture | None = None,
kind: str = "deep",
pinned: bool = False,
@@ -315,7 +316,9 @@ class ClaudeSdkBackend:
prior = history[:-1]
key = conversation_id or fingerprint(prior)
spec = _SessionSpec(kind=kind, pinned=pinned, tools=tools)
live = await self._acquire(key, session_id=session_id, history=prior, spec=spec)
live = await self._acquire(
key, session_id=session_id, history=prior, spec=spec, reseed=reseed
)
message_id = f"msg_{uuid.uuid4().hex}"
yield build_message_start(message_id=message_id, model=self._agent.model)
turn = _Turn()
@@ -484,10 +487,13 @@ class ClaudeSdkBackend:
session_id: str | None,
history: list[dict[str, Any]],
spec: _SessionSpec,
reseed: bool = False,
) -> Session:
live = self._pool.get(key)
if live is not None:
return live
if not reseed:
return live
await self._pool.close(key)
resume = session_id
if resume is not None:
await self.repair_session(resume)