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:
@@ -236,7 +236,19 @@ _HOME_SYSTEM = (
|
||||
"multiple sub-agents if needed.\n\n"
|
||||
"You also have an update_core_memory tool — use it when the user states "
|
||||
"a preference or important fact worth remembering long-term.\n\n"
|
||||
"After gathering data, synthesize a clear, helpful response for the user.\n\n"
|
||||
"## Entity References\n"
|
||||
"When your response mentions specific workspace entities, embed them "
|
||||
"inline using entity tags so the UI can render interactive components.\n"
|
||||
"Format: <type>[comma-separated UUIDs]</type>\n"
|
||||
"Supported types: task, project, note, timeline\n\n"
|
||||
"Example response:\n"
|
||||
" Here is your project:\n"
|
||||
" <project>[abc-123-def]</project>\n"
|
||||
" It has these pending tasks:\n"
|
||||
" <task>[def-456,ghi-789]</task>\n\n"
|
||||
"IMPORTANT: Only include IDs of entities that are directly relevant to "
|
||||
"the user's question. Do NOT dump all entity IDs returned by a tool — "
|
||||
"filter to only the ones the user asked about or that matter for the answer.\n\n"
|
||||
"Memory context:\n{memory_context}"
|
||||
)
|
||||
|
||||
@@ -360,6 +372,7 @@ async def _run_graph_stream(
|
||||
isinstance(msg, AIMessageChunk)
|
||||
and msg.content
|
||||
and not msg.tool_calls
|
||||
and isinstance(metadata, dict)
|
||||
and metadata.get("langgraph_node") == "agent"
|
||||
):
|
||||
yield ("token", str(msg.content))
|
||||
|
||||
Reference in New Issue
Block a user