Skip to content

fix(memory): honor configured primary search result limits - #133254

Merged
steipete merged 1 commit into
mainfrom
codex/qa-20260830-memory-search-budget
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-20260830-memory-search-budget

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #133253

What Problem This Solves

Fixes an issue where operators who raised memory.search.query.maxResults above ten still received only ten primary-memory search hits when the model omitted a per-call limit. For example, a configured limit of 12 produced 12 eligible hits but serialized only ten to the model, with no truncation warning.

Why This Change Was Made

Primary search already owns ranking, visibility filtering, and the configured result window. Return those results directly instead of passing them through the wiki aggregation cap. Reuse settings from the current tool context and remove unused raw-result copies; live configuration refresh and revocation remain unchanged.

Wiki and combined searches keep their independent ten-result default, explicit overrides, balancing, and backfill. This does not change configuration schemas, index/storage behavior, provider calls, or recall persistence. Production LOC: +22/-22 (net 0); regression tests: +111.

User Impact

Primary memory_search calls now honor the configured result limit without requiring the model to repeat it. Existing defaults and explicit limits remain intact. The configuration reference now explains the separate primary and aggregate budgets.

Evidence

  • The actual tool JSON regression table failed two configured-12 cases before the fix, while eight default/explicit/wiki/all controls passed. The same ten cases all pass after the fix, including Unicode snippets, combined-result balancing, and spare-slot backfill.
  • All 42 existing search-tool tests pass, including live configuration changes and session-corpus filtering. The existing retained-tool configuration-disable control also passes.
  • Proof uses the existing synthetic manager seam and the real tool execution, visibility/projection, aggregation, and JSON serialization path. No live provider, database, or index is involved; source hashes remained unchanged during each run.
  • Validation commands: OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/memory-core/src/tools.budget.test.ts; the same wrapper for extensions/memory-core/src/tools.test.ts, and extensions/memory-core/src/tools.citations.test.ts -t "revokes retained memory tools".
  • The canonical five-file node scripts/check-changed.mjs -- <changed files> gate passed: production/test type checks, scoped lint with zero warnings/errors, formatting, shared plugin-contract tests, and repository guards. Fresh Codex autoreview found no actionable P0 issue; an independent source/artifact review found no actionable finding.
  • Stable v2026.7.1 source contains the same unconditional aggregate cap. The owner history distinguishes the primary window from the intentional wiki/all aggregation behavior.

Known follow-up, unchanged here: combined searches queue primary recall tracking before final corpus selection, so tracked hits may exceed surfaced hits. This is a source-level observation, not a verified persistence defect; changing that behavior requires separate review.

Maintainer review follow-through: exact-head CI is green for d0f764cfcd22ab704e64e397763b8986c194d878. The current-main/release inspection gap in the ClawSweeper review is resolved by direct source inspection: extensions/memory-core, the primary configuration owner, and this documentation page are unchanged between the reproduction base and current main d498334714d255a992232f8175be1065fde11627. Stable v2026.7.1 source also applies the unconditional ten-result aggregation cap; this is source evidence, not a live test of that release.

The automated stored-data classification is not a material data-model change: this diff changes only transient tool context and result projection. It does not change embedding metadata, schemas, indexes, stored records, or recall-write arguments. The removed rawResults fields were unused copies in the transient aggregation value; the actual raw results supplied to recall tracking remain intact. No migration or new persistence behavior is introduced.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: S maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 10:10
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 6:34 AM ET / 10:34 UTC.

ClawSweeper review

What this changes

The PR makes primary-only memory searches use the configured result limit when a tool call omits its own limit, while retaining the ten-result budget for wiki and combined searches.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The patch is a coherent repair for the linked configured-budget bug and has no actionable introduced defect in this review. This PR remains open for maintainer handling because it carries the protected maintainer label and is the active candidate fix for the linked issue.

Priority: P2
Reviewed head: d0f764cfcd22ab704e64e397763b8986c194d878

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused net-neutral repair with direct model-visible regression coverage preserves the distinct aggregate-search contract.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied real-tool trace nevertheless maps the changed Memory Core tool path through the model-visible JSON result and reports the configured-budget cases passing after the repair.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied real-tool trace nevertheless maps the changed Memory Core tool path through the model-visible JSON result and reports the configured-budget cases passing after the repair.
Evidence reviewed 6 items Current-main bug remains: The fetched current-main version retains the unconditional corpus merge with maxResults ?? 10, so primary-only configured budgets still pass through the aggregate ten-result cap on main.
Introduced repair follows the owner boundary: The PR passes resolved settings to the tool execution, applies its query budget when obtaining primary results, and bypasses aggregation only when no wiki search runs; wiki/all remain on the aggregate budget.
Configuration contract: The resolver defines query.maxResults from agent override, global config, or the default of six, and the query owner caps filtered primary results to that resolved limit.
Findings None None.
Security None None.

How this fits together

Memory Core turns indexed memory and optional wiki matches into the model-visible memory_search tool result. Configuration supplies the primary-memory budget; the tool then selects a corpus, combines results only when needed, and serializes them for the model.

flowchart LR
  A[Memory search configuration] --> B[Memory Core tool]
  C[Primary memory matches] --> B
  D[Optional wiki matches] --> B
  B --> E{Requested corpus}
  E --> F[Primary results]
  E --> G[Combined result budget]
  F --> H[Model-visible JSON]
  G --> H
Loading

Before merge

  • Complete next step (P2) - Normal protected-label maintainer review is the remaining action; the linked issue is already paired with this open repair.
Agent review details

Security

None.

PR surface

Source 0, Tests +111, Docs +5. Total +116 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 22 22 0
Tests 1 111 0 +111
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 138 22 +116

Review metrics

Metric Value Why it matters
Production vs. regression coverage production net 0 (+22/-22); tests +111 The repair absorbs the behavior change into the existing tool flow while adding ten model-visible budget scenarios.

Stored data model

Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/tools.ts, vector/embedding metadata: extensions/memory-core/src/memory-tool-contract.ts, vector/embedding metadata: extensions/memory-core/src/tools.shared.ts, vector/embedding metadata: extensions/memory-core/src/tools.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #133253
Summary: This PR is the open candidate fix for the linked configured-primary-budget defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Merge the canonical primary-only budget repair after the normal protected-label maintainer review, retaining the separate wiki and combined-search budget behavior.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main applies a configured primary limit and then unconditionally applies a separate omitted-parameter ten-result merge cap; the PR's added tool-level table targets that deterministic path.

Is this the best way to solve the issue?

Yes. The branch removes the second cap only for primary-only searches and preserves the established aggregation path for wiki and combined searches.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d498334714d2.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: The bug silently reduces configured memory context but is limited to configured primary Memory Core searches.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied real-tool trace nevertheless maps the changed Memory Core tool path through the model-visible JSON result and reports the configured-budget cases passing after the repair.

Evidence

What I checked:

  • Current-main bug remains: The fetched current-main version retains the unconditional corpus merge with maxResults ?? 10, so primary-only configured budgets still pass through the aggregate ten-result cap on main. (extensions/memory-core/src/tools.ts:505, d498334714d2)
  • Introduced repair follows the owner boundary: The PR passes resolved settings to the tool execution, applies its query budget when obtaining primary results, and bypasses aggregation only when no wiki search runs; wiki/all remain on the aggregate budget. (extensions/memory-core/src/tools.ts:498, d0f764cfcd22)
  • Configuration contract: The resolver defines query.maxResults from agent override, global config, or the default of six, and the query owner caps filtered primary results to that resolved limit. (src/agents/memory-search.ts:281, d0f764cfcd22)
  • Regression and sibling coverage: The added table executes the real tool and parses model-visible JSON for configured primary, explicit overrides, wiki, and combined-search cases; existing tests retain live-config and combined-corpus coverage. (extensions/memory-core/src/tools.budget.test.ts:90, d0f764cfcd22)
  • Current-main comparison: No changes were found in the changed Memory Core or documentation paths between the PR base and fetched current main; the patch is not redundant with intervening base work. (extensions/memory-core/src/tools.ts:505, d498334714d2)
  • Release inspection limitation: The local v2026.7.1-2 tag resolves to 0790d9f, but retrieving its Memory Core blob requires the unavailable promisor remote; the submitted v2026.7.1 source claim was therefore not independently verified. (0790d9f593ad)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-30T10:17:27.071Z sha d0f764c :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for d0f764cfcd22ab704e64e397763b8986c194d878: exact-head CI run 33305832554 is green. Fresh Codex autoreview found no actionable P0 issue, and independent source/artifact review accepted this exact commit. The two configured-12 regressions fail before the fix; all ten primary/wiki/all cases, 42 existing owner tests, and the retained-tool revocation control pass after it. Production is +22/-22, net zero.

The latest ClawSweeper review found no actionable patch defect. Its current-main/release source gap is resolved: direct comparison of the entire Memory Core plugin, primary config owner, and affected docs against current main d498334714d255a992232f8175be1065fde11627 shows no changes since the reproduced base. Stable v2026.7.1 source contains the same extra cap. The PR body now records this evidence and explains the automated storage classification: only transient context/result projection changes; actual recall-write inputs, stored records, schema, index, and embedding metadata remain unchanged. No migration is needed.

Local commands, with isolated temporary state and one test worker:

node scripts/run-vitest.mjs extensions/memory-core/src/tools.budget.test.ts
node scripts/run-vitest.mjs extensions/memory-core/src/tools.test.ts
node scripts/run-vitest.mjs extensions/memory-core/src/tools.citations.test.ts -t "revokes retained memory tools"
node scripts/check-changed.mjs -- docs/reference/memory-config.md extensions/memory-core/src/memory-tool-contract.ts extensions/memory-core/src/tools.budget.test.ts extensions/memory-core/src/tools.shared.ts extensions/memory-core/src/tools.ts

The full changed gate passed. Proof exercises real tool execution and model-visible JSON with the existing synthetic manager seam; no live provider/model, database, or index run is claimed. The separate, source-only combined-search recall-tracking observation is documented as a follow-up and its persistence behavior is intentionally unchanged. Native review artifacts are validated; landing will use the repository's prepare/merge wrapper.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 30, 2026
@steipete
steipete merged commit ba1be2f into main Aug 30, 2026
244 checks passed
@steipete
steipete deleted the codex/qa-20260830-memory-search-budget branch August 30, 2026 10:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: memory_search silently caps configured primary limits at ten

1 participant