fix: reject context commands for context-owning providers (#11094)
Co-authored-by: Douwe M Osinga <douwe@sidewalklabs.com>
This commit is contained in:
@@ -37,7 +37,9 @@ use anyhow::{Context, Result};
|
||||
use completion::GooseCompleter;
|
||||
use goose::agents::extension::{Envs, ExtensionConfig, PLATFORM_EXTENSIONS};
|
||||
use goose::agents::types::RetryConfig;
|
||||
use goose::agents::{Agent, SessionConfig, COMPACT_TRIGGERS};
|
||||
use goose::agents::{
|
||||
context_management_unsupported_message, Agent, SessionConfig, COMPACT_TRIGGERS,
|
||||
};
|
||||
use goose::config::extensions::name_to_key;
|
||||
use goose::config::{Config, GooseMode};
|
||||
use input::InputResult;
|
||||
@@ -1047,6 +1049,15 @@ impl CliSession {
|
||||
}
|
||||
|
||||
async fn handle_clear(&mut self) -> Result<()> {
|
||||
let provider = self.agent.provider().await?;
|
||||
if provider.manages_own_context() {
|
||||
output::render_error(&context_management_unsupported_message(
|
||||
"clear",
|
||||
provider.get_name(),
|
||||
));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Err(e) = self
|
||||
.agent
|
||||
.config
|
||||
@@ -1263,6 +1274,15 @@ impl CliSession {
|
||||
}
|
||||
|
||||
async fn handle_compact(&mut self) -> Result<()> {
|
||||
let provider = self.agent.provider().await?;
|
||||
if provider.manages_own_context() {
|
||||
output::render_error(&context_management_unsupported_message(
|
||||
"compact",
|
||||
provider.get_name(),
|
||||
));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let prompt = "Are you sure you want to compact this conversation? This will condense the message history.";
|
||||
let should_summarize = match cliclack::confirm(prompt).initial_value(true).interact() {
|
||||
Ok(choice) => choice,
|
||||
|
||||
Reference in New Issue
Block a user