Skip to content

fix(sessions): prune stale gateway model-run sessions - #91057

Merged
jalehman merged 10 commits into
openclaw:mainfrom
wangwllu:fix/88632-model-run-ttl
Jun 24, 2026
Merged

jalehman merged 10 commits into
openclaw:mainfrom
wangwllu:fix/88632-model-run-ttl

Conversation

@wangwllu

@wangwllu wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Prunes stale gateway model-run probe sessions (agent:*:explicit:model-run-<uuid>) before they can contribute to session cap pressure and evict durable sessions (#88632).

The cleanup is intentionally not exposed as a new openclaw.json option. OpenClaw applies a fixed 24h model-run probe retention only when session-entry maintenance/cap pressure is reached. Healthy stores are left untouched, and strict key matching keeps normal direct, group, thread, cron, hook, heartbeat, ACP, and sub-agent sessions out of this cleanup path.

modelRunPruned / prune-model-run are reported separately in cleanup summaries and dry-run plans.

Fixes #88632

Real behavior proof

Behavior addressed: stale gateway model-run-<uuid> probe sessions are pruned before the maxEntries cap can evict durable sessions, while healthy stores below cap pressure are left untouched.

Real environment tested: local macOS worktree at head 5d9a14ec360 (josh/review-pr-91057-thermonuclear), using the real pnpm openclaw sessions cleanup CLI after the worktree runtime build, with isolated OPENCLAW_CONFIG_PATH values and temp session stores under /tmp/openclaw-91057-proof.LB3erh.

Exact steps or command run after this patch:

# Build/verify the real CLI entrypoint and cleanup options.
pnpm openclaw sessions cleanup --help

# Scenario A: no cap pressure. Config uses maxEntries: 500.
OPENCLAW_CONFIG_PATH=/tmp/openclaw-91057-proof.LB3erh/config-no-pressure.json \
  pnpm openclaw sessions cleanup --dry-run --enforce --json \
  --store /tmp/openclaw-91057-proof.LB3erh/store-no-pressure.json

# Scenario B: cap pressure. Config uses maxEntries: 2.
OPENCLAW_CONFIG_PATH=/tmp/openclaw-91057-proof.LB3erh/config-pressure.json \
  pnpm openclaw sessions cleanup --dry-run --enforce --json \
  --store /tmp/openclaw-91057-proof.LB3erh/store-pressure.json

# Scenario C: same pressure store, text dry-run to verify the visible action table.
OPENCLAW_CONFIG_PATH=/tmp/openclaw-91057-proof.LB3erh/config-pressure.json \
  pnpm openclaw sessions cleanup --dry-run --enforce \
  --store /tmp/openclaw-91057-proof.LB3erh/store-pressure-text.json

# Scenario D: apply the pressure cleanup.
OPENCLAW_CONFIG_PATH=/tmp/openclaw-91057-proof.LB3erh/config-pressure.json \
  pnpm openclaw sessions cleanup --enforce --json \
  --store /tmp/openclaw-91057-proof.LB3erh/store-pressure.json

# Scenario E: prove the removed public config key is not accepted.
OPENCLAW_CONFIG_PATH=/tmp/openclaw-91057-proof.LB3erh/config-invalid-public-key.json \
  pnpm openclaw sessions cleanup --dry-run --enforce --json \
  --store /tmp/openclaw-91057-proof.LB3erh/store-pressure-text.json

Evidence after fix: the fixture stores contained one stale strict model-run probe (agent:main:explicit:model-run-123e4567-e89b-12d3-a456-426614174100, updated 2 days ago), one recent strict model-run probe (...174101, updated now), and one durable thread session (agent:main:discord:channel:123456:thread:987654, updated 2 days ago).

No-pressure dry-run result:

{
  "beforeCount": 3,
  "afterCount": 3,
  "modelRunPruned": 0,
  "capped": 0,
  "wouldMutate": false,
  "staleStillPresent": true
}

Pressure dry-run result:

{
  "beforeCount": 3,
  "afterCount": 2,
  "modelRunPruned": 1,
  "capped": 0,
  "wouldMutate": true
}

Text dry-run showed the visible cleanup action:

Planned session actions:
Action           Key                        Age       Model          Flags
keep             agent:main:expli...174101  1m ago    gpt-5.5        id:recent-model-run
prune-model-run  agent:main:expli...174100  2d ago    gpt-5.5        id:stale-model-run
keep             agent:main:disco...987654  2d ago    gpt-5.5        id:normal-durable-thread

Apply result:

{
  "beforeCount": 3,
  "afterCount": 2,
  "modelRunPruned": 1,
  "capped": 0,
  "applied": true,
  "staleRemoved": true,
  "recentModelRunPresent": true,
  "durableThreadPresent": true
}

Removed-config proof:

invalid_config_status=1
OpenClaw config is invalid
File: /tmp/openclaw-91057-proof.LB3erh/config-invalid-public-key.json
Problem:
  - session.maintenance: Invalid input

Observed result after fix: model-run cleanup is pressure-gated under the fixed 24h policy, removes the stale probe before capping, reports modelRunPruned / prune-model-run, preserves recent model-run and durable thread sessions, and rejects the removed public session.maintenance.modelRunPruneAfter key.

What was not tested: no live remote model/provider call was required because this PR changes session-store cleanup behavior, not model execution or transport delivery. The future SQLite storage flip was not tested here; this proof exercises the current file-backed store and real cleanup CLI path.

Testing

  • node scripts/run-vitest.mjs src/plugin-sdk/session-store-runtime.test.ts src/config/sessions/store.pruning.test.ts src/config/sessions/store.pruning.integration.test.ts src/commands/sessions-cleanup.test.ts
  • pnpm tsgo:core:test
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base aa0bdb901f4a166bd9652b5b4e397febd3fce91f
  • git diff --check HEAD
  • Real behavior proof commands listed above.

Current status (2026-06-24)

Maintainer follow-up removed the proposed public config option, closed the internal resolved maintenance type back up, and restored plugin-facing source compatibility for old-shape maintenanceConfig callers via a normalized input type. The PR now implements only the automatic fixed-policy cleanup and the CLI/reporting proof needed for #88632. maintainerCanModify is enabled, and the PR branch has been updated to head 5d9a14ec360.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 7, 2026
@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 4:35 PM ET / 20:35 UTC.

Summary
The PR adds pressure-gated 24h cleanup/reporting for strict gateway model-run session rows, updates the sessions cleanup CLI/docs, and adapts plugin/runtime maintenance-config compatibility types.

PR surface: Source +200, Tests +365, Docs +16. Total +581 across 19 files.

Reproducibility: yes. Source inspection shows current main creates agent-scoped explicit model-run session rows while current and latest-release maintenance only apply global prune/cap retention, and the linked issue provides production counts showing those rows saturating the cap.

Review metrics: 3 noteworthy metrics.

  • Default cleanup deletion path: 1 added. The PR adds automatic deletion of stale strict model-run probe rows under cap pressure, which maintainers must accept before merge.
  • Public session config options: 0 added, 0 changed, 0 removed. The latest head keeps model-run retention as fixed internal policy rather than expanding openclaw.json.
  • Plugin maintenance config adapters: 2 changed. Both the public plugin SDK wrapper and plugin runtime facade normalize old-shape maintenance configs, so plugin compatibility is part of the review surface.

Stored data model
Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-workspace-status.test.ts, serialized state: src/commands/sessions-cleanup.test.ts, serialized state: src/commands/sessions-cleanup.ts, serialized state: src/config/sessions/cleanup-service.ts, serialized state: src/config/sessions/runtime-types.ts, serialized state: src/config/sessions/store-load.ts, and 13 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #88632
Summary: This PR is the open candidate fix for the canonical gateway model-run session accumulation issue; broader session-retention requests overlap but do not replace this specific fix.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Record maintainer acceptance of the pressure-gated deletion contract for strict stale model-run probe rows.

Risk before merge

  • [P1] Merging intentionally makes stale strict agent-scoped model-run probe rows disposable under session-entry cap pressure by default, so maintainers need to accept that upgrade behavior.
  • [P1] The patch changes the resolved maintenance-config shape crossing plugin SDK/runtime seams; the latest head adds normalization and regression coverage, but the surface remains compatibility-sensitive.

Maintainer options:

  1. Accept pressure-gated probe cleanup (recommended)
    Maintainers can accept stale strict model-run probe rows as disposable when they would otherwise contribute to cap pressure, then proceed through normal merge gates.
  2. Make deletion non-default
    If upgrade-time deletion is not acceptable, change the PR so default cleanup does not remove probe rows without an explicit maintainer-approved mode or command path.
  3. Replace with non-persistence
    If model-run probes should never be normal session rows, pause this PR and replace it with a non-persistence or separate-history design that also handles already-polluted stores.

Next step before merge

  • [P2] The remaining action is maintainer acceptance of the pressure-gated default session cleanup contract and normal merge readiness; no narrow automated repair remains.

Security
Cleared: No workflow, dependency, package, secret, auth, or external code-execution surface changes were found; destructive cleanup behavior is tracked as session-state merge risk.

Review details

Best possible solution:

Land this or an equivalent core session-lifecycle fix after maintainers explicitly accept pressure-gated cleanup of stale strict model-run probe rows and normal merge gates pass.

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

Yes. Source inspection shows current main creates agent-scoped explicit model-run session rows while current and latest-release maintenance only apply global prune/cap retention, and the linked issue provides production counts showing those rows saturating the cap.

Is this the best way to solve the issue?

Yes, pending maintainer acceptance. Session maintenance is the right owner because it repairs already-polluted stores, keeps matching strict to generated model-run UUID keys, avoids a new public config option, and preserves old-shape plugin maintenance-config callers.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority session maintenance bug fix with production evidence and bounded blast radius.
  • merge-risk: 🚨 compatibility: The PR changes upgrade behavior by allowing automatic deletion of persisted model-run probe session rows under cap pressure.
  • merge-risk: 🚨 session-state: The diff deliberately removes matching session-store rows and associated artifacts from persisted session state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output from the real sessions cleanup CLI for no-pressure, pressure dry-run, text dry-run, apply, and rejected removed-config scenarios.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output from the real sessions cleanup CLI for no-pressure, pressure dry-run, text dry-run, apply, and rejected removed-config scenarios.
Evidence reviewed

PR surface:

Source +200, Tests +365, Docs +16. Total +581 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 10 211 11 +200
Tests 5 370 5 +365
Docs 4 17 1 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 598 17 +581

What I checked:

  • Repository policy applied: Root AGENTS.md and relevant scoped docs/plugin guidance were read; session-state, config/default, and plugin SDK/runtime seam changes require conservative compatibility review. (AGENTS.md:1, d23977edbcf9)
  • Current main creates persisted model-run session keys: The current gateway model-run CLI path builds a model-run UUID session id, derives an explicit session key, and sends it through the Gateway agent call with modelRun enabled. (src/cli/capability-cli.ts:816, d23977edbcf9)
  • Current main has only global session retention: Current session maintenance resolves global prune/cap settings and has no model-run-specific prune function or report field. (src/config/sessions/store-maintenance.ts:21, d23977edbcf9)
  • Latest release lacks the fix: Tag v2026.6.10 still creates model-run session ids while its store-maintenance source has no model-run cleanup symbols. (src/config/sessions/store-maintenance.ts:21, aa69b12d0086)
  • PR adds strict pressure-gated model-run cleanup: The PR adds fixed 24h model-run retention, pressure-gates it against the cap trigger, and matches only canonical agent-scoped explicit model-run UUID keys. (src/config/sessions/store-maintenance.ts:191, 5efccbbc256d)
  • PR wires cleanup preview/apply reporting: The cleanup service now records modelRunPruned keys and reports modelRunPruned in preview and applied summaries. (src/config/sessions/cleanup-service.ts:370, 5efccbbc256d)

Likely related people:

  • Kaspre: Authored the merged gateway model-run isolation work that creates explicit model-run UUID session ids and keys. (role: introduced behavior; confidence: high; commits: 2a01cc641ec8, e4ec1b3de8af; files: src/cli/capability-cli.ts, src/cli/capability-cli.test.ts)
  • jalehman: Authored the merged session maintenance transaction seam and the latest compatibility-oriented commits on this PR branch. (role: recent session lifecycle contributor; confidence: high; commits: acafa74d72e5, 5508486d6618, 5efccbbc256d; files: src/config/sessions/store-maintenance-operations.ts, src/config/sessions/store-maintenance.ts, src/plugin-sdk/session-store-runtime.ts)
  • gumadeiras: Authored the earlier global session maintenance prune/cap feature that owns the baseline retention behavior extended here. (role: session maintenance feature contributor; confidence: medium; commits: e19a23520c2d; files: src/config/sessions/store.ts, src/config/sessions/store-maintenance.ts, src/config/types.base.ts)
  • steipete: Committed or merged adjacent model-run and session-maintenance work around the relevant CLI and retention surfaces. (role: feature merger and adjacent contributor; confidence: medium; commits: e4ec1b3de8af, 7eda63232497; files: src/cli/capability-cli.ts, src/config/sessions/store-maintenance.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 7, 2026
@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR body with structured real-behavior proof fields (, , , , , ). I also validated the body locally against ; it now passes the proof policy for the current head.

@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR body with structured real-behavior proof fields: behavior, environment, steps, evidence, observedResult, and notTested.

I also validated the body locally against scripts/github/real-behavior-proof-policy.mjs; evaluateRealBehaviorProof now passes for the current head.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 7, 2026
@wangwllu
wangwllu force-pushed the fix/88632-model-run-ttl branch from 8413871 to fc22cc1 Compare June 7, 2026 02:14
@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest upstream/main and updated the structured real-behavior proof for the new head.

Local checks after rebase:

  • pnpm tsgo:core:test
  • runtime-config focused tests: 84 passed
  • sessions-cleanup command tests: 6 passed
  • touched-file oxfmt check
  • node scripts/build-all.mjs cliStartup
  • real built CLI proof: dry-run/enforce both reported modelRunPruned: 1 and retained the recent model-run plus durable control session
  • local proof-policy evaluation passed for the PR body

@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 7, 2026
@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the remaining ClawSweeper docs finding by documenting session.maintenance.modelRunPruneAfter in public session maintenance and cleanup docs.

Docs checks:

  • pnpm format:docs:check docs/cli/sessions.md docs/concepts/session.md docs/reference/session-management-compaction.md docs/gateway/config-agents.md
  • pnpm docs:check-mdx
  • pnpm lint:docs -- docs/cli/sessions.md docs/concepts/session.md docs/reference/session-management-compaction.md docs/gateway/config-agents.md

@wangwllu

wangwllu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Jun 7, 2026
@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Jun 7, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 22, 2026
@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@wangwllu

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@wangwllu

Copy link
Copy Markdown
Contributor Author

@jalehman — apologies for the direct ping; this builds on the session-maintenance transaction seam you added in #93737. ClawSweeper currently has it as ready for maintainer look with green CI, and maintainerCanModify is on. If you're not the right person for this, I'm happy to be redirected.

As far as I can tell, the remaining question is the product/default-behavior call: stale strict agent:*:explicit:model-run-<uuid> probe rows are pruned only when they would otherwise contribute to maxEntries cap pressure — unset = pressure-gated 24h, explicit duration = unconditional, false = off. This is intended to address #88632's accumulate-to-cap failure without eagerly mutating healthy stores on upgrade. The two 🚨 merge-risk labels appear to be the relevant auto-flags for that default-behavior decision.

Happy to switch this to default-off if you'd prefer. No rush.

@jalehman

Copy link
Copy Markdown
Contributor

@jalehman — apologies for the direct ping;

All good! This is something I'd like to be pinged about. Will review and incorporate today.

wanglu241 and others added 9 commits June 24, 2026 13:14
The model-run prune predicate fell back to testing the raw sessionKey
when parseAgentSessionKey returned null, so unscoped keys like
`explicit:model-run-<uuid>` and shapes with empty agent ids were
eligible for the new default 24h cleanup. Restrict matching to keys
that successfully parse as agent-scoped with a non-empty agent id,
and add negative tests covering unscoped, empty-agent, extra-segment,
and whitespace-padded keys.

Refs openclaw#88632 (review feedback before merge).
Forced maintenance (sessions cleanup / maintenanceOverride) caps immediately to
maxEntries, but the unset model-run default was high-water gated. In the
(maxEntries, high-water) window stale model-run probes survived while the forced
cap evicted real sessions — the inverse of openclaw#88632. shouldRunModelRunPrune now
takes a force flag: when the caller caps immediately, the unset default prunes
once entryCount > maxEntries. Wire force at the two forced call sites
(applyEnforcedMaintenance, previewStoreCleanup). Make the SDK runtime config
field modelRunPruneAfterConfigured optional (additive). Add force-gate unit
test + forced-apply regression test.
The model-run maintenance fields (modelRunPruneAfterMs from openclaw#88632 base work,
modelRunPruneAfterConfigured from the pressure-gating fix) were required on the
resolved maintenance config exposed to plugins via patchSessionEntry's
maintenanceConfig. External plugin TypeScript callers that construct a
pre-openclaw#88632 maintenanceConfig would fail to compile.

Make both fields optional on ResolvedSessionMaintenanceConfig (and the runtime
type), so old-shape plugin configs keep compiling. All internal readers already
treat an absent value as unset: shouldRunModelRunPrune returns false when
modelRunPruneAfterMs == null and modelRunPruneAfterConfigured is falsy, so a
plugin-supplied config without the fields runs no model-run pruning — the
pre-openclaw#88632 behavior. The resolver still always populates both fields, so normal
runtime behavior is unchanged. Add an old-shape maintenanceConfig SDK
regression test.
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 5efccbbc256ded2995fcfe6005c9173975bf7e3d

@jalehman

Copy link
Copy Markdown
Contributor

Merged via rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

[Bug]: gateway model-run sessions accumulate until session maxEntries cap

2 participants