feat: HomeFormatter parses inline entity tags instead of tool_end blocks

The supervisor LLM now embeds <type>[id1,id2]</type> entity tags in its
response text. The HomeFormatter buffers streamed tokens, detects complete
tags across chunk boundaries, and emits WsStreamBlock with entity type +
specific IDs. This replaces the old approach of emitting blocks for every
tool_end event, which dumped ALL entities regardless of relevance.

Also fixes:
- NoneType guard on metadata in _run_graph_stream (metadata can be None)
- Updated _HOME_SYSTEM prompt with entity tag instructions
- Updated all affected tests
This commit is contained in:
2026-03-12 00:01:06 +01:00
parent 92716cb89a
commit 617a17db40
4 changed files with 190 additions and 51 deletions

View File

@@ -46,8 +46,7 @@ def _recv_until_end(ws, max_frames: int = 20) -> list[dict]:
async def _mock_home_stream(user_id, message, context, db_session_factory=None):
yield "tool_end", {"name": "task_agent", "result": "Found tasks"}
yield "token", "Hello"
yield "token", "Here are your tasks:\n<task>[t1,t2]</task>"
yield "mutations", []
@@ -115,7 +114,6 @@ def test_home_request_request_id_propagated(client):
req_id = "my-unique-req-id"
async def _stream(user_id, message, context, db_session_factory=None):
yield "tool_end", {"name": "note_agent", "result": "ok"}
yield "token", "ok"
yield "mutations", []