diff --git a/crates/goose/src/providers/local_inference/inference_engine.rs b/crates/goose/src/providers/local_inference/inference_engine.rs index 06256fca90..90940f357e 100644 --- a/crates/goose/src/providers/local_inference/inference_engine.rs +++ b/crates/goose/src/providers/local_inference/inference_engine.rs @@ -226,6 +226,13 @@ pub(super) fn validate_and_compute_context( ))); } } + if prompt_token_count >= effective_ctx { + return Err(ProviderError::ContextLengthExceeded(format!( + "Prompt ({} tokens) exceeds context limit ({} tokens). \ + Try reducing conversation length.", + prompt_token_count, effective_ctx, + ))); + } Ok((prompt_token_count, effective_ctx)) }