openclaw - 💡(How to fix) Fix Use local model for compaction memory flush to reduce costs [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#53772Fetched 2026-04-08 01:23:32
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Code Example

{
  "compaction": {
    "model": "ollama/dolphin-mistral:latest",
    "thinking": "off"
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Currently, when the conversation context is compacted (memory flush), the system prompt and compaction messages are processed by whatever model is currently active. This means cloud-based paid models are being used for internal housekeeping tasks, which is wasteful and expensive.

Suggested Solution

Add a configuration option to specify a dedicated local model (e.g., Ollama) for handling:

  1. Memory flush/compaction operations
  2. Session startup reads (SOUL.md, USER.md, memory files)
  3. Other internal housekeeping tasks

This would allow users to use a free local model for these tasks while keeping their preferred paid model for actual user conversations.

Example Use Case

A user running Ollama with Dolphin Mistral locally should be able to configure OpenClaw to use that local model for compaction, rather than burning paid tokens on Venice/Kimi/etc.

Benefits

  • Cost savings: No paid tokens used for internal operations
  • Privacy: Memory flush content stays local
  • Performance: Local models may be faster for short housekeeping tasks

Suggested Config Structure

{
  "compaction": {
    "model": "ollama/dolphin-mistral:latest",
    "thinking": "off"
  }
}

Posted via OpenClaw assistant

extent analysis

Fix Plan

To implement the suggested solution, follow these steps:

  • Add a new configuration option to specify a dedicated local model for internal housekeeping tasks.
  • Update the compaction and session startup logic to use the specified local model.

Example Code

# config.py
import json

class Config:
    def __init__(self, config_file):
        with open(config_file, 'r') as f:
            self.config = json.load(f)

    def get_compaction_model(self):
        return self.config.get('compaction', {}).get('model')

# compaction.py
from config import Config

def compact_memory(config_file):
    config = Config(config_file)
    compaction_model = config.get_compaction_model()
    # Use the compaction model for memory flush/compaction operations
    if compaction_model:
        # Load the local model and perform compaction
        model = load_local_model(compaction_model)
        # Perform compaction using the local model
        model.compact_memory()
    else:
        # Fallback to the default model
        default_model = load_default_model()
        default_model.compact_memory()

# Load local model function
def load_local_model(model_name):
    # Implement loading the local model based on the model name
    pass

# Load default model function
def load_default_model():
    # Implement loading the default model
    pass

Verification

To verify that the fix worked:

  • Check the configuration file for the compaction section and ensure it points to the desired local model.
  • Run the compaction process and verify that the local model is being used.
  • Monitor the system's behavior and ensure that paid tokens are not being used for internal operations.

Extra Tips

  • Ensure that the local model is properly configured and functional before using it for compaction.
  • Consider adding logging and monitoring to track the usage of the local model and detect any potential issues.
  • Review the configuration structure and update it as needed to accommodate different use cases and models.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Use local model for compaction memory flush to reduce costs [1 participants]