feat(conversations): the recall hook and the user sink learn whose turn it is
This commit is contained in:
@@ -219,3 +219,25 @@ async def test_failing_recall_or_sink_never_blocks_the_turn(world: World) -> Non
|
||||
assert prompt.startswith("hello\n\n" + HEADER)
|
||||
assert root.exists()
|
||||
await asyncio.sleep(0)
|
||||
|
||||
|
||||
async def test_the_recall_hook_and_the_sink_see_whose_turn_it_is(world: World) -> None:
|
||||
root, watch = vault()
|
||||
seen: list[RecallContext] = []
|
||||
|
||||
def recall(ctx: RecallContext) -> str | None:
|
||||
seen.append(ctx)
|
||||
return None if ctx.agent == "a" else "👤 указатель"
|
||||
|
||||
noted: list[UserSaid] = []
|
||||
world.conversations._envelope = Envelope(watch=watch, tz="UTC", recall=recall) # noqa: SLF001
|
||||
world.conversations._user_sink = noted.append # noqa: SLF001
|
||||
master = await world.conversations.create(kind="master", agent="a", origin="test")
|
||||
append(root / "люди" / "Прохор.md", "новое\n")
|
||||
watch.note(root / "люди" / "Прохор.md")
|
||||
await world.conversations.post(master, "что там у Прохор")
|
||||
await world.settle(master, 1)
|
||||
assert [ctx.agent for ctx in seen] == ["a"]
|
||||
assert [m.agent for m in noted] == ["a"]
|
||||
assert "👤" not in ScriptedClient.instances[0].prompts[0]
|
||||
await asyncio.sleep(0)
|
||||
|
||||
Reference in New Issue
Block a user