Skip to content

fix(compaction): compact with the model a session inherits from its parent - #204755

Merged
jalehman merged 3 commits into
mainfrom
openclaw/investigating-a-compaction-error-fe7b55
Nov 24, 2026
Merged

jalehman merged 3 commits into
mainfrom
openclaw/investigating-a-compaction-error-fe7b55

Conversation

@jalehman

Copy link
Copy Markdown
Contributor

What

Manual compaction (sessions.compact) now chooses its model the same way ordinary turns and the Control UI do, including a model inherited from a parent session. Preflight and execution share that one selection.

Why

A dashboard child session inherited anthropic/claude-opus-5-5 from its parent and carried the matching personal anthropic:manual auth pin. Chat turns used the inherited model. Manual compaction used resolveSessionModelRef, which ignores parent inheritance, so it fell back to the configured default (clawrouter/anthropic/claude-opus-5-5). It then combined that model with the session's Anthropic pin, and every /compact failed with:

Auth profile "anthropic:manual" is not compatible with the resolved model endpoint for "clawrouter". Select a compatible provider profile.

The auth check was correct. The bug was that compaction built a model/credential pair the session never uses.

Changes

  • Compaction model selection uses resolveSessionSelectedModelRefAsync
  • Parent entry is prepared via prepareGatewaySessionEntryReader, which honors configured stores
  • Preflight (usesLegacyRuntime) and execution share one selection
  • Regression test for a child that inherits its parent's model

Review findings addressed:

  • Cross-agent parent reads now use the reader that respects configured stores.
  • Preflight could select a different model than execution, which could skip native compaction. Both now use the same selection.

Related issue, not fixed here: subagent-announce turns on the same session still resolve the configured default (ClawRouter), while human turns use the inherited Anthropic model. Each switch rewrites the whole prompt cache.

Testing

  • pnpm test src/gateway/server.sessions.compaction-model.test.ts: fails on base (compaction got the config default anthropic), passes with the fix
  • Compaction suites (compaction, -model, -preemption, -accounting, -read-errors, chat-send-compaction-handoff): 38/38 passed
  • pnpm check:changed passed. The dead-export scan was skipped; it fails on main because of unrelated beam exports.
  • Not yet re-run on a live gateway; the affected production session will be retried after deploy

🦞 Made with OpenClaw

@clawsweeper

clawsweeper Bot commented Nov 24, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Manual compaction uses the existing inherited-model selector for both preflight and execution.

Example: agent:main:dashboard:child inherits openai/gpt-5.4 and retains the openai:personal auth pin.

  • Before: Compaction selects the configured anthropic provider while retaining the incompatible OpenAI pin.
  • After: Compaction selects openai/gpt-5.4 and retains openai:personal.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified introduced defect, but mocked compaction does not satisfy the required real-behavior proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Manual compaction can reject a child session's valid auth pin because it selects a different provider from ordinary turns.
Reason: The repair aligns compaction with an existing session-selection contract and stays within the maintainer-authorized direction.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still ignores parent model inheritance during manual compaction, and this PR provides a focused repair with no introduced correctness defect found.

Priority: P2
Reviewed head: 5772ec38b36d9d5cc5403f922e254ca8f80e0bce

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted live Gateway output showing successful sessions.compact with the inherited model and matching pin on fresh state and after an upgrade from the latest stable release, with existing selections preserved.
Agent review details

How this fits together

The Gateway sessions.compact handler prepares the session, selects its model and runtime, and passes the selected model and existing auth pin to the compaction engine.

flowchart TD
  A[Manual compaction request] --> B[Gateway session lifecycle]
  B --> C[Prepared parent lineage]
  C --> D[Existing model selector]
  D --> E[Runtime preflight and execution]
  E --> F[Compaction engine]
Loading

Technical review

Best possible solution:

Retain this focused reuse of the existing inheritance and model-selection owners while preserving auth compatibility checks and runtime ownership.

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

The source establishes the mismatch: current-main compaction ignores the parent selection but forwards the child's auth pin; the author also reports a regression that fails on base and passes on the PR, which this read-only review did not execute.

Is this the best way to solve the issue?

The patch is the smallest complete repair identified: reuse the existing parent reader and selected-model resolver through one helper called by both compaction phases, without introducing parallel policy or persistent state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1f4079a13ed5.

Provenance checked

  • Compaction model resolution changes intended behavior with a stated reason (refactor(gateway): split session handlers #107677: The earlier change extracted the compaction request builder while preserving behavior; it does not establish an intentional exclusion of parent inheritance or the original introduction of that exclusion.)
  • Preflight runtime classification keeps the original intent (refactor(sessions): reduce database work during manual compaction #175311: Preparation consolidated transcript and accounting work while retaining native/custom-engine paths; applying inherited selection to preflight preserves that runtime distinction for the corrected provider.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit b4fb043 adds src/gateway/server-methods/sessions-compaction-runner.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b4fb0436986d; files: src/gateway/server-methods/sessions-compaction-runner.ts)

PR surface

Source +21, Tests +63. Total +84 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 24 3 +21
Tests 1 63 0 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 87 3 +84

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Manual compaction fails for the specific combination of an inherited provider selection and a matching child auth pin; the repair has a limited scope.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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:

  • P2: Manual compaction fails for the specific combination of an inherited provider selection and a matching child auth pin; the repair has a limited scope.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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 November 24, 2026, 11:35 AM ET / 16:35 UTC.

@jalehman
jalehman merged commit cee9028 into main Nov 24, 2026
128 of 130 checks passed
@jalehman
jalehman deleted the openclaw/investigating-a-compaction-error-fe7b55 branch November 24, 2026 17:27
tideclaw-bot pushed a commit that referenced this pull request Nov 25, 2026
…arent (#204755)

* fix(compaction): compact with the model a session inherits from its parent

* fix(compaction): share inherited model selection across preflight and run

* fix(compaction): compact with the model a session inherits from its parent

OpenClaw-Publication: 85662330-c12e-44aa-8f1f-ceea1f9b7a9d
(cherry picked from commit cee9028)
Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…arent (openclaw#204755)

* fix(compaction): compact with the model a session inherits from its parent

* fix(compaction): share inherited model selection across preflight and run

* fix(compaction): compact with the model a session inherits from its parent

OpenClaw-Publication: 85662330-c12e-44aa-8f1f-ceea1f9b7a9d
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…arent (#204755)

* fix(compaction): compact with the model a session inherits from its parent

* fix(compaction): share inherited model selection across preflight and run

* fix(compaction): compact with the model a session inherits from its parent

OpenClaw-Publication: 85662330-c12e-44aa-8f1f-ceea1f9b7a9d
(cherry picked from commit cee9028)

Companion audit: ec31b90 changes prepared transcript size policy; e52c1a9 and c2d208f are later Claude runtime-key reuse fixes; 966d287 changes Talk consultation runtime admission. Those are distinct from inherited model selection.

Release adaptation: Use the existing inherited selector and lineage reader in both preflight and execution; keep stable persisted runtime and child auth selection.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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