OpenClaw DB-First Session Loading - Feature Request / Help Needed
Background
We're trying to implement DB-first session loading to reduce token usage and improve startup performance.
Current Implementation
- OpenClaw loads sessions from
.jsonlfiles - Large sessions (100+ messages) consume 100k-200k tokens
- We want to load only recent messages (20-30) from PostgreSQL database
What We've Done
- Implemented DB session loader with tiered loading (hot/warm/cold)
- Migrated 110 messages to PostgreSQL successfully
- Modified source code (
src/agents/pi-embedded-runner/run/attempt.ts) - Attempted to compile but encountered issues:
- A2UI bundle fails
- Direct modification of
dist/*.jsfiles doesn't work reliably
The Problem
Code modifications don't execute:
- Modified
pi-embedded-CCXIVUPP.jsandpi-embedded-DF3C75Qw.js - Added DB loading logic before
SessionManager.open() - No logs appear, code path never executes
- Gateway restarts don't pick up changes
Code Location
// In attempt.ts around line 1096
await prewarmSessionFile(params.sessionFile);
// We added:
if (useDBFirst && params.sessionKey) {
const dbLoader = getDBSessionLoader();
const sessionData = await dbLoader.loadSession(params.sessionKey);
// ... but this never executes
}
sessionManager = guardSessionManager(SessionManager.open(params.sessionFile), {
// ...
});
Questions
-
What's the correct way to modify OpenClaw source and rebuild?
- How to fix A2UI bundle errors?
- Is there a development build mode?
-
Is there an official way to implement custom session loaders?
- Plugin system?
- Configuration hooks?
-
Why don't dist file modifications work?
- Are files cached?
- Multiple code paths?