Skip to main content

Smart Context Management

When working with Large Language Models (LLMs), there are limits to how much conversation history they can process at once. Goose provides smart context management features to help handle context and conversation limits so you can maintain productive sessions. Here are some key concepts:

  • Context Length: The amount of conversation history the LLM can consider
  • Context Limit: The maximum number of tokens the model can process
  • Context Management: How Goose handles conversations approaching these limits
  • Turn: One complete prompt-response interaction between Goose and the LLM

Context Limit Strategy

When a conversation reaches the context limit, Goose offers different ways to handle it:

FeatureDescriptionBest ForImpact
SummarizationCondenses conversation while preserving key pointsLong, complex conversationsMaintains most context
TruncationRemoves oldest messages to make roomSimple, linear conversationsLoses old context
ClearStarts fresh while keeping session activeNew direction in conversationLoses all context
PromptAsks user to choose from the above optionsControl over each decision in interactive sessionsDepends on choice made

Your available options depend on whether you're using the Desktop app or CLI.

Goose Desktop exclusively uses summarization to manage context, preserving key information while reducing size.

When you reach the context limit in Goose Desktop:

  1. Goose will automatically start summarizing the conversation to make room.
  2. You'll see a message that says "Preparing summary...", followed by "Session summarized."
  3. Once complete, you'll have the option to "View or edit summary."
  4. You can then continue the session with the summarized context in place.

Maximum Turns

The Max Turns limit is the maximum number of consecutive turns that Goose can take without user input (default: 1000). When the limit is reached, Goose stops and prompts: "I've reached the maximum number of actions I can do without user input. Would you like me to continue?" If the user answers in the affirmative, Goose continues until the limit is reached and then prompts again.

This feature gives you control over agent autonomy and prevents infinite loops and runaway behavior, which could have significant cost consequences or damaging impact in production environments. Use it for:

  • Preventing infinite loops and excessive API calls or resource consumption in automated tasks
  • Enabling human supervision or interaction during autonomous operations
  • Controlling loops while testing and debugging agent behavior

This setting is stored as the GOOSE_MAX_TURNS environment variable in your config.yaml file. You can configure it using the Desktop app or CLI.

  1. Click the gear icon ⚙️ on the top toolbar
  2. Click Advanced settings
  3. Scroll to Conversation Limits and enter a value for Max Turns

Choosing the Right Value

The appropriate max turns value depends on your use case and comfort level with automation:

  • 5-10 turns: Good for exploratory tasks, debugging, or when you want frequent check-ins. For example, "analyze this codebase and suggest improvements" where you want to review each step
  • 25-50 turns: Effective for well-defined tasks with moderate complexity, such as "refactor this module to use the new API" or "set up a basic CI/CD pipeline"
  • 100+ turns: More suitable for complex, multi-step automation where you trust Goose to work independently, like "migrate this entire project from React 16 to React 18" or "implement comprehensive test coverage for this service"

Remember that even simple-seeming tasks often require multiple turns. For example, asking Goose to "fix the failing tests" might involve analyzing test output (1 turn), identifying the root cause (1 turn), making code changes (1 turn), and verifying the fix (1 turn).

Token Usage

After sending your first message, Goose Desktop and Goose CLI display token usage.

The Desktop displays a colored circle next to the model name at the bottom of the session window. The color provides a visual indicator of your token usage for the session.

  • Green: Normal usage - Plenty of context space available
  • Orange: Warning state - Approaching limit (80% of capacity)
  • Red: Error state - Context limit reached

Hover over this circle to display:

  • The number of tokens used
  • The percentage of available tokens used
  • The total available tokens
  • A progress bar showing your current token usage

Cost Tracking

Display estimated real-time costs of your session at the bottom of the Goose Desktop window.

To manage live cost tracking:

  1. Click the gear icon ⚙️ on the top toolbar
  2. Click Advanced settings
  3. Scroll to App Settings and toggle Cost Tracking on or off

The session cost updates dynamically as tokens are consumed. Hover over the cost to see a detailed breakdown of token usage. If multiple models are used in the session, this includes a cost breakdown by model. Ollama and local deployments always show a cost of $0.00.

Pricing data is regularly fetched from the OpenRouter API and cached locally. The Advanced settings tab shows when the data was last updated and allows you to refresh.

These costs are estimates only, and not connected to your actual provider bill. The cost shown is an approximation based on token counts and public pricing data.