fix: unify context limit resolution behind provider API (#11213)
Signed-off-by: Jack Amadeo <jackamadeo@squareup.com>
This commit is contained in:
@@ -250,8 +250,7 @@ These variables allow you to override the default context window size (token lim
|
||||
| Variable | Purpose | Values | Default |
|
||||
|----------|---------|---------|---------|
|
||||
| `GOOSE_CONTEXT_LIMIT` | Override context limit for the main model | Integer (number of tokens) | Model-specific default or 128,000 |
|
||||
| `GOOSE_INPUT_LIMIT` | Override input prompt limit for ollama requests (maps to `num_ctx`) | Integer (number of tokens) | Falls back to `GOOSE_CONTEXT_LIMIT` or model default |
|
||||
| `GOOSE_PLANNER_CONTEXT_LIMIT` | Override context limit for the [planner model](/docs/guides/context-engineering/creating-plans) | Integer (number of tokens) | Falls back to `GOOSE_CONTEXT_LIMIT` or model default |
|
||||
| `GOOSE_INPUT_LIMIT` | Override input prompt limit for ollama requests (maps to `num_ctx`) | Integer (number of tokens) | Unset; Ollama uses its model default |
|
||||
|
||||
**Examples**
|
||||
|
||||
@@ -260,9 +259,6 @@ These variables allow you to override the default context window size (token lim
|
||||
export GOOSE_CONTEXT_LIMIT=200000
|
||||
# Override ollama input prompt limit
|
||||
export GOOSE_INPUT_LIMIT=32000
|
||||
|
||||
# Set context limit for planner
|
||||
export GOOSE_PLANNER_CONTEXT_LIMIT=1000000
|
||||
```
|
||||
|
||||
For more details and examples, see [Model Context Limit Overrides](/docs/guides/sessions/smart-context-management#model-context-limit-overrides).
|
||||
|
||||
@@ -295,7 +295,6 @@ Context limits are automatically detected based on your model name, but goose pr
|
||||
| Model | Description | Best For | Setting |
|
||||
|-------|-------------|----------|---------|
|
||||
| **Main** | Set context limit for the main model (also serves as fallback for other models) | LiteLLM proxies, custom models with non-standard names | `GOOSE_CONTEXT_LIMIT` |
|
||||
| **Planner** | Set context for [planner models](/docs/guides/context-engineering/creating-plans) | Large planning tasks requiring extensive context | `GOOSE_PLANNER_CONTEXT_LIMIT` |
|
||||
|
||||
:::info
|
||||
This setting only affects the displayed token usage and progress indicators. Actual context management is handled by your LLM, so you may experience more or less usage than the limit you set, regardless of what the display shows.
|
||||
@@ -310,10 +309,10 @@ This feature is particularly useful with:
|
||||
|
||||
goose resolves context limits with the following precedence (highest to lowest):
|
||||
|
||||
1. Explicit context_limit in model configuration (if set programmatically)
|
||||
2. Specific environment variable (e.g., `GOOSE_PLANNER_CONTEXT_LIMIT`)
|
||||
3. Global environment variable (`GOOSE_CONTEXT_LIMIT`)
|
||||
4. Model-specific default based on name pattern matching
|
||||
1. Global environment variable (`GOOSE_CONTEXT_LIMIT`)
|
||||
2. Explicit declarative or custom provider model configuration
|
||||
3. Provider runtime discovery
|
||||
4. Canonical model metadata
|
||||
5. Global default (128,000 tokens)
|
||||
|
||||
**Configuration**
|
||||
@@ -348,22 +347,6 @@ export GOOSE_MODEL="my-custom-gpt4-proxy"
|
||||
export GOOSE_CONTEXT_LIMIT=200000 # Override the 32k default
|
||||
```
|
||||
|
||||
2. Planner setup with a different context limit
|
||||
|
||||
```bash
|
||||
# Set a larger context window for planning
|
||||
export GOOSE_PLANNER_MODEL="claude-opus-custom"
|
||||
export GOOSE_PLANNER_CONTEXT_LIMIT=500000
|
||||
```
|
||||
|
||||
3. Planner with large context
|
||||
|
||||
```bash
|
||||
# Large context for complex planning
|
||||
export GOOSE_PLANNER_MODEL="gpt-4-custom"
|
||||
export GOOSE_PLANNER_CONTEXT_LIMIT=1000000
|
||||
```
|
||||
|
||||
## Credit Balance Monitoring
|
||||
|
||||
goose monitors your API provider balance and warns you when credits are running low or exhausted. When this happens, you'll see an **Insufficient Credits** notification.
|
||||
|
||||
Reference in New Issue
Block a user