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 772db11c7f
commit d3a3e7b1f1
5 changed files with 60 additions and 15 deletions
+27
View File
@@ -228,3 +228,30 @@ async def test_anthropic_turns_become_one_deep_conversation(stack: Stack) -> Non
headers=AUTH,
)
assert r.status_code == 400 and "runs on 'd'" in r.json()["detail"]
async def test_markdown_edited_reply_reseeds_the_session(stack: Stack) -> None:
async with stack.client(stack.markdown) as c:
r = await c.post(
"/chat",
json={"filename": "e.md", "agent": "d", "content": "### User:\n\nanimal\n"},
headers=AUTH,
)
assert r.status_code == 200, r.text
content = r.json()["new_content"]
assert "ok:animal" in content and len(ScriptedClient.instances) == 1
edited = content.replace("ok:animal", "penguin") + "\nwhich one?\n"
r = await c.post(
"/chat",
json={"filename": "e.md", "agent": "d", "content": edited},
headers=AUTH,
)
assert r.status_code == 200, r.text
assert len(ScriptedClient.instances) == 2
first, second = ScriptedClient.instances
assert not first.connected and second.prompts == ["which one?"]
assert second.options.resume not in (None, first.session_id)
assert "penguin" in repr(vars(stack.world.store))
async with stack.world.db.session() as session:
stored = await load_messages(session, conversation_id=1)
assert stored[1]["content"] == [{"type": "text", "text": "penguin"}]