Skip to content

[Bug]: Auto-compaction does not resolve compaction model aliases before dispatch #90340

Closed

Description

@toruvieI

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Auto-compaction in OpenClaw 2026.6.1 does not resolve a configured compaction model alias before dispatch, causing the alias gpt54mini to be sent as openai/gpt54mini and rejected as an unknown model.

Steps to reproduce

  1. Start OpenClaw 2026.6.1 with a model alias and compaction override shaped like this sanitized config:

    {
      "models": {
        "providers": {
          "openai": {
            "api": "openai-chatgpt-responses",
            "agentRuntime": { "id": "pi" }
          }
        }
      },
      "agents": {
        "defaults": {
          "model": {
            "primary": "gpt55",
            "fallbacks": ["gpt54"]
          },
          "models": {
            "openai/gpt-5.5": {
              "alias": "gpt55",
              "agentRuntime": { "id": "pi" }
            },
            "openai/gpt-5.4": {
              "alias": "gpt54",
              "agentRuntime": { "id": "pi" }
            },
            "openai/gpt-5.4-mini": {
              "alias": "gpt54mini",
              "params": { "thinking": "high" },
              "agentRuntime": { "id": "pi" }
            },
            "openai/*": {
              "agentRuntime": { "id": "pi" }
            }
          },
          "compaction": {
            "reserveTokens": 30000,
            "keepRecentTokens": 20000,
            "maxHistoryShare": 0.1,
            "model": "gpt54mini",
            "notifyUser": true
          }
        }
      }
    }
  2. Run a long openai/gpt-5.5 session until embedded auto-compaction is triggered.

  3. Observe the gateway/agent log line shown below.

Expected behavior

The auto-compaction path should resolve agents.defaults.compaction.model = "gpt54mini" through the same model alias resolver used by normal agent model selection, then dispatch compaction to canonical openai/gpt-5.4-mini.

Actual behavior

Auto-compaction dispatches or reports the alias as openai/gpt54mini, which is not a configured model id and is rejected as unknown.

OpenClaw version

2026.6.1

Operating system

macOS 15.x / Darwin 24.x

Install method

npm global, Node.js 24

Model

Primary session model: openai/gpt-5.5

Compaction override: alias gpt54mini for canonical openai/gpt-5.4-mini

Provider / routing chain

OpenClaw -> OpenAI plugin -> ChatGPT Responses runtime (agentRuntime.id = "pi")

Additional provider/model setup details

The alias is defined under agents.defaults.models as:

"openai/gpt-5.4-mini": {
  "alias": "gpt54mini",
  "params": { "thinking": "high" },
  "agentRuntime": { "id": "pi" }
}

Changing only agents.defaults.compaction.model from gpt54mini to canonical openai/gpt-5.4-mini avoids the failure.

Logs, screenshots, and evidence

15:17:24+02:00 warn agent/embedded {"subsystem":"agent/embedded"} auto-compaction failed for openai/gpt-5.5: Unknown model: openai/gpt54mini

Sanitized verification after workaround:

agents.defaults.compaction.model = "openai/gpt-5.4-mini"
config valid: true
issues: []
warnings: []

Impact and severity

  • Affected users/systems/channels: OpenClaw sessions using agents.defaults.compaction.model set to a configured alias instead of a fully-qualified provider/model id.
  • Severity: Medium. Normal chat continues, but auto-compaction fails, so long sessions can lose the intended context-management behavior.
  • Frequency: Observed when auto-compaction runs with the alias override shown above.
  • Consequence: Context compaction does not complete until the config is changed to a canonical model id.

Additional information

This appears to be either:

  1. the embedded auto-compaction path not calling the normal model alias resolver, or
  2. the call site passing the configured alias into provider/model normalization before alias resolution.

The workaround is to avoid aliases in agents.defaults.compaction.model and use openai/gpt-5.4-mini directly.

No credentials, user paths, account names, chat IDs, or local file paths are included in this report.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 19, 2026, 6:32 AM ET / 10:32 UTC.

    Summary
    Keep open: current main and v2026.6.8 still treat a bare compaction model override as a literal model id, while open fix PRs already target the remaining alias-resolution bug.

    Reproducibility: yes. at source level: a bare compaction.model alias reaches the return branch as model: override without calling the shared alias resolver. I did not run a live long-session auto-compaction in this read-only review.

    Root-cause cluster
    Relationship: canonical
    Canonical: #90340
    Summary: This issue is the canonical report for the embedded auto-compaction alias-resolution bug; open PRs are candidate fixes, while safeguard-mode compaction issues are related but distinct.

    Members:

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

    Next step
    Open fix PRs already target this issue, so ClawSweeper should not queue another repair branch.

    Review details

    Best possible solution:

    Land one canonical narrow fix, likely #90885 if maintainers accept that direction, then close this issue after the merged code is on main.

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

    Yes at source level: a bare compaction.model alias reaches the return branch as model: override without calling the shared alias resolver. I did not run a live long-session auto-compaction in this read-only review.

    Is this the best way to solve the issue?

    Yes: the best fix is to reuse the existing shared model alias resolver in resolveEmbeddedCompactionTarget while preserving current literal model-id and auth-profile behavior. The linked open PRs are implementation candidates, so the issue should remain open until one merges or maintainers close both.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Two open PRs target the same issue; maintainers need to choose one canonical fix path before closing the report.
    • The fix is compatibility-sensitive because alias resolution must not silently steal precedence from literal configured model ids.

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

    Label changes

    Label justifications:

    • P2: This is a normal-priority compaction/model-routing bug with a clear canonical-model workaround and limited blast radius.
    • impact:session-state: Failed auto-compaction prevents the intended long-session context-management behavior from completing.
    • impact:auth-provider: The failure is in provider/model choice for a configured compaction override alias.
    Evidence reviewed

    What I checked:

    Likely related people:

    • steipete: Recent merged compaction fallback, OpenAI provider identity, and model-selection history touches the central resolver and alias contracts. (role: feature owner / recent area contributor; confidence: high; commits: aada44fca5ab, bb46b79d3c14; files: src/agents/embedded-agent-runner/compaction-runtime-context.ts, src/agents/model-selection-shared.ts)
    • vincentkoc: Recent commits touched the compaction runtime-context helper and model catalog/model-selection shared area after the report. (role: recent area contributor; confidence: medium; commits: c624ae49db90, daf7c92db3e5; files: src/agents/embedded-agent-runner/compaction-runtime-context.ts, src/agents/model-selection-shared.ts)
    • stevenepalmer: Adjacent model-selection work preserved exact configured provider/model refs before aliases, which is the same compatibility invariant the fix PRs must preserve. (role: adjacent alias-precedence contributor; confidence: medium; commits: 86e33d6985c9; files: src/agents/model-selection-shared.ts)
    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.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jun 4, 2026
  3. added a commit that references this issue on Jun 7, 2026
    2e566e0
  4. added
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    on Jun 15, 2026
  5. steipete commented on Jun 19, 2026

    @steipete
    Contributor

    Fixed by #90885 in b677ea6.

    Bare compaction model aliases now resolve to the canonical provider/model at the shared runtime-context boundary before direct, queued, or context-engine dispatch. The fix also preserves active-provider literal precedence and same-provider auth. Focused tests, docs checks, exact-head autoreview, and exact-head hosted CI passed.

    Thanks for the report and clear workaround, @toruvieI.

  6. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions