openclaw - ✅(Solved) Fix Bug: compaction.truncateAfterCompaction is implemented but rejected by config validation [2 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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#68143Fetched 2026-04-18 05:53:45
View on GitHub
Comments
2
Participants
2
Timeline
4
Reactions
0
Timeline (top)
commented ×2cross-referenced ×2

agents.defaults.compaction.truncateAfterCompaction appears to be implemented and documented in the runtime, but the Zod config validator rejects it as an unknown key. This prevents users from enabling post-compaction session JSONL truncation, even though the runtime has code to do exactly that.

This matters for long-running Telegram / gateway sessions: auto-compaction can create a type: "compaction" entry, but the JSONL transcript keeps growing because the summarized historical message entries are not physically removed. In the diagnosed case, the session had already compacted once, but the file still stayed large enough to keep contributing to context-overflow / timeout failures.

Root Cause

This matters for long-running Telegram / gateway sessions: auto-compaction can create a type: "compaction" entry, but the JSONL transcript keeps growing because the summarized historical message entries are not physically removed. In the diagnosed case, the session had already compacted once, but the file still stayed large enough to keep contributing to context-overflow / timeout failures.

Fix Action

Fix / Workaround

Local workaround that confirmed the issue

PR fix notes

PR #68328: fix(config): accept truncateAfterCompaction

Description (problem / solution / changelog)

Summary

Accept agents.defaults.compaction.truncateAfterCompaction in the Zod config schema and add regression coverage at both the leaf schema and public config validation layers.

Root cause

The public config type, help metadata, and compaction runtime already knew about truncateAfterCompaction, but AgentDefaultsSchema omitted the field. That left config validation rejecting an option that the rest of the config surface already advertised and the runtime already honored.

Impact

Users can set agents.defaults.compaction.truncateAfterCompaction: true without schema validation failing.

Closes #68143.

Validation

  • pnpm test src/config/zod-schema.agent-defaults.test.ts src/config/config.schema-regressions.test.ts
  • pnpm check currently fails on existing unrelated main issues in src/agents/auth-health.test.ts, src/commands/configure.channels.ts, and src/flows/channel-setup*.test.ts

Changed files


PR #68395: fix(config): accept truncateAfterCompaction

Description (problem / solution / changelog)

Summary

Accept agents.defaults.compaction.truncateAfterCompaction in the Zod config schema and add regression coverage at both the leaf schema and public config validation layers.

Root cause

The public config type, help metadata, and compaction runtime already knew about truncateAfterCompaction, but AgentDefaultsSchema omitted the field. That left config validation rejecting an option that the rest of the config surface already advertised and the runtime already honored.

Impact

Users can set agents.defaults.compaction.truncateAfterCompaction: true without schema validation failing.

Closes #68143.

Validation

  • pnpm test src/config/zod-schema.agent-defaults.test.ts src/config/config.schema-regressions.test.ts
  • pnpm check currently fails on existing unrelated main issues in src/agents/auth-health.test.ts, src/commands/configure.channels.ts, and src/flows/channel-setup*.test.ts

Changed files

  • src/config/config.schema-regressions.test.ts (modified, +14/-0)
  • src/config/zod-schema.agent-defaults.test.ts (modified, +9/-0)
  • src/config/zod-schema.agent-defaults.ts (modified, +1/-0)

Code Example

openclaw config set agents.defaults.compaction '{"mode":"safeguard","truncateAfterCompaction":true}' --strict-json

---

{
  "agents": {
    "defaults": {
      "compaction": {
        "mode": "safeguard",
        "truncateAfterCompaction": true
      }
    }
  }
}

---

openclaw config validate
launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway

---

Config validation failed: agents.defaults.compaction: Unrecognized key: "truncateAfterCompaction"

---

config reload skipped (invalid config): agents.defaults.compaction: Unrecognized key: "truncateAfterCompaction"
Invalid config at ~/.openclaw/openclaw.json:
- agents.defaults.compaction: Unrecognized key: "truncateAfterCompaction"

---

// dist/plugin-sdk/src/config/types.agent-defaults.d.ts
truncateAfterCompaction?: boolean;

---

// dist/runtime-schema-BpoRdXIq.js
"agents.defaults.compaction.truncateAfterCompaction": { ... }

---

// dist/compact-Fl3cALvc.js
if (params.config?.agents?.defaults?.compaction?.truncateAfterCompaction) {
  const truncResult = await truncateSessionAfterCompaction(...)
}

---

// dist/zod-schema-BO9ySEsE.js
compaction: z.object({
  mode: ...,
  provider: ...,
  ...,
  model: z.string().optional(),
  timeoutSeconds: z.number().int().positive().optional(),
  memoryFlush: ...,
  notifyUser: z.boolean().optional()
}).strict().optional()

---

timeoutSeconds: z.number().int().positive().optional(),
  memoryFlush: z.object({ ... }).strict().optional(),
+ truncateAfterCompaction: z.boolean().optional(),
  notifyUser: z.boolean().optional()

---

{
  "mode": "safeguard",
  "model": "openai-codex/gpt-5.4",
  "timeoutSeconds": 1800,
  "truncateAfterCompaction": true,
  "maxHistoryShare": 0.35,
  "recentTurnsPreserve": 2,
  "postIndexSync": "async",
  "notifyUser": false
}

---

agents.defaults.compaction.truncateAfterCompaction
RAW_BUFFERClick to expand / collapse

I am reporting this from a local OpenClaw instance while diagnosing a real user configuration. The local OpenClaw runtime found an internal schema mismatch in OpenClaw 2026.4.15.

Summary

agents.defaults.compaction.truncateAfterCompaction appears to be implemented and documented in the runtime, but the Zod config validator rejects it as an unknown key. This prevents users from enabling post-compaction session JSONL truncation, even though the runtime has code to do exactly that.

This matters for long-running Telegram / gateway sessions: auto-compaction can create a type: "compaction" entry, but the JSONL transcript keeps growing because the summarized historical message entries are not physically removed. In the diagnosed case, the session had already compacted once, but the file still stayed large enough to keep contributing to context-overflow / timeout failures.

Version

  • OpenClaw: 2026.4.15
  • Install path observed: npm/global package under /opt/homebrew/lib/node_modules/openclaw
  • Runtime: Node 25.2.1
  • Platform: macOS

Reproduction

Run:

openclaw config set agents.defaults.compaction '{"mode":"safeguard","truncateAfterCompaction":true}' --strict-json

or add this to ~/.openclaw/openclaw.json:

{
  "agents": {
    "defaults": {
      "compaction": {
        "mode": "safeguard",
        "truncateAfterCompaction": true
      }
    }
  }
}

Then validate or restart the gateway:

openclaw config validate
launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway

Actual behavior

Config validation fails:

Config validation failed: agents.defaults.compaction: Unrecognized key: "truncateAfterCompaction"

Gateway reload/start can also reject the config:

config reload skipped (invalid config): agents.defaults.compaction: Unrecognized key: "truncateAfterCompaction"
Invalid config at ~/.openclaw/openclaw.json:
- agents.defaults.compaction: Unrecognized key: "truncateAfterCompaction"

Expected behavior

The config should be accepted, because the runtime already has support for this option and should call post-compaction truncation after a successful compaction.

Evidence in the shipped package

The option exists in the type definition:

// dist/plugin-sdk/src/config/types.agent-defaults.d.ts
truncateAfterCompaction?: boolean;

The option has schema/help metadata:

// dist/runtime-schema-BpoRdXIq.js
"agents.defaults.compaction.truncateAfterCompaction": { ... }

The runtime checks it and calls the truncation path:

// dist/compact-Fl3cALvc.js
if (params.config?.agents?.defaults?.compaction?.truncateAfterCompaction) {
  const truncResult = await truncateSessionAfterCompaction(...)
}

But the Zod schema for agents.defaults.compaction omits the field:

// dist/zod-schema-BO9ySEsE.js
compaction: z.object({
  mode: ...,
  provider: ...,
  ...,
  model: z.string().optional(),
  timeoutSeconds: z.number().int().positive().optional(),
  memoryFlush: ...,
  notifyUser: z.boolean().optional()
}).strict().optional()

Local workaround that confirmed the issue

Adding this one line to the Zod schema fixed validation locally:

  timeoutSeconds: z.number().int().positive().optional(),
  memoryFlush: z.object({ ... }).strict().optional(),
+ truncateAfterCompaction: z.boolean().optional(),
  notifyUser: z.boolean().optional()

After that, the config validated and the gateway started with:

{
  "mode": "safeguard",
  "model": "openai-codex/gpt-5.4",
  "timeoutSeconds": 1800,
  "truncateAfterCompaction": true,
  "maxHistoryShare": 0.35,
  "recentTurnsPreserve": 2,
  "postIndexSync": "async",
  "notifyUser": false
}

Operational impact observed

A long-running Telegram direct session had:

  • type: "compaction" entry present
  • firstKeptEntryId present
  • tokensBefore about 194864
  • transcript still around 1.96 MB / 331 entries

After manually applying equivalent truncation based on the latest compaction boundary, the transcript reduced to about:

  • 575 KB / 137 entries
  • JSON remained valid
  • no dangling parentId references

So the feature is useful and the missing validator field prevents it from being enabled safely through normal config.

Related issues

This appears related to previous config-schema mismatches such as #60512 and #40227, but the missing key here is specifically:

agents.defaults.compaction.truncateAfterCompaction

extent analysis

TL;DR

The most likely fix is to update the Zod schema to include the missing truncateAfterCompaction field.

Guidance

  • The issue is caused by a mismatch between the runtime's supported configuration options and the Zod schema used for validation.
  • To fix the issue, the Zod schema needs to be updated to include the truncateAfterCompaction field, as shown in the local workaround.
  • The updated Zod schema should include the following line: truncateAfterCompaction: z.boolean().optional().
  • After updating the Zod schema, the config should be re-validated to ensure that the truncateAfterCompaction option is recognized.

Example

  timeoutSeconds: z.number().int().positive().optional(),
  memoryFlush: z.object({ ... }).strict().optional(),
+ truncateAfterCompaction: z.boolean().optional(),
  notifyUser: z.boolean().optional()

Notes

  • The issue is specific to OpenClaw version 2026.4.15 and may not affect other versions.
  • The local workaround confirmed that updating the Zod schema fixes the issue, but a official fix or patch may be required for a permanent solution.

Recommendation

Apply the workaround by updating the Zod schema to include the missing truncateAfterCompaction field, as this has been confirmed to fix the issue locally.

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…

FAQ

Expected behavior

The config should be accepted, because the runtime already has support for this option and should call post-compaction truncation after a successful compaction.

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 - ✅(Solved) Fix Bug: compaction.truncateAfterCompaction is implemented but rejected by config validation [2 pull requests, 2 comments, 2 participants]