Skip to content

Commit c8d4057

Browse files
feat: expose context window utilization to agent via MOIM (#7418)
1 parent db44a40 commit c8d4057

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

crates/goose/src/agents/extension_manager.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,28 @@ impl ExtensionManager {
16081608
working_dir.display()
16091609
);
16101610

1611+
if let Ok(session) = self
1612+
.context
1613+
.session_manager
1614+
.get_session(session_id, false)
1615+
.await
1616+
{
1617+
if let (Some(total), Some(config)) =
1618+
(session.total_tokens, session.model_config.as_ref())
1619+
{
1620+
let limit = config.context_limit();
1621+
if total > 0 && limit > 0 {
1622+
let pct = (total as f64 / limit as f64 * 100.0).round() as u32;
1623+
content.push_str(&format!(
1624+
"Context: ~{}k/{}k tokens used ({}%)\n",
1625+
total / 1000,
1626+
limit / 1000,
1627+
pct
1628+
));
1629+
}
1630+
}
1631+
}
1632+
16111633
let platform_clients: Vec<(String, McpClientBox)> = {
16121634
let extensions = self.extensions.lock().await;
16131635
extensions

0 commit comments

Comments
 (0)