This commit is contained in:
2026-04-03 01:24:37 -03:00
parent cae9312db1
commit db3b94a6a1
5 changed files with 34 additions and 6 deletions

View File

@@ -146,6 +146,8 @@ class AgentRunner:
def __init__(self):
self._provider: AgentProvider | None = None
self._history: list[tuple[str, str]] = [] # (role, text)
self.include_history = False # toggled by UI
def _get_provider(self) -> AgentProvider:
if self._provider is None:
@@ -178,6 +180,9 @@ class AgentRunner:
def model(self, value: str):
self._get_provider().model = value
def clear_history(self):
self._history.clear()
def send(
self,
message: str,
@@ -205,9 +210,14 @@ class AgentRunner:
mentioned_frames=mentioned_frames,
transcript_segments=transcript,
mentioned_transcripts=mentioned_transcripts,
history=list(self._history) if self.include_history else [],
)
self._history.append(("user", message))
response_chunks = []
for chunk in provider.stream(message, context):
response_chunks.append(chunk)
on_chunk(chunk)
self._history.append(("assistant", "".join(response_chunks)))
on_done(None)
except Exception as e:
log.error("Agent error: %s", e)