openclaw - ✅(Solved) Fix compaction.truncateAfterCompaction rejected by strict zod schema [1 pull requests]

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…

truncateAfterCompaction is declared in the TypeScript type (types.agent-defaults.ts:451), read at runtime (compact.ts:1103), documented in schema help (schema.help.ts:1216), and has a label (schema.labels.ts:564) — but is missing from the zod validation schema at zod-schema.agent-defaults.ts:136-180.

The compaction zod object uses .strict(), which rejects unknown keys. Any user who sets agents.defaults.compaction.truncateAfterCompaction: true in their config will fail validation at startup, preventing the container/gateway from starting.

Error Message

Config validation fails with an "unrecognized key" error on load/hot-reload.

Root Cause

truncateAfterCompaction is declared in the TypeScript type (types.agent-defaults.ts:451), read at runtime (compact.ts:1103), documented in schema help (schema.help.ts:1216), and has a label (schema.labels.ts:564) — but is missing from the zod validation schema at zod-schema.agent-defaults.ts:136-180.

The compaction zod object uses .strict(), which rejects unknown keys. Any user who sets agents.defaults.compaction.truncateAfterCompaction: true in their config will fail validation at startup, preventing the container/gateway from starting.

Fix Action

Fix

Add truncateAfterCompaction: z.boolean().optional() to the compaction zod object in zod-schema.agent-defaults.ts.

PR fix notes

PR #69282: fix(config): add truncateAfterCompaction to compaction zod schema

Description (problem / solution / changelog)

Summary

  • Add missing truncateAfterCompaction: z.boolean().optional() to the compaction zod schema
  • Regenerate config baseline hash

The field is declared in the TypeScript type (types.agent-defaults.ts:451), read at runtime (compact.ts:1103), documented in schema help (schema.help.ts:1216), and has a label — but was missing from the strict zod validation schema. Since the compaction object uses .strict(), any user setting this field gets a validation error at startup.

Closes #69280

Test plan

  • pnpm tsgo passes
  • pnpm test src/config/zod-schema.agent-defaults.test.ts — 11/11 pass
  • pnpm config:docs:check passes after hash regen

🤖 Generated with Claude Code

Changed files

  • docs/.generated/config-baseline.sha256 (modified, +2/-2)
  • src/config/zod-schema.agent-defaults.ts (modified, +1/-0)

Code Example

// ~/.openclaw/config.json
{
  "agents": {
    "defaults": {
      "compaction": {
        "mode": "safeguard",
        "truncateAfterCompaction": true
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

truncateAfterCompaction is declared in the TypeScript type (types.agent-defaults.ts:451), read at runtime (compact.ts:1103), documented in schema help (schema.help.ts:1216), and has a label (schema.labels.ts:564) — but is missing from the zod validation schema at zod-schema.agent-defaults.ts:136-180.

The compaction zod object uses .strict(), which rejects unknown keys. Any user who sets agents.defaults.compaction.truncateAfterCompaction: true in their config will fail validation at startup, preventing the container/gateway from starting.

Impact

The feature is effectively unreachable — dead code behind a locked validation gate. No user can enable it.

Reproduction

// ~/.openclaw/config.json
{
  "agents": {
    "defaults": {
      "compaction": {
        "mode": "safeguard",
        "truncateAfterCompaction": true
      }
    }
  }
}

Config validation fails with an "unrecognized key" error on load/hot-reload.

Fix

Add truncateAfterCompaction: z.boolean().optional() to the compaction zod object in zod-schema.agent-defaults.ts.

extent analysis

TL;DR

Add truncateAfterCompaction: z.boolean().optional() to the compaction zod object in zod-schema.agent-defaults.ts to fix the validation issue.

Guidance

  • Verify that the truncateAfterCompaction property is correctly declared in the TypeScript type and documented in the schema help and labels.
  • Check the zod validation schema in zod-schema.agent-defaults.ts to ensure it includes the truncateAfterCompaction property.
  • Update the compaction zod object to include truncateAfterCompaction: z.boolean().optional() to allow for optional boolean values.
  • Test the updated configuration with the truncateAfterCompaction property set to true to ensure validation succeeds.

Example

// zod-schema.agent-defaults.ts
const compaction = z.object({
  // ... existing properties ...
  truncateAfterCompaction: z.boolean().optional(),
});

Notes

This fix assumes that the truncateAfterCompaction property is intended to be an optional boolean value. If the property has different requirements, the zod schema may need to be adjusted accordingly.

Recommendation

Apply the workaround by adding truncateAfterCompaction: z.boolean().optional() to the compaction zod object, as this will allow users to enable the feature without validation errors.

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 - ✅(Solved) Fix compaction.truncateAfterCompaction rejected by strict zod schema [1 pull requests]