cli(config): Add GOOSE_CONTEXT_STRATEGY setting (#2666)
Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
committed by
GitHub
parent
601744518d
commit
78234fb103
@@ -62,6 +62,24 @@ export GOOSE_PLANNER_PROVIDER="openai"
|
||||
export GOOSE_PLANNER_MODEL="gpt-4"
|
||||
```
|
||||
|
||||
## Session Management
|
||||
|
||||
These variables control how Goose manages conversation sessions and context.
|
||||
|
||||
| Variable | Purpose | Values | Default |
|
||||
|----------|---------|---------|---------|
|
||||
| `GOOSE_CONTEXT_STRATEGY` | Controls how Goose handles context limit exceeded situations | "summarize", "truncate", "clear", "prompt" | "prompt" (interactive), "summarize" (headless) |
|
||||
|
||||
**Examples**
|
||||
|
||||
```bash
|
||||
# Automatically summarize when context limit is reached
|
||||
export GOOSE_CONTEXT_STRATEGY=summarize
|
||||
|
||||
# Always prompt user to choose (default for interactive mode)
|
||||
export GOOSE_CONTEXT_STRATEGY=prompt
|
||||
```
|
||||
|
||||
## Tool Configuration
|
||||
|
||||
These variables control how Goose handles [tool permissions](/docs/guides/tool-permissions) and their execution.
|
||||
|
||||
@@ -58,10 +58,33 @@ You can proactively summarize your conversation before reaching context limits:
|
||||
|
||||
The CLI offers three context management options: summarize, truncate, or clear your session.
|
||||
|
||||
### Default Context Strategy
|
||||
|
||||
You can configure Goose to automatically handle context limits without prompting by setting the `GOOSE_CONTEXT_STRATEGY` environment variable:
|
||||
|
||||
```bash
|
||||
# Set default strategy (choose one)
|
||||
export GOOSE_CONTEXT_STRATEGY=summarize # Automatically summarize (recommended)
|
||||
export GOOSE_CONTEXT_STRATEGY=truncate # Automatically remove oldest messages
|
||||
export GOOSE_CONTEXT_STRATEGY=clear # Automatically clear session
|
||||
export GOOSE_CONTEXT_STRATEGY=prompt # Always prompt user (default)
|
||||
```
|
||||
|
||||
Or configure it permanently:
|
||||
```bash
|
||||
goose configure set GOOSE_CONTEXT_STRATEGY summarize
|
||||
```
|
||||
|
||||
**Default behavior:**
|
||||
- **Interactive mode**: Prompts user to choose (equivalent to `prompt`)
|
||||
- **Headless mode** (`goose run`): Automatically summarizes (equivalent to `summarize`)
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="automatic" label="Automatic" default>
|
||||
|
||||
When you hit the context limit, you'll see this prompt to choose a management option, allowing you to continue your session:
|
||||
When you hit the context limit, the behavior depends on your configuration:
|
||||
|
||||
**With default settings (no `GOOSE_CONTEXT_STRATEGY` set)**, you'll see this prompt to choose a management option:
|
||||
|
||||
```sh
|
||||
◇ The model's context length is maxed out. You will need to reduce the # msgs. Do you want to?
|
||||
@@ -76,6 +99,24 @@ final_summary: [A summary of your conversation will appear here]
|
||||
Context maxed out
|
||||
--------------------------------------------------
|
||||
Goose summarized messages for you.
|
||||
```
|
||||
|
||||
**With `GOOSE_CONTEXT_STRATEGY` configured**, Goose will automatically apply your chosen strategy:
|
||||
|
||||
```sh
|
||||
# Example with GOOSE_CONTEXT_STRATEGY=summarize
|
||||
Context maxed out - automatically summarized messages.
|
||||
--------------------------------------------------
|
||||
Goose automatically summarized messages for you.
|
||||
|
||||
# Example with GOOSE_CONTEXT_STRATEGY=truncate
|
||||
Context maxed out - automatically truncated messages.
|
||||
--------------------------------------------------
|
||||
Goose tried its best to truncate messages for you.
|
||||
|
||||
# Example with GOOSE_CONTEXT_STRATEGY=clear
|
||||
Context maxed out - automatically cleared session.
|
||||
--------------------------------------------------
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -118,4 +159,4 @@ Key information has been preserved while reducing context length.
|
||||
This functionality is not available in the Goose CLI.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
</Tabs>
|
||||
|
||||
Reference in New Issue
Block a user