Deepen context-window management into ContextWindow #116

Merged
hermes merged 3 commits from context-window into main 2026-10-02 15:06:19 +00:00
Showing only changes of commit 3070029c9e - Show all commits
+2 -4
View File
@@ -1,10 +1,10 @@
//! Agent loop: stream -> tool calls -> hooks -> results -> repeat.
use crate::compact;
use crate::window::ContextWindow;
use crate::hook::{Bus, Event};
use crate::session::Session;
use crate::tool::{Registry, ToolCtx};
use crate::window::ContextWindow;
use futures::StreamExt;
use hx_ai::{ContentBlock, Message, Provider, Request, Role, StopReason, StreamEvent, Usage};
use std::sync::Arc;
@@ -228,9 +228,7 @@ impl Agent {
if self.aborted() {
return Err(Error::Aborted);
}
if self.window.should_compact(&self.session.messages())
&& self.compact(6).await?
{
if self.window.should_compact(&self.session.messages()) && self.compact(6).await? {
self.emit(Event::Info("context compacted".into())).await;
}
self.emit(Event::TurnStart).await;