feat(conversations): pre-SDK rows read from canonical messages, implied titles, markdown adopts them by first prompt
This commit is contained in:
@@ -18,6 +18,7 @@ from claude_agent_sdk import (
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
from test_conversations import ScriptedClient, World
|
||||
|
||||
from beaver_gateway.core.conversation_store import rewrite_messages
|
||||
from beaver_gateway.core.auth import TokenStore
|
||||
from beaver_gateway.core.registry import McpRegistry
|
||||
from beaver_gateway.core.transcript import build_entries
|
||||
@@ -397,3 +398,25 @@ async def test_admin_login_hands_out_the_ui_bearer(world: World) -> None:
|
||||
assert me.status_code == 200
|
||||
assert (await http.post("/admin/auth/logout")).status_code == 204
|
||||
assert (await http.get("/admin/auth/session")).status_code == 401
|
||||
|
||||
|
||||
async def test_pre_sdk_rows_show_canonical_history_and_a_title(world: World) -> None:
|
||||
api = Api(world)
|
||||
conv = await world.conversations.create(kind="deep", agent="d", origin="markdown")
|
||||
async with world.db.session() as session:
|
||||
await rewrite_messages(
|
||||
session,
|
||||
conversation_id=cast("int", conv.id),
|
||||
messages=[
|
||||
{"role": "user", "content": "так смотри, план на май\nвторая строка"},
|
||||
{"role": "assistant", "content": [{"type": "text", "text": "ок"}]},
|
||||
],
|
||||
)
|
||||
rows = (await api.get("/conversations"))["conversations"]
|
||||
assert [r["title"] for r in rows if r["id"] == conv.external_id] == [
|
||||
"так смотри, план на май"
|
||||
]
|
||||
shown = await api.get(f"/conversations/{conv.external_id}")
|
||||
assert shown["title"] == "так смотри, план на май" and shown["session_id"] is None
|
||||
history = await api.get(f"/conversations/{conv.external_id}/history")
|
||||
assert [m["role"] for m in history["messages"]] == ["user", "assistant"]
|
||||
|
||||
Reference in New Issue
Block a user