mirror of
https://github.com/usestrix/strix.git
synced 2026-10-03 02:24:24 +00:00
perf(tui): index chat_messages by agent to eliminate O(N) scan per frame
This commit is contained in:
parent
4b17b57696
commit
d0cbaec173
2 changed files with 3 additions and 2 deletions
|
|
@ -1477,8 +1477,7 @@ class StrixTUIApp(App): # type: ignore[misc]
|
|||
"id": f"chat_{msg['message_id']}",
|
||||
"data": msg,
|
||||
}
|
||||
for msg in self.tracer.chat_messages
|
||||
if msg.get("agent_id") == agent_id
|
||||
for msg in self.tracer.chat_messages_by_agent.get(agent_id, [])
|
||||
]
|
||||
|
||||
agent_data = self.tracer.agents.get(agent_id, {})
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class Tracer:
|
|||
self.agents: dict[str, dict[str, Any]] = {}
|
||||
self.tool_executions: dict[int, dict[str, Any]] = {}
|
||||
self.chat_messages: list[dict[str, Any]] = []
|
||||
self.chat_messages_by_agent: dict[str, list[dict[str, Any]]] = {}
|
||||
self.streaming_content: dict[str, str] = {}
|
||||
self.interrupted_content: dict[str, str] = {}
|
||||
|
||||
|
|
@ -474,6 +475,7 @@ class Tracer:
|
|||
}
|
||||
|
||||
self.chat_messages.append(message_data)
|
||||
self.chat_messages_by_agent.setdefault(agent_id, []).append(message_data)
|
||||
self._emit_event(
|
||||
"chat.message",
|
||||
actor={"agent_id": agent_id, "role": role},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue