agent: Suggest turning burn mode on when close to the context window limit (#32691)

Previously, upon getting close to reaching the context window, we'd just
suggest creating a new thread using the summary of the current one. Now,
we also suggest turning burn mode on as an alternative action to solve
the context window problem.

Release Notes:

- agent: Added a suggestion to turn burn mode on when getting close to
the context window limit.
This commit is contained in:
Danilo Leal 2025-06-13 11:41:17 -03:00 committed by GitHub
parent fcf5042007
commit d280c95d91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View file

@ -502,7 +502,7 @@ impl MessageEditor {
cx.notify(); cx.notify();
} }
fn render_max_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> { fn render_burn_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
let thread = self.thread.read(cx); let thread = self.thread.read(cx);
let model = thread.configured_model(); let model = thread.configured_model();
if !model?.model.supports_max_mode() { if !model?.model.supports_max_mode() {
@ -717,7 +717,7 @@ impl MessageEditor {
.child( .child(
h_flex() h_flex()
.child(self.render_follow_toggle(cx)) .child(self.render_follow_toggle(cx))
.children(self.render_max_mode_toggle(cx)), .children(self.render_burn_mode_toggle(cx)),
) )
.child( .child(
h_flex() h_flex()
@ -1256,7 +1256,7 @@ impl MessageEditor {
.icon(icon) .icon(icon)
.title(title) .title(title)
.description( .description(
"Start a new thread from a summary to continue the conversation.", "To continue, start a new thread from a summary or turn burn mode on.",
) )
.primary_action( .primary_action(
Button::new("start-new-thread", "Start New Thread") Button::new("start-new-thread", "Start New Thread")
@ -1268,6 +1268,13 @@ impl MessageEditor {
cx, cx,
); );
})), })),
)
.secondary_action(
IconButton::new("burn-mode-callout", IconName::ZedBurnMode)
.icon_size(IconSize::XSmall)
.on_click(cx.listener(|this, _event, window, cx| {
this.toggle_burn_mode(&ToggleBurnMode, window, cx);
})),
), ),
), ),
) )
@ -1466,6 +1473,8 @@ impl Render for MessageEditor {
total_token_usage.ratio() total_token_usage.ratio()
}); });
let burn_mode_enabled = thread.completion_mode() == CompletionMode::Burn;
let action_log = self.thread.read(cx).action_log(); let action_log = self.thread.read(cx).action_log();
let changed_buffers = action_log.read(cx).changed_buffers(cx); let changed_buffers = action_log.read(cx).changed_buffers(cx);
@ -1482,7 +1491,7 @@ impl Render for MessageEditor {
if usage_callout.is_some() { if usage_callout.is_some() {
usage_callout usage_callout
} else if token_usage_ratio != TokenUsageRatio::Normal { } else if token_usage_ratio != TokenUsageRatio::Normal && !burn_mode_enabled {
self.render_token_limit_callout(line_height, token_usage_ratio, cx) self.render_token_limit_callout(line_height, token_usage_ratio, cx)
} else { } else {
None None

View file

@ -110,7 +110,7 @@ impl RenderOnce for Callout {
|this| { |this| {
this.child( this.child(
h_flex() h_flex()
.gap_1() .gap_0p5()
.when_some(self.secondary_action, |this, action| { .when_some(self.secondary_action, |this, action| {
this.child(action) this.child(action)
}) })