Repository navigation
perf(models): release unused account catalog instructions - #174361
Conversation
Cache projected OpenAI account catalog facts instead of raw backend model responses, which also carry unused instruction templates. Add bounded size-only catalog worker diagnostics on the existing memory sampling channel. Focused regressions cover raw response collection, cache reuse and account isolation, cache lifecycle, worker transport, and diagnostic sanitization. Synthetic account breadth measurements show raw response retention is removed; production attribution awaits deployment.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Move existing Codex row normalization into the row helper owner and existing live catalog test helpers into test support. Preserve the account catalog and retention regression coverage while satisfying the changed-file line-cap ratchet.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 700b987af5
ℹ️ 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".
Restrict the size census to plain record and array data properties. Skip proxies, custom instances and accessors with an explicit partial estimate instead of invoking plugin-owned behavior during worker sampling. The shared-cache regression reproduces proxy trap execution before the fix and verifies safe sampling afterward. Focused cache and estimator tests and independent review pass.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a6385cd62
ℹ️ 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".
|
Merged as 1b9fe6a under the authorized inherited-failure exception, pinned to reviewed head 9d489a6. Final CI run 38928137387 completed. The three remaining failing jobs were unchanged-main defects: five guided custom-provider onboarding assertions at line 346 (reproduced on main: 5 failed / 12 passed), duplicate-scanner coverage missing cli-parent-lifetime.mjs (reproduced with the coverage-only command), and the ungrandfathered darwin-bun-process-census mock in doctor-plugin-source-captures.test.ts (identical scanner fingerprint on the exact main parent and tested merge). Exact commits, job links, commands, and attribution are recorded in the PR body. Aggregate CI gates remained red for those failures; they were not reported as green. Other applicable checks and security-fast passed. Independent review is clean, both diagnostics findings are fixed, and all review threads are resolved. No CI reruns or green-chasing branch updates were used. Production post-deployment memory confirmation remains a follow-up. |
* commit '14e993fff3ecb84eb1d7c9724c4ceda235d797e4': (110 commits) fix(decisions): align accounting ratchet evidence feat(memory): activate PostgreSQL memory search and lifecycle (#174374) fix: join process shutdown and isolate runtime fixtures (#174359) refactor(ui): scope native gateway observation to Solid (#174367) refactor(ui): own canvas widget lifetime in Solid (#174370) perf(control-ui): keep agent avatar faces stable across agent publications (#174239) perf(models): release unused account catalog instructions (#174361) refactor(ui): own composer command menus in Solid stores (#174321) refactor(ui): separate sidebar filter state from view lifecycle (#174352) test(release): make artifact qualification deadlines deterministic fix(codex): preserve sandboxed process inspection and setup errors (#174284) fix(gateway): stop worker processes before draining their queues (#174312) refactor(agents): reuse prepared tool facts (#174349) test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331) refactor(ui): replace MCP retirement host adapters with a factory (#174375) refactor(logging): remove redundant native success traces (#174330) refactor(test): remove dead control-plane fixture branches (#174377) refactor(mcp): remove test-only session runtime seams (#174347) feat(matrix): account-root state databases follow the selected engine (#174315) refactor(discord): collapse private interaction and factory seams (#174322) ...
* commit '14e993fff3ecb84eb1d7c9724c4ceda235d797e4': (110 commits) fix(decisions): align accounting ratchet evidence feat(memory): activate PostgreSQL memory search and lifecycle (#174374) fix: join process shutdown and isolate runtime fixtures (#174359) refactor(ui): scope native gateway observation to Solid (#174367) refactor(ui): own canvas widget lifetime in Solid (#174370) perf(control-ui): keep agent avatar faces stable across agent publications (#174239) perf(models): release unused account catalog instructions (#174361) refactor(ui): own composer command menus in Solid stores (#174321) refactor(ui): separate sidebar filter state from view lifecycle (#174352) test(release): make artifact qualification deadlines deterministic fix(codex): preserve sandboxed process inspection and setup errors (#174284) fix(gateway): stop worker processes before draining their queues (#174312) refactor(agents): reuse prepared tool facts (#174349) test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331) refactor(ui): replace MCP retirement host adapters with a factory (#174375) refactor(logging): remove redundant native success traces (#174330) refactor(test): remove dead control-plane fixture branches (#174377) refactor(mcp): remove test-only session runtime seams (#174347) feat(matrix): account-root state databases follow the selected engine (#174315) refactor(discord): collapse private interaction and factory seams (#174322) ...
* commit '0c6c7ee5837ed93f6fb09ca58b280e76878c21f1': (109 commits) feat(memory): activate PostgreSQL memory search and lifecycle (#174374) fix: join process shutdown and isolate runtime fixtures (#174359) refactor(ui): scope native gateway observation to Solid (#174367) refactor(ui): own canvas widget lifetime in Solid (#174370) perf(control-ui): keep agent avatar faces stable across agent publications (#174239) perf(models): release unused account catalog instructions (#174361) refactor(ui): own composer command menus in Solid stores (#174321) refactor(ui): separate sidebar filter state from view lifecycle (#174352) test(release): make artifact qualification deadlines deterministic fix(codex): preserve sandboxed process inspection and setup errors (#174284) fix(gateway): stop worker processes before draining their queues (#174312) refactor(agents): reuse prepared tool facts (#174349) test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331) refactor(ui): replace MCP retirement host adapters with a factory (#174375) refactor(logging): remove redundant native success traces (#174330) refactor(test): remove dead control-plane fixture branches (#174377) refactor(mcp): remove test-only session runtime seams (#174347) feat(matrix): account-root state databases follow the selected engine (#174315) refactor(discord): collapse private interaction and factory seams (#174322) refactor(feishu): reuse streaming merge in dispatcher tests (#174371) ...
* commit '14e993fff3ecb84eb1d7c9724c4ceda235d797e4': (110 commits) fix(decisions): align accounting ratchet evidence feat(memory): activate PostgreSQL memory search and lifecycle (#174374) fix: join process shutdown and isolate runtime fixtures (#174359) refactor(ui): scope native gateway observation to Solid (#174367) refactor(ui): own canvas widget lifetime in Solid (#174370) perf(control-ui): keep agent avatar faces stable across agent publications (#174239) perf(models): release unused account catalog instructions (#174361) refactor(ui): own composer command menus in Solid stores (#174321) refactor(ui): separate sidebar filter state from view lifecycle (#174352) test(release): make artifact qualification deadlines deterministic fix(codex): preserve sandboxed process inspection and setup errors (#174284) fix(gateway): stop worker processes before draining their queues (#174312) refactor(agents): reuse prepared tool facts (#174349) test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331) refactor(ui): replace MCP retirement host adapters with a factory (#174375) refactor(logging): remove redundant native success traces (#174330) refactor(test): remove dead control-plane fixture branches (#174377) refactor(mcp): remove test-only session runtime seams (#174347) feat(matrix): account-root state databases follow the selected engine (#174315) refactor(discord): collapse private interaction and factory seams (#174322) ...
* commit '0c6c7ee5837ed93f6fb09ca58b280e76878c21f1': (109 commits) feat(memory): activate PostgreSQL memory search and lifecycle (#174374) fix: join process shutdown and isolate runtime fixtures (#174359) refactor(ui): scope native gateway observation to Solid (#174367) refactor(ui): own canvas widget lifetime in Solid (#174370) perf(control-ui): keep agent avatar faces stable across agent publications (#174239) perf(models): release unused account catalog instructions (#174361) refactor(ui): own composer command menus in Solid stores (#174321) refactor(ui): separate sidebar filter state from view lifecycle (#174352) test(release): make artifact qualification deadlines deterministic fix(codex): preserve sandboxed process inspection and setup errors (#174284) fix(gateway): stop worker processes before draining their queues (#174312) refactor(agents): reuse prepared tool facts (#174349) test(gateway,plugins,ui): remove low-value tests (batch d174) (#174331) refactor(ui): replace MCP retirement host adapters with a factory (#174375) refactor(logging): remove redundant native success traces (#174330) refactor(test): remove dead control-plane fixture branches (#174377) refactor(mcp): remove test-only session runtime seams (#174347) feat(matrix): account-root state databases follow the selected engine (#174315) refactor(discord): collapse private interaction and factory seams (#174322) refactor(feishu): reuse streaming merge in dispatcher tests (#174371) ...
…74361) * perf(models): release unused account catalog instructions Cache projected OpenAI account catalog facts instead of raw backend model responses, which also carry unused instruction templates. Add bounded size-only catalog worker diagnostics on the existing memory sampling channel. Focused regressions cover raw response collection, cache reuse and account isolation, cache lifecycle, worker transport, and diagnostic sanitization. Synthetic account breadth measurements show raw response retention is removed; production attribution awaits deployment. * refactor(openai): extract catalog helpers within file limits Move existing Codex row normalization into the row helper owner and existing live catalog test helpers into test support. Preserve the account catalog and retention regression coverage while satisfying the changed-file line-cap ratchet. * fix(diagnostics): avoid executing opaque catalog values Restrict the size census to plain record and array data properties. Skip proxies, custom instances and accessors with an explicit partial estimate instead of invoking plugin-owned behavior during worker sampling. The shared-cache regression reproduces proxy trap execution before the fix and verifies safe sampling afterward. Focused cache and estimator tests and independent review pass. * docs(models): state the catalog cache type invariant * fix(diagnostics): count static catalog records without plugin reads
What Problem This Solves
Account model discovery retains unused backend instruction templates, so catalog-worker memory grows with distinct authenticated account catalogs.
User Impact
OpenAI account discovery now retains only projected models and account availability facts. Operators can inspect size-only catalog-worker data through
openclaw gateway stability --type diagnostic.memory.sample --limit 1 --json, without heap snapshots, catalog contents, object keys, identities, or secrets.Why This Change Was Made
The backend response includes both current instruction templates and a legacy rendered instruction field. Projection previously happened after raw rows entered the shared cache. Moving projection inside the loader drops both unused copies while preserving account/token/endpoint isolation, coalescing, expiry, refresh, cancellation, and failures.
The existing cache moves behind its unchanged SDK exports to one internal owner. A bounded census on the existing worker-memory channel covers config, plugin metadata, models, pricing, cached provider results, auth stores, and active requests. Estimates can overlap across categories and do not cover module/closure internals. Only plain records and arrays are traversed; proxies, custom instances, and accessors yield partial estimates without executing plugin code. No schema, configuration, or retention-policy change.
Evidence
A synthetic Linux run exercises the actual prepared-model catalog worker and OpenAI provider, with 12 models per account and two 64 KiB instruction fields per model. Network access is disabled. After collection, worker old space is:
At 40 accounts, old space falls 28.3%. Growth from 1 to 40 accounts falls from 59.10 MiB to 0.67 MiB. All 40 account discoveries fetch once and return the expected catalog. The measured worker census reports one prepared generation, 40 cached provider results totaling approximately 548,380 bytes, and no pending loads or active task input. An OpenAI-only run produces the same reduction within 0.08 MiB, isolating the retention fix from the diagnostics.
This is a synthetic account-breadth sweep, not an exact production reproduction. Source-mode runtime overhead differs from a compiled deployment. Production runtime account breadth and post-deployment old space remain unverified; the census enables that follow-up safely.
Production delta: +595/-263 (+332 LOC); tests/support: +417/-108 (+309 LOC). Required size-only introspection accounts for the growth; raw response retention and the old cache implementation are replaced, with no parallel cache or speculative fast path.
The static census counts retained provider records rather than reading plugin-owned model arrays. Both proxy and accessor regressions fail at the old direct property read, then pass after removing it (4 ms test time; 35.11 s including cold worker preparation). Independent review is clean. The stale assertion baseline entry for the moved SDK implementation is removed; the actual scanner reports zero undocumented assertions in both the SDK re-export and internal cache owner.
Baseline CI attribution
b460ee8d2ab41bf94bb8518e7330290787ea3465, using its CI-built artifact, reproduces 5 failed / 12 passed in the singlesrc/commands/onboard-guided.custom-provider.e2e.test.tsfile. Command:OPENCLAW_E2E_USE_PREBUILT_DIST=1 pnpm test src/commands/onboard-guided.custom-provider.e2e.test.ts --maxWorkers=1. All five failures are line 346 expectingundefinedfor the intentional saved-profile reference. This matches the PR's earlier failed job. The test, model-selection writer, credential/activation owners, and provider-snapshot test have identical blobs on this baseline and CI's later main parent5aec205816506ceb6983a5ab1c549c9e0b301a61.node scripts/check-duplicates.mjs --coverageon unchanged main5aec205816506ceb6983a5ab1c549c9e0b301a61exits 1 forcli-parent-lifetime.mjs, matching the PR guard failure. Neither the file nor the scanner differs between that baseline and tested merged144d31abccf4ab7ece17fd3a1bcc1805aa42845.src/flows/doctor-plugin-source-captures.test.ts, reports the ungrandfathereddarwin-bun-process-census.jsmock at line 32, matching the CI ratchet job. This is separate from this PR's repaired stale assertion entry.Final CI run 38928137387 completed for head
9d489a6e59556b2cdf87e9a46138c41bf4f4764a. Its tested merge isfef941b9934b60ecc04b8921b63a6af13a9836c2, with ordered parents0dc31f5f64309d199f12aea643452bfde54f4888(main) and the PR head. The assertion and line-cap repairs pass,security-fastpasses, and all review threads are resolved. PR checks report 85 successes; the remaining failures are these three inherited jobs and their aggregate CI gates:cli-parent-lifetime.mjs. Scanner and file are unchanged from the reproduced main baseline through the tested merge.doctor-plugin-source-captures.test.ts. A targeted replay of the actual scanner on the exact main parent and tested merge produces the identical ungrandfathered fingerprint0f314816d50228e6240f1048998f802dd80d499ba91277a72f2a366e9c574dd2.Landing uses the authorized inherited-failure exception. No CI reruns, dispatches, or branch updates were used to chase green.