Skip to content

refactor(agents): keep attempt settings directly in memory - #178049

Merged
steipete merged 2 commits into
mainfrom
deslop/z34-29-in-memory-settings-20261015
Oct 20, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/z34-29-in-memory-settings-20261015

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The attempt-local SettingsManager still serializes prepared settings through an in-memory JSON store, queues synchronous writes, snapshots modified fields, and carries file reload/error/persistence paths. Neither production factory constructs a file-backed manager: preparation already reads and merges global, plugin, and project settings before creating the attempt-local manager.

User Impact

No intended user-visible change or operator action. Prepared settings, per-attempt defaults and runtime overrides keep their existing precedence; persisted settings and their actual storage owner remain unchanged.

Why This Change Was Made

Keep settings and runtime overrides directly in memory and apply setters synchronously. Delete the unreachable file-backed manager factories, write tail, persistence merge/error tracking, flush/reload methods, and orphan in-memory storage. Remove the redundant settings reload from extension reload; real extension/resource/model reload and queue-mode resynchronization remain.

Actual FileSettingsStorage reads, locking, atomic replacement, permissions and stored Settings shapes are unchanged. Retired-key, malformed-file and read-error coverage moves to the actual preparation/read boundaries. Prepared snapshot isolation/invalidation, override precedence, provider retry, explicit transport and model/default publication remain protected.

This is a focused widely-imported owner/agents-area slice, below the campaign's usual size floor to keep CI attribution narrow. No Plugin SDK export, config, protocol, schema, durability, retention, permission, dependency or Phase E session-memory change.

Best-effort tradeoffs accepted

  • Unsupported private-source callers lose the file-backed SettingsManager factories and its persistence/flush/error/reload methods. Both in-tree production factories use inMemory; the public SDK selects neither this manager nor the private session factory. refactor: internalize OpenClaw agent runtime #85341 internalized this runtime; refactor(agents): retire unused private session layers #177664 conservatively preserved these paths, not as a human-reported incident or an activation foundation. Actual file storage remains at its existing owner.
  • Attempt-local defaults no longer take a detour through a queued JSON string map, reload that map, or clone a getter result. Current callers only read the prepared base record and setters own top-level/nested records. File edits still enter through the existing next-session or explicit-invalidation boundary; no live file refresh was possible through the removed in-memory reload.

Evidence

Net production delta: +22/-209, 187 lines removed, across five production files; tests/support +145/-303, 158 lines removed. Fifteen source/test paths plus one shrink-only assertion-baseline correction (16 paths total).

Source/caller/provenance inspection, author simplification and test audit complete. Independent isolated Codex review was scoped-clean at P0–P2 (confidence .96); final source verified. Subsequent edits only collapsed identical subprocess arguments, restored whitespace and made an orphan storage interface private, deriving its fixture type from the actual reader.

Serial isolated focused proof: 264 distinct behavioral cases across 15 files pass, covering settings/preparation/storage, explicit transport/provider retry, real extension reload/queue resynchronization, model admission/default publication/notifications, prompt-prefix stability and attempt/context-engine/abort consumers. 17 suppression/wrapper audits pass. Runtime cycles 0; Madge cycles 0. Targeted production and test typechecks, actual touched-file typed lint, formatting, staged line-cap ratchet and changed-check dry-run pass; final production/test types took 22.4/21.9 seconds and final typed lint 54.3 seconds.

All test state used task-owned HOME/OpenClaw/XDG directories, nice 10 and one worker, with heavy commands serialized. No full local build, E2E, broad check-changed or whole-graph typecheck.

Initial exact-head CI39370778575 correctly caught an authored baseline omission: settings-manager now has three grandfathered type assertions rather than eight. Its assertion-safety ratchet job118458331649 failed; correction84a85d40dcc97 reduces the baseline from eight to three, not expanded or bypassed. Focused assertion-safety validation passes115.9s; all17 suppression/wrapper audits pass89.6s. Runtime implementation and its independent review are unchanged.

Final exact-head CI39371962311 succeeded on84a85d40dcc9705b2b261e527f26b43fd069c3dd. Both actual extension typed-lint stripes118462419895 and118462419817 passed on this final head. Complete127-check inventory has no failed or nonterminal check; the one cancelled metadata context is superseded by its successful same-head context, not missing suite proof. No CI rerun or green-only push.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 20, 2026 04:40
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 20, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T04:42:40.757200Z 92c08bd Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR stores attempt-local settings directly in memory and removes unused persistence, reload, and storage paths.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is coherent and has no actionable finding; confidence rests on source review, behavioral tests, and passing exact-head CI rather than a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal refactor is outside the ordinary contributor-proof gate; supplied evidence covers settings and consumer tests plus exact-head CI, with no claimed live product run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: The maintainer-approved direction removes unreachable private persistence behavior and repeated serialization without changing supported settings behavior.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: the maintainer-approved simplification removes unused private machinery while preserving production settings ownership, precedence, and reload behavior; no actionable defect was found.

Priority: P3
Reviewed head: 84a85d40dcc9705b2b261e527f26b43fd069c3dd

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped-entry-point run was supplied; validation covers settings owners, affected consumers, and exact-head CI.
Agent review details

How this fits together

Settings preparation reads and merges global, plugin, and project inputs; the attempt-local manager layers runtime overrides and supplies settings to agent sessions and provider requests.

flowchart TD
  A[Stored settings] --> B[Settings preparation]
  C[Plugin settings] --> B
  B --> D[Attempt settings manager]
  E[Runtime overrides] --> D
  D --> F[Agent session]
  F --> G[Provider requests]
Loading

Technical review

Best possible solution:

Keep the existing preparation and file-storage owners while using synchronous attempt-local settings with runtime overrides applied last.

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

This refactor claims no user-visible bug; source inspection confirms the redundant serialization and persistence machinery on the existing in-memory construction path.

Is this the best way to solve the issue?

The change is a focused simplification using existing owners, with no replacement abstraction, competing state owner, or public SDK expansion.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 08d20d2856f5.

Provenance checked

  • Private settings factories, persistence, and getter snapshots changes intended behavior with a stated reason (refactor: centralize agent session settings state #117868: Centralize scope loading and persistence while preserving the existing method set; the later private-surface cleanup conservatively retained these paths.)
  • Runtime override precedence keeps the original intent (1f75418: Prevent local setter writes and reloads from discarding configured compaction overrides.)
  • Explicit transport precedence keeps the original intent (e28b516: Restore implicit automatic transport only when session settings do not explicitly pin transport, as described in fix(slack): trim DM reply overhead and restore Codex auto transport #53957.)
  • Extension reload changes intended behavior with a stated reason (b9a837e: Split session responsibilities while retaining settings reload; this PR explains why reloading the attempt's in-memory backing store supplied no live file refresh.)
  • File-storage read and write contracts keeps the original intent (707d3f4: Separate settings storage from the manager; this PR preserves the actual reader, locking, atomic writes, and stored settings shape.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f746a65 adds src/agents/sessions/settings-manager.ts:451 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f746a653139d; files: src/agents/sessions/settings-manager.ts)
  • Sergio Cadavid: Raw commit 1f75418 adds src/agents/sessions/settings-manager.ts:255 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1f754189b4e7; files: src/agents/sessions/settings-manager.ts)
  • Vincent Koc: Raw commit f6f939a adds src/agents/sessions/settings-storage.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f6f939a8ebc6; files: src/agents/sessions/settings-storage.ts)

PR surface

Source -187, Tests -158, Other 0. Total -345 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 22 209 -187
Tests 10 146 304 -158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 16 169 514 -345

Review metrics

Metric Value Why it matters
Production versus test changes Production +22/-209; tests and support +146/-304 The reduction removes unused persistence machinery and its obsolete fixtures while retaining preparation, storage, and override contracts.

Labels

Label changes:

  • add P3: This is a behavior-preserving internal cleanup with no reported user-facing failure or operator action.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a behavior-preserving internal cleanup with no reported user-facing failure or operator action.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 1:25 AM ET / 05:25 UTC.

@steipete
steipete merged commit cbdfdfa into main Oct 20, 2026
161 of 162 checks passed
@steipete
steipete deleted the deslop/z34-29-in-memory-settings-20261015 branch October 20, 2026 06:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 20, 2026
Read prepared global and project settings directly through their existing parser and paths. Remove the private single-implementation backend, unused writer, read locks, and writer-only fixtures after #178049 retired production persistence.

Keep ENOENT-only absence handling, native filesystem errors, trust/sanitization, refresh boundaries, and user file bytes. Old/private writers or overlapping external edits may produce an old/empty/error snapshot until fresh preparation; this best-effort read never writes user settings.

Targeted types, ordinary typed lint, formatting, caps, zero runtime/static cycles, independent review, and exact-head CI 39423745313 passed. Local runtime gaps and unrun opt-in Gateway/upgrade proof are disclosed. The generic automated proof hold is advisory; review identified no code finding.

PR #178407; 73 net production and 398 fixture/support lines removed. Standalone session memory is unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…178049)

* refactor(agents): keep attempt settings directly in memory

* chore(agents): shrink settings assertion baseline
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
Read prepared global and project settings directly through their existing parser and paths. Remove the private single-implementation backend, unused writer, read locks, and writer-only fixtures after openclaw#178049 retired production persistence.

Keep ENOENT-only absence handling, native filesystem errors, trust/sanitization, refresh boundaries, and user file bytes. Old/private writers or overlapping external edits may produce an old/empty/error snapshot until fresh preparation; this best-effort read never writes user settings.

Targeted types, ordinary typed lint, formatting, caps, zero runtime/static cycles, independent review, and exact-head CI 39423745313 passed. Local runtime gaps and unrun opt-in Gateway/upgrade proof are disclosed. The generic automated proof hold is advisory; review identified no code finding.

PR openclaw#178407; 73 net production and 398 fixture/support lines removed. Standalone session memory is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

1 participant