feat: add thread info and status reads
This commit is contained in:
16 files changed
+496
-33
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import asyncio
|
||||
|
||||
from agentmsgs.core.app import App
|
||||
from agentmsgs.mcp import server
|
||||
from agentmsgs.stores.memory import InMemoryStore
|
||||
|
||||
|
||||
def test_thread_info_and_status_tools():
|
||||
app = App(store=InMemoryStore())
|
||||
alice = app.get_or_create_agent("Alice")
|
||||
bob = app.get_or_create_agent("Bob")
|
||||
thread = app.create_thread(alice, bob)
|
||||
latest = app.append(thread.id, alice, "hello")
|
||||
server._app = app
|
||||
|
||||
info_result = asyncio.run(
|
||||
server.mcp.call_tool("thread_info", {"thread_id": str(thread.id)})
|
||||
)
|
||||
status_result = asyncio.run(
|
||||
server.mcp.call_tool(
|
||||
"thread_status",
|
||||
{"thread_id": str(thread.id), "agent_name": "Bob"},
|
||||
)
|
||||
)
|
||||
|
||||
assert info_result.structured_content["result"] == {
|
||||
"id": str(thread.id),
|
||||
"participants": [
|
||||
{"id": str(alice.id), "name": "Alice"},
|
||||
{"id": str(bob.id), "name": "Bob"},
|
||||
],
|
||||
"created_at": thread.created_at.isoformat(),
|
||||
"message_count": 1,
|
||||
"latest_message": {
|
||||
"id": str(latest.id),
|
||||
"seq": latest.seq,
|
||||
"sender": latest.sender.name,
|
||||
"content": latest.content,
|
||||
"ts": latest.ts.isoformat(),
|
||||
},
|
||||
}
|
||||
assert status_result.structured_content["result"] == {
|
||||
"thread_id": str(thread.id),
|
||||
"agent": {"id": str(bob.id), "name": bob.name},
|
||||
"cursor_seq": 0,
|
||||
"latest_seq": 1,
|
||||
"unread_count": 1,
|
||||
"unread_from_others_count": 1,
|
||||
"has_unread": True,
|
||||
"has_unread_from_others": True,
|
||||
}
|
||||
Reference in new issue
Block a user