Repository navigation
fix(memory): inherit default context limits when an agent overrides one - #164633
Conversation
Merge per-agent context-limit overrides over the defaults instead of replacing the entire object. An unrelated postCompactionMaxChars override must not silently discard the documented memoryGetMaxChars inheritance. The host adapter consolidation in 025081d introduced the raw-object fallback. Cover omitted, partial, and explicit agent limits through readAgentMemoryFile without changing config or SDK contracts. Before: an isolated Gateway returned all 7,999 characters despite a 2,000 character default. After: the same flow returns a 1,999-character excerpt, truncation metadata, and continuation at line 21 (2,051 characters total). The regression failed before the fix and passes afterward. Validation on Blacksmith Testbox, rebased onto 3562b69: - 108 related memory tests across eight files passed. - pnpm test packages/memory-host-sdk/src/host/read-file.test.ts --maxWorkers=1: 18 passed, 2.55s Testbox wall time, 1.44s Vitest duration. - pnpm build and node scripts/check-changed.mjs passed. - Stub-provider Gateway proof passed automatic/manual compaction, history retention, concurrent turns, visible summarization failure, and restart after and during compaction. - Agent-driven memory write, cross-session read/search, cross-agent isolation, and restart continuity passed with isolated state and no real credentials. Formatting and validation ran remotely; local hooks were skipped to honor the campaign's no-local-build/test/tooling requirement.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 8:32 PM ET / October 4, 2026, 00:32 UTC. ClawSweeper reviewWhat this changesThe PR merges per-agent memory context limits over shared defaults and adds file-read regression cases for omitted, partial, and explicit overrides. Merge readiness✅ Ready for maintainer review This PR remains useful: pinned current main still drops inherited memory limits when an agent supplies a partial override. The focused repair matches the documented contract, and no blocking patch defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's memory reader turns agent configuration and Markdown files into model-visible excerpts. Resolved character limits control truncation and continuation guidance returned by memory_get. flowchart TD
A[Shared context limits] --> C[Resolve agent limits]
B[Agent overrides] --> C
C --> E[Read memory file]
D[Memory request and Markdown file] --> E
E --> F[Apply excerpt budget]
F --> G[Excerpt and continuation guidance]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +30. Total +31 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep memory reads aligned with the existing field-by-field inheritance contract while preserving explicit agent limits and continuation behavior. Do we have a high-confidence way to reproduce the issue? Yes, from source: configure a 2,000-character default, override only postCompactionMaxChars for an agent, and read a longer memory file. Pinned main loses the configured cap; execution was not performed in this read-only review. Is this the best way to solve the issue? Yes. Merging at the existing memory-host resolver restores documented semantics without changing the public API or persisted config, and the regression cases protect inherited and explicit caps. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2df2d8455db0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…164633) Merge per-agent context-limit overrides over the defaults instead of replacing the entire object. An unrelated postCompactionMaxChars override must not silently discard the documented memoryGetMaxChars inheritance. The host adapter consolidation in 280b6c5 introduced the raw-object fallback. Cover omitted, partial, and explicit agent limits through readAgentMemoryFile without changing config or SDK contracts. Before: an isolated Gateway returned all 7,999 characters despite a 2,000 character default. After: the same flow returns a 1,999-character excerpt, truncation metadata, and continuation at line 21 (2,051 characters total). The regression failed before the fix and passes afterward. Validation on Blacksmith Testbox, rebased onto fa864a2: - 108 related memory tests across eight files passed. - pnpm test packages/memory-host-sdk/src/host/read-file.test.ts --maxWorkers=1: 18 passed, 2.55s Testbox wall time, 1.44s Vitest duration. - pnpm build and node scripts/check-changed.mjs passed. - Stub-provider Gateway proof passed automatic/manual compaction, history retention, concurrent turns, visible summarization failure, and restart after and during compaction. - Agent-driven memory write, cross-session read/search, cross-agent isolation, and restart continuity passed with isolated state and no real credentials. Formatting and validation ran remotely; local hooks were skipped to honor the campaign's no-local-build/test/tooling requirement. Co-authored-by: Peter Steinberger <[email protected]>
…irs for 8.35-D Adapt official PRs openclaw#140388, openclaw#156842, openclaw#168738, openclaw#169010, openclaw#165444, openclaw#164633 and openclaw#169029 to the existing synchronous 2026.8.35 custom queue and plugin baseline. Preserve prior A/B/C repairs, UI, locked dependencies, database schemas, configuration and build customizations. Canonical build source: 7fdcb8a1f5b9cec7c1e9d66bc8ae551a38f0ed70 Verified complete source tree: 6511c79 Upstream base: 713ba57 Selected regression boundaries: 247 tests passed; core and plugin production typechecks passed; bounded P0 autoreview scoped-clean. Broader Windows cleanup/symlink EPERM limits are recorded in local verification. No live Telegram-group test or full repository-green claim. Saved ordinary inbound final text permits one retry after typed ambiguous transport failure, at most two total sends, with possible duplicate after a lost acknowledgement. Media, controls and accepted partial/identityless evidence remain excluded. This does not grant all cron/invest completion paths replay permission. Candidate build only; no production deployment or memory reset.
What Problem This Solves
memory_getinjected far more text into the model context than the configured limit when an agent overrode only part of its memory context limits. With a defaultmemoryGetMaxChars: 2000and an agent that overrides onlypostCompactionMaxChars, a read returned 7,999 untruncated characters and no continuation pointer. The default excerpt cap, which bounds model-visible context, silently stopped applying.Why This Change Was Made
packages/memory-host-sdk/src/host/config-utils.tsresolved agent context limits by replacing the defaults object with the agent's partial object instead of merging field by field (introduced by025081dbc576). Any agent-level override therefore dropped every inherited limit it did not repeat. The resolver now merges agent fields over the defaults, so unspecified limits are inherited.User Impact
Agents that customize one memory limit keep the default excerpt bound on
memory_get: reads return a bounded excerpt plus continuation guidance (nextFrom) instead of flooding the context.Evidence
nextFrom: 21).3562b697df6: 108 tests across eight related suites,pnpm build, andcheck-changedpass.