fix(telegram,core): no draft for seed turns

This commit is contained in:
hh
2026-08-28 18:59:00 +02:00
parent 66325c2879
commit 1f8dae57ac
3 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -779,6 +779,7 @@ class Conversations:
use_session: bool = True,
tools: bool = True,
turn_id: str | None = None,
item_origin: str | None = None,
) -> AsyncIterator[MessageStreamEvent]:
"""Run one turn on ``conv`` under its lock; the only path to the backend.
@@ -799,6 +800,7 @@ class Conversations:
conversation_id=conv.external_id,
turn_id=turn_id,
origin=origin,
item_origin=item_origin,
)
stop = "error"
try:
@@ -825,6 +827,7 @@ class Conversations:
conversation_id=conv.external_id,
turn_id=turn_id,
origin=origin,
item_origin=item_origin,
stop=stop,
usage=_usage_dict(capture),
)
@@ -837,6 +840,7 @@ class Conversations:
origin: str,
tools: bool = True,
turn_id: str | None = None,
item_origin: str | None = None,
) -> tuple[str, TurnCapture]:
capture = TurnCapture()
acc = StreamAccumulator()
@@ -848,6 +852,7 @@ class Conversations:
capture=capture,
tools=tools,
turn_id=turn_id,
item_origin=item_origin,
):
acc.feed(event)
message = acc.finalize(model=agent.model)
@@ -1062,7 +1067,7 @@ class Conversations:
prompt = "\n\n".join(f"{inject_header(i.origin)}\n{i.text}" for i in batch)
try:
text, capture = await self.run_text_turn(
conv, prompt, origin=origin, turn_id=turn_id
conv, prompt, origin=origin, turn_id=turn_id, item_origin=head.origin
)
except Exception: # noqa: BLE001
_log.exception("turn %s on %s failed", turn_id, conv.external_id)
@@ -648,7 +648,9 @@ class TelegramFrontend(Frontend):
return
match kind:
case "turn.start":
if event.get("origin") == "user":
if event.get("origin") == "user" and not str(
event.get("item_origin") or ""
).startswith("сид"):
await self._open_draft(key, event, target)
case "stream":
self._feed_draft(key, event)
+1
View File
@@ -465,6 +465,7 @@ async def test_commands_status_merge_and_new(stack: Stack) -> None:
await stack.world.settle(child, 1)
await asyncio.sleep(0.2)
assert all(m["thread"] != 902 for m in stack.bot.sent)
assert all(d["message_thread_id"] != 902 for d in stack.bot.drafts)
stack.bot.message("первое в новый топик", thread=902)
reply = await stack.until(lambda: stack.sent_with("первое в новый топик"), what="r")
assert reply["thread"] == 902