Repository navigation
fix(sessions): preserve active turns during session compaction - #110389
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a0ad677a6
ℹ️ 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".
| blockedByActiveRun = | ||
| isCompetingSessionWorkAdmissionActive(storePath, lifecycleIdentities) || | ||
| hasVisibleActiveSessionRun({ | ||
| context, | ||
| requestedKey: key, | ||
| canonicalKey: target.canonicalKey, | ||
| sessionId, | ||
| agentId: requestedAgentId, | ||
| defaultAgentId: resolveDefaultAgentId(cfg), | ||
| }); |
There was a problem hiding this comment.
Include worker inferences in active-run guard
When a cloud-worker turn is active only in context.workerEnvironmentService (hasInferenceForSession(sessionId) true) and has not produced a visible/projected run context, this new guard leaves blockedByActiveRun false and the RPC proceeds to trim or compact the transcript. The removed interruptSessionRunIfActive() path explicitly checked asWorkerInferenceControl(...).hasInferenceForSession, and the worker inference manager keeps those active sessions in its own map, so this misses a real active-run source and can mutate the session while the worker is still streaming/appending.
Useful? React with 👍 / 👎.
0a21937 to
927fc84
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 12:48 AM ET / 04:48 UTC. Summary PR surface: Source +143, Tests +8. Total +151 across 7 files. Reproducibility: yes. from source: a cloud-worker inference that has not yet created a visible/projected run context bypasses the new guard and can reach transcript mutation. The supplied material does not include an inspectable live after-fix reproduction. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Use one canonical active-work predicate that includes visible runs, lifecycle admissions, and worker inference ownership before any transcript mutation, add a worker-only regression test, then attach redacted live Gateway evidence for the no-op and refusal paths. Do we have a high-confidence way to reproduce the issue? Yes, from source: a cloud-worker inference that has not yet created a visible/projected run context bypasses the new guard and can reach transcript mutation. The supplied material does not include an inspectable live after-fix reproduction. Is this the best way to solve the issue? No. Preflight-before-mutation is the right boundary, but the active-work check must also cover worker inference ownership; otherwise the proposed safety guarantee is incomplete. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4e0cc187a21c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +143, Tests +8. Total +151 across 7 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (1 earlier review cycle)
|
927fc84 to
9723183
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9723183683
ℹ️ 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".
| return ( | ||
| (!persistedRuntime || persistedRuntime === "openclaw") && | ||
| (!contextEngine || contextEngine === "legacy") |
There was a problem hiding this comment.
Honor configured runtime policy before preflight
When an unlocked session relies on provider/model agentRuntime policy instead of a persisted entry.agentHarnessId, persistedRuntime is undefined, so this treats the session as legacy OpenClaw whenever the context engine is default/legacy. The caller can then return the OpenClaw preflight no-op (Nothing to compact/Already compacted) before compactEmbeddedAgentSession runs, bypassing the configured native/owner runtime that the compaction path resolves from policy. Please either resolve the same configured harness policy here or only run this preflight when the runtime is known to be OpenClaw.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
What Problem This Solves
sessions compacton a session with an in-flight agent turn killed the live turn (status:"timeout", stopReason:"restart", timeoutPhase:"gateway_draining") — even when compaction then decided there was nothing to do (ok:false, "Nothing to compact (session too small)"). The user's live run was aborted for a compaction that never happened.Why This Change Was Made
Found by the R5 QA campaign (2× live repro): the lifecycle-mutation prepare step drained queues and interrupted session work admissions (
src/gateway/server-methods/sessions-compact.ts) before the no-op verdict was computed much later insrc/agents/sessions/agent-session-compaction.ts.User Impact
INVALID_REQUESTerror instead of silently killing the run — consistent withsessions cleanuppreserving active sessions and archive refusing active mutation. No--forceadded.Evidence
src/agents/sessions/manual-compaction-preflight.ts, wired atsrc/gateway/server-methods/sessions-compaction-runner.ts:54and before queue clearing atsessions-compact.ts:198; active-work guard atsessions-compact.ts:212,:261; competing-admission detection atsrc/sessions/session-lifecycle-admission.ts:330.node scripts/check-changed.mjsgreen (types/lint/format/guards).