fix(agents): sync stale this.model snapshot after /model switch#93056
fix(agents): sync stale this.model snapshot after /model switch#93056samson910022 wants to merge 6 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 2:44 PM ET / 18:44 UTC. Summary PR surface: Source +116, Tests +718. Total +834 across 10 files. Reproducibility: yes. from source inspection, but not from a live run in this read-only review; current main can persist model switches while AgentSession prompt/status reads keep using the in-memory Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Remove the duplicate import, then land this or a narrow replacement only after redacted CLI/daemon or Telegram proof shows explicit and default Do we have a high-confidence way to reproduce the issue? Yes from source inspection, but not from a live run in this read-only review; current main can persist model switches while AgentSession prompt/status reads keep using the in-memory Is this the best way to solve the issue? No, not mergeable yet; the implementation direction is plausible and bounded, but the duplicate import and missing real behavior proof must be cleared first. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3f380635f59b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +116, Tests +718. Total +834 across 10 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 (9 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Updated the stale-model fix to use the canonical session store path, sync before prompt/status reads, mark Telegram Verification:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
b366df6 to
0060de4
Compare
|
@clawsweeper re-review Rebased onto current Verification:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
AgentSession.this.model can become stale when /model command writes to the session store but the in-memory AgentSession never re-reads it. Only the prompt() entry point — used by TUI interactive and plugin SDK long-lived sessions — needs the fix; the embedded runner creates a fresh AgentSession per run so it was already safe. Add syncModelFromStoreEntry() called at the start of prompt() before model validation. It guard-chains: store access → liveModelSwitchPending flag → valid provider+id → registry lookup → auth configured → direct assignment + appendModelChange() + setThinkingLevel(). A model-already-matches guard prevents repeated transcript entries. Closes openclaw#92415 PR openclaw#92424 (replaced)
Remove dead code (4 unused helper functions), unused imports, fix ResourceLoader mock return types, use correct AuthCredential shape, and add curly braces to satisfy oxlint. check-lint: 16 errors -> 0 check-test-types: 15 errors -> 0
…tion The syncModelFromStoreEntry() fix added in this PR was dead code in production because no caller of createAgentSession() passed storePath or sessionKey. Both are already available in the embedded runner params (sessionFile = store path, sessionKey = session key) but were never forwarded to the AgentSession constructor. Add storePath/sessionKey to EmbeddedAgentSessionOptions bridge type and pass them from attempt.ts and compact.ts call sites. This makes the model-override sync actually activate on production TUI/plugin SDK paths where the session store contains pending liveModelSwitchPending state.
- Remove empty test (covered by real test) - Add afterEach with vi.restoreAllMocks() for centralized spy cleanup - Remove all individual mockRestore() calls (now handled by afterEach) - Remove unused findSpy/authSpy variable assignments - Add model-already-matches guard test (critical missing coverage) - Add modelOverride missing guard test (guard 4b)
0060de4 to
211df63
Compare
|
@clawsweeper re-review Rebased onto latest upstream/main and fixed the check-test-types failure by widening the resource-loader mock-call type from Verification:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
AgentSession.this.modelsnapshot after a session-level/modelswitch./modelwrites as pending so the session can resync on the next read.Linked Context
Closes #92415
Related #92388
Related #92424
Related #95353
Evidence
node scripts/run-vitest.mjs src/agents/sessions/agent-session.model-sync.test.tsnode scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.spawn-workspace.resource-loader.test.tsnode scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.tsTests and Validation
getSessionStats()/ context usage reads.storePathandsessionKey.ModelRegistryauth-backed path without mockinghasConfiguredAuth().Risk Checklist
Current Review State