Repository navigation
docs(integrations): size Pi and OpenClaw context windows for the gateway ceiling - #2892
Conversation
…way ceiling The gateway accepts at most 1 MiB of model input after injection and cost guidance, and both hosts resend the whole history on every request. At the examples' 400000-token window, a long session reached that ceiling before the host compacted, so its requests failed with 413 or 403 request_payload_too_large. State the ceiling in both guides and derive the example contextWindow from each host's compaction trigger: 128000 for OpenClaw (20000-token reserve) and, for Pi, 80000, so it also fits the byte-counted window check of the guide's enforcing example target; 128000 applies to Pi with a non-enforcing Core. Part of oceanbase#2250.
hidb4ai
left a comment
There was a problem hiding this comment.
Reviewed 997eb6b. No blocking defect found in this documentation-only change. The smaller example windows and estimated compaction thresholds are consistent with the referenced host implementations and the Core/Gateway limits. No new database tables, migrations, or public interfaces. Merge score: 85/100.
Validation covered host-source inspection, bilingual examples and link targets, link-validation tests, and a conflict-free merge-tree check. No live host/LLM long-session acceptance was performed; the documented byte estimates are not a hard guarantee. CI remains blocked by the persistence compatibility digest check: the same failure reproduces on the base and head with identical managed-input digests. Required CI still needs to pass before merging.
Which issue or RFC does this PR close?
Part of #2250 (step 5: hosts behind the gateway).
Rationale for this change
The Pi and OpenClaw guides show a model entry with
contextWindow: 400000for running behind the PowerContext gateway. The gateway accepts at most 1 MiB of model input, measured after it injects context and adds its cost guidance, and configuration cannot raise that ceiling (Gateway byte capacity). A request that arrives larger fails with HTTP 413. One that grows past the ceiling through injection or cost guidance fails with HTTP 403request_payload_too_large. In both cases the model is never called. Both hosts resend the session's whole history on every request. At a 400000-token window, a long session therefore reaches 1 MiB long before the host compacts: at about four bytes per token, Pi's trigger at that window is about 1.5 MB.The Pi guide has a second, tighter limit. Its Core example is an enforcing target with
context_window_tokens: 400000andmax_output_tokens: 32000. Core's window check counts each byte of the request as a token. It withholds withcontext_window_exceededwhen the request's bytes plus the output limit plus a 64-token protocol reserve exceed the window, which for that target means more than 367,936 bytes (_budgetinsrc/powercontext/builtin/inference/privacy.py). This check applies only under an enforcing Core (context_check.py). With the merged example, an enforcing Core starts withholding a Pi session at roughly 92k tokens, long before Pi compacts at 383,616.What changes are included in this PR?
Docs only, en and zh:
integrations/pi.md: the example'scontextWindowgoes from 400000 to 80000. New paragraphs state the 1 MiB ceiling (with a link), the 413/403 outcomes, and the enforcing window check, which with the example target withholds requests over about 368,000 bytes. They explain how the value was derived:contextWindowminuscompaction.reserveTokens, which defaults to 16384 (shouldCompactindist/core/compaction/compaction.js; default insettings-manager.js)._checkCompactioninagent-session.js), not between tool-loop requests.80000compacts above 63,616 tokens, about 254 KB at four UTF-8 bytes per token, under the 367,936 bytes the example target admits.128000compacts above 111,616 tokens, about 446 KB.compaction.keepRecentTokens).integrations/openclaw.md: the example'scontextWindowgoes from 400000 to 128000. The same ceiling paragraph is added, plus the derivation:contextTokens > contextWindow - reserveTokens(checkCompactionindist/sessions-*.js,shouldCompactindist/agent-core-*.js).DEFAULT_AGENT_COMPACTION_RESERVE_TOKENS_FLOORindist/openclaw-runtime-*.js).128000compacts by 108,000 tokens at the latest, about 432 KB.Decision: the four-bytes-per-token figure matches the Kimi Code guide's assumption on its gateway branch. The values leave room for the gateway's additions, which are small: a prepared context of at most 8192 bytes (
default_max_bytesinpc-gateway-types/src/prepare.rs) and steering instructions of at most 4,096 bytes. The rest of the margin covers JSON overhead and the tool results that one prompt or run adds before the host's next check.Overlap with open PRs: #2893 edits
pi.mdand #2895 editsopenclaw.md, both in the same gateway sections, and #2889 and #2735 also edit these guides. None of them changes the model entries or the paragraphs this PR adds. Against this branch,git merge-treeis clean for #2889 and for the current heads of #2893 (f7cd8a5) and #2895 (6ed8bea), which merge master too. #2735 conflicts only inrelease/upgrade-support.json, as it does against master; this PR does not touch that file.Are there any user-facing changes?
Yes, docs only. The Pi and OpenClaw gateway examples now use a smaller
contextWindowand explain the gateway's input ceiling. Users who copied400000should lower it. No code, API, or persisted-format changes.How was this change tested?
pnpm check:linksinwebsite/, run offline (no network in the sandbox, existingnode_modules,UV_OFFLINE=1): link tests pass, and links are validated in 379 public pages and 672 repository files.@earendil-works/pi-coding-agent0.82.1, the version installed for the package'sdevDependenciesrange (^0.82.0).openclaw2026.8.1-beta.2, the plugin'speerDependenciesfloor.src/powercontext/builtin/inference/privacy.pyandsrc/powercontext/builtin/runtime/context_check.py.AI usage statement
Written with Claude Code (Claude Opus 5.5). It read the host sources and Core code, derived the values, and drafted the en and zh text. Another Claude Code session (Claude Opus 5.5) reviewed the commit and checked this description's claims against the guides, the Core and gateway code, and the overlapping PRs before it was opened. After #2630 merged, the first session merged master into the branch and reran the docs checks, and the reviewing session checked the merge, the merged guides, and this description's overlap claims before the push.