Skip to content

docs(openclaw): recommend setting context_window - #4547

Merged
athitten merged 1 commit into
mainfrom
athitten/openclaw-context-window-docs
Oct 12, 2026
Merged

athitten merged 1 commit into
mainfrom
athitten/openclaw-context-window-docs

Conversation

@athitten

Copy link
Copy Markdown
Contributor

What does this PR do?

README only. Tells OpenClaw users to set context_window to the model server's maximum context length, and explains how OpenClaw uses it and max_output_tokens. Follow-up to #4476, which lets sandbox sessions use max_output_tokens; there is no issue.

Why: when context_window is unset, OpenClaw assumes 200,000 tokens. On a server with a smaller limit, it keeps requesting its full output limit and does not compact in time, so long episodes can send requests the server rejects. Gym's vllm_model returns an empty reply, not an error, by default, and the run ends early.

Example, worked out from the code and not measured in a run: released vLLM (up to 0.31) rejects a call when prompt + requested output > max_model_len. At 131,072 with no context_window, calls fail once the prompt passes 122,880 tokens (131,072 − 8,192 default), or 98,304 with max_output_tokens: 32768 (131,072 − 32,768). With context_window: 131072, OpenClaw lowers each call's output to fit the room left by its estimate of the input; the estimate can undercount code or JSON. Unreleased vLLM main (vllm-project/vllm#57035) lowers the output instead of rejecting, but still rejects a prompt longer than max_model_len.

The sandbox section now also says that the request field is rejected but the agent config field applies, and that a max_output_tokens above context_window is rejected (the check from #4476).

Validation

  • Read the OpenClaw npm package at 2026.6.11 (pinned in configs/openclaw_agent.yaml) and at 2026.6.35 (the pin in feat(rollout): add multi-harness fan-out training #4082). Both match the README:
    • contextWindow defaults to 200,000 and maxTokens to min(8,192, contextWindow) (dist/io-*.js);
    • each call requests at most min(maxTokens, contextWindow − estimated input − 1), where the estimate is characters / 4 × 1.25. This applies to any base URL other than OpenAI's or Azure OpenAI's, which covers Gym's model server (dist/openai-transport-stream-*.js);
    • two in-run limits are computed from contextWindow. One is the context guard: once a run passes its limit, OpenClaw compacts and retries (installToolResultContextGuard in dist/selection-*.js). The other is the cap on each tool result's size (resolveLiveToolResultMaxChars in dist/tool-result-truncation-*.js).
  • Gym code on main: _build_openclaw_config writes contextWindow and maxTokens only when they are set, and vllm_model returns an empty length completion on a context-length error unless propagate_context_overflow_errors is true.
  • Open PRs touching OpenClaw: feat(terminal-bench): support Pi, Codex, OpenCode and OpenClaw #3902 and feat(openclaw_agent): consume rollout-scoped Gym MCP metadata #2733 edit this README, and feat(rollout): add multi-harness fan-out training #4082 moves the pin to 2026.6.35. git merge-tree shows this PR adds no conflicts with any of them.
  • pre-commit run --all-files: passed.

Rollouts

N/A: README-only change, with no code or config changes.

Compatibility and benchmark impact

None from this PR. Following the advice can change rollouts with long episodes or long tool results, because context_window also sets when OpenClaw compacts and how much of a tool result it keeps.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). N/A: docs-only.
  • Documentation added or updated, or N/A with justification.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header. N/A: no new files.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@athitten athitten added area:agent Agent harnesses and Responses API agent behavior docs Documentation-only updates or documentation debt labels Oct 12, 2026
@athitten

Copy link
Copy Markdown
Contributor Author

/ok to test 4276d40

@athitten
athitten added this pull request to the merge queue Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38322542872

@yaoyu-33 yaoyu-33 added complexity:low Localized change in one scope with a small, straightforward review surface ready-to-merge PR is approved, current, and waiting for final CI or merge labels Oct 12, 2026
Merged via the queue into main with commit 30f63c2 Oct 12, 2026
52 of 54 checks passed
@athitten
athitten deleted the athitten/openclaw-context-window-docs branch October 12, 2026 23:48

This branch was previously deployed

1 inactive deployment
public — 4276d40e Deployed Oct 12, 2026 by copy-pr-bot[bot] via release / finalize / notify #5108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior complexity:low Localized change in one scope with a small, straightforward review surface docs Documentation-only updates or documentation debt ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants