Skip to content

fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars#7900

Merged
DOsinga merged 1 commit intoblock:mainfrom
jeffa-block:jeffa/fix-context-limit-config-yaml
Mar 26, 2026
Merged

fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars#7900
DOsinga merged 1 commit intoblock:mainfrom
jeffa-block:jeffa/fix-context-limit-config-yaml

Conversation

@jeffa-block
Copy link
Copy Markdown
Contributor

Problem

ModelConfig::new_base() reads GOOSE_CONTEXT_LIMIT via std::env::var(), which only checks environment variables. Users who set the value in config.yaml have it silently ignored for the lead model, even though the same key works for the worker model (which uses Config::global().get_param() in init.rs).

Fix

Switch to Config::global().get_param() which checks environment variables first (preserving existing behaviour) then falls back to config.yaml. This matches how GOOSE_MAX_TOKENS is already read in the same file and how GOOSE_CONTEXT_LIMIT is read for the worker model in init.rs.

Testing

All 16 model::tests pass.

Partially addresses #7839. Complements #7888.

`ModelConfig::new_base()` read `GOOSE_CONTEXT_LIMIT` via
`std::env::var()`, which only checks environment variables.  Users
who set the value in config.yaml (e.g. `GOOSE_CONTEXT_LIMIT: 1000000`)
had it silently ignored for the lead model.

Switch to `Config::global().get_param()` which checks environment
variables first (preserving existing behaviour) then falls back to
config.yaml.  This matches how `GOOSE_MAX_TOKENS` is already read in
the same file and how `GOOSE_CONTEXT_LIMIT` is read for the worker
model in `init.rs`.

Partially addresses block#7839 (Option B). Complements block#7888 which fixes
predefined model priority (Option A).
@DOsinga DOsinga marked this pull request as ready for review March 26, 2026 21:22
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DOsinga DOsinga added this pull request to the merge queue Mar 26, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e503c3b25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +93 to +97
if limit == 0 {
return Err(ConfigError::InvalidRange(
"GOOSE_CONTEXT_LIMIT".to_string(),
"must be greater than 0".to_string(),
));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reinstate minimum 4K validation for GOOSE_CONTEXT_LIMIT

This new branch only rejects GOOSE_CONTEXT_LIMIT == 0, so values from 1..4095 now pass when read via Config::global().get_param() (including env var overrides), whereas the previous code path enforced >= 4 * 1024 through validate_context_limit. That regression allows unrealistically small context windows that were previously blocked and can lead to immediate context-exceeded behavior in normal sessions. Reusing validate_context_limit (or preserving the same lower bound here) would keep the prior contract.

Useful? React with 👍 / 👎.

Merged via the queue into block:main with commit 143a269 Mar 26, 2026
20 checks passed
michaelneale added a commit that referenced this pull request Mar 26, 2026
* main: (337 commits)
  fix: replace panics with user-friendly errors in CLI session builder (#7901)
  fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900)
  fix: deliver truncation notice as separate content block (#7899)
  fix: use platform-appropriate commands in developer extension instructions (#7898)
  fix: replace any with proper SVG types in icon components (#7873)
  chore: remove debug console.log statements, stale comments, and dead code (#8142)
  feat: Gemini OAuth provider (#8129)
  chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123)
  feat: show installed skills in UI (#7910)
  fix(deps): gate keyring platform features behind target-specific deps (#8039)
  chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124)
  fix: strip message wrapper in CLI session title generation (#7996)
  fix(providers): fall back to configured models when models endpoint fetch fails (#7530)
  chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139)
  fix: prevent Ollama provider from hanging on tool-calling requests (#7723)
  fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126)
  feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097)
  fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019)
  fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054)
  feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919)
  ...

# Conflicts:
#	crates/goose/src/providers/formats/openai.rs
michaelneale added a commit that referenced this pull request Mar 30, 2026
* origin/main: (63 commits)
  remove name from blog post (#8157)
  fix: use `overflow: clip` to not disrupt sticky ToC (#8158)
  chore(deps): bump path-to-regexp from 0.1.12 to 0.1.13 in /documentation (#8161)
  chore(deps): bump node-forge from 1.3.2 to 1.4.0 in /documentation (#8145)
  refactor: goose-acp-server -> goose binary for TUI (#8155)
  fix "View as Markdown" feature not working (#8160)
  feat(tui): UI improvements for messages, tool calls, text entry, etc (#8156)
  feat(desktop): add i18n infrastructure with react-intl (#8105)
  fix(tui): ordering of messages (#8144)
  fix: extension command with quotes in  cli (#8150)
  chore(aaif): Use Azure Artifact Signing for Windows (#8116)
  chore(aaif): Switch macOS code signing (#8076)
  Remove unused tool call json in logs (#8147)
  feat(tui): tab expand tool calls cleanly (#8136)
  fix: replace panics with user-friendly errors in CLI session builder (#7901)
  fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900)
  fix: deliver truncation notice as separate content block (#7899)
  fix: use platform-appropriate commands in developer extension instructions (#7898)
  fix: replace any with proper SVG types in icon components (#7873)
  chore: remove debug console.log statements, stale comments, and dead code (#8142)
  ...
hydrosquall pushed a commit to hydrosquall/goose that referenced this pull request Mar 31, 2026
blackgirlbytes pushed a commit that referenced this pull request Apr 2, 2026
* main: (337 commits)
  fix: replace panics with user-friendly errors in CLI session builder (#7901)
  fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900)
  fix: deliver truncation notice as separate content block (#7899)
  fix: use platform-appropriate commands in developer extension instructions (#7898)
  fix: replace any with proper SVG types in icon components (#7873)
  chore: remove debug console.log statements, stale comments, and dead code (#8142)
  feat: Gemini OAuth provider (#8129)
  chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123)
  feat: show installed skills in UI (#7910)
  fix(deps): gate keyring platform features behind target-specific deps (#8039)
  chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124)
  fix: strip message wrapper in CLI session title generation (#7996)
  fix(providers): fall back to configured models when models endpoint fetch fails (#7530)
  chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139)
  fix: prevent Ollama provider from hanging on tool-calling requests (#7723)
  fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126)
  feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097)
  fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019)
  fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054)
  feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919)
  ...

# Conflicts:
#	crates/goose/src/providers/formats/openai.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants