Skip to content

fix(config): allow historyLimit: 0 in GroupChatSchema - #65359

Merged
steipete merged 1 commit into
openclaw:mainfrom
maxreith:fix/groupchat-historylimit-zero
Jul 21, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
maxreith:fix/groupchat-historylimit-zero

Conversation

@maxreith

@maxreith maxreith commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GroupChatSchema.historyLimit used .positive(), which rejects 0, while the other historyLimit schemas accept 0 with .min(0). This made messages.groupChat.historyLimit: 0 invalid even though 0 is the existing config value for disabling history.

Fixes #65305

Fix

  • Change messages.groupChat.historyLimit from .positive() to .min(0) in src/config/zod-schema.core.ts.
  • Add focused runtime config schema tests for 0, positive values, and negative values.
  • Add a Gateway config.patch regression test proving the runtime API path accepts historyLimit: 0.

Current Status

  • Rebased cleanly on current upstream/main (33b81686ad).
  • Current PR head is a4f99c4cd2c05c26e52a06b315a5b81da24f509b.
  • Diff against current main is one commit: git rev-list --left-right --count upstream/main...refresh-historylimit-zero -> 0 1.
  • Main has not already fixed this: current main still has .positive() for GroupChatSchema.historyLimit.

Test Plan

Current head verification after the final rebase:

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.runtime-config.config.ts src/config/zod-schema.core.test.ts
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.gateway.config.ts src/gateway/server.config-patch.test.ts -t "historyLimit: 0"
  • ./node_modules/.bin/oxfmt --check src/config/zod-schema.core.ts src/config/zod-schema.core.test.ts src/gateway/server.config-patch.test.ts
  • git diff --check

Real behavior proof

Behavior or issue addressed: messages.groupChat.historyLimit: 0 must be accepted as a valid runtime config value so group chat history can be disabled.

Real environment tested: Local OpenClaw checkout of this PR branch after applying the schema/test changes, built locally and run with a local Gateway using token auth.

Exact steps or command run after this patch: Built the branch with OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build, started the built local Gateway, connected through the backend Gateway protocol with operator.admin, read the runtime config schema, called config.patch, and read the config back from the running server.

Evidence after fix: Copied live output from the local Gateway API smoke run:

helloAuth.scopes: ["operator.admin"]
schema.messages.groupChat.historyLimit: { type: "integer", minimum: 0 }
before: { valid: true, historyLimit: 1 }
config.patch: { ok: true, noop: false, historyLimit: 0 }
after: { valid: true, historyLimit: 0 }

Observed result after fix: The running Gateway advertised minimum: 0 for messages.groupChat.historyLimit; config.patch accepted historyLimit: 0 with ok: true; a follow-up read returned valid: true and historyLimit: 0.

What was not tested: The dashboard browser clickpath was not exercised; this proof targets the runtime Gateway/API config validation path directly.

This specifically covers the concern that direct config loading may accept a value while runtime JSON Schema/API validation may still reject it.

@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a one-character inconsistency in GroupChatSchema where historyLimit used .positive() (rejects 0) instead of .min(0) (accepts 0), aligning it with DmConfigSchema and ReplyRuntimeConfigSchemaShape. A focused test file is added covering the zero, positive, and negative cases.

Confidence Score: 5/5

Safe to merge — minimal targeted fix with adequate test coverage and no side effects.

The change is a single validator token fix that aligns GroupChatSchema with every other historyLimit schema in the file. Tests cover the critical boundary values. No logic, security, or architectural concerns.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(config): allow historyLimit: 0 in Gr..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 313c515d9d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

.object({
mentionPatterns: z.array(z.string()).optional(),
historyLimit: z.number().int().positive().optional(),
historyLimit: z.number().int().min(0).optional(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Regenerate base config schema for historyLimit change

Update the generated config schema artifact alongside this Zod change. GroupChatSchema.historyLimit now accepts 0, but buildBaseConfigSchema serves GENERATED_BASE_CONFIG_SCHEMA (src/config/schema.ts:463), and that snapshot still encodes messages.groupChat.historyLimit as exclusiveMinimum: 0 (src/config/schema.base.generated.ts:6193). This leaves runtime parsing and published schema out of sync, so schema-driven consumers (like config UIs/validators) can still reject 0 even though core now accepts it.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 2:17 AM ET / 06:17 UTC.

Summary
The PR relaxes messages.groupChat.historyLimit from positive-only to nonnegative and adds direct schema plus Gateway config.patch regression coverage.

PR surface: Source 0, Tests +63. Total +63 across 3 files.

Reproducibility: yes. at source level. Current main validates messages.groupChat.historyLimit through GroupChatSchema, which still uses .positive() even though docs and sibling schemas define 0 as valid; I did not run tests because this review is read-only.

Review metrics: 1 noteworthy metric.

  • Config validator lower bound: 1 changed, 0 added, 0 removed. The PR relaxes one persisted config validator bound, which can alter upgrade behavior for zero-valued group-chat history configs.

Stored data model
Persistent data-model change detected: serialized state: src/gateway/server.config-patch.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #65305
Summary: This PR is the active focused candidate fix for the canonical group-chat history-limit zero-validation bug; same-topic duplicate PRs are closed, while the inbound history-cap PR is adjacent but distinct.

Members:

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

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Accepting messages.groupChat.historyLimit: 0 will make existing zero-valued configs effective after upgrade, disabling group-chat history where current main and the latest release reject the value.

Maintainer options:

  1. Accept documented zero semantics (recommended)
    Proceed if maintainers agree the documented 0-disables-history contract should apply to the global group-chat key on upgrade.
  2. Ask for one fresh upgrade smoke
    Request a current-head smoke covering direct config load, runtime schema lookup, and config.patch if maintainers want extra confidence before merge.
  3. Pause if zero should stay invalid
    Pause or close only if maintainers decide the global group-chat history limit should continue rejecting zero despite docs and sibling schemas.

Next step before merge

  • No automated repair is needed; the remaining action is maintainer acceptance of the compatibility-sensitive zero semantics and normal merge gates.

Security
Cleared: The diff changes config validation source and tests only, with no dependency, workflow, package, secret, permission, or new code-execution surface.

Review details

Best possible solution:

Land this narrow validation fix with schema and Gateway coverage once maintainers accept the documented zero-disables-history upgrade behavior and normal merge gates pass.

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

Yes, at source level. Current main validates messages.groupChat.historyLimit through GroupChatSchema, which still uses .positive() even though docs and sibling schemas define 0 as valid; I did not run tests because this review is read-only.

Is this the best way to solve the issue?

Yes. The schema owns the lower-bound contract, Gateway config.patch reaches the same validation path, and current runtime schema generation derives from OpenClawSchema rather than a separate generated artifact.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This fixes a bounded config validation bug with limited blast radius to group-chat history settings.
  • merge-risk: 🚨 compatibility: The lower-bound change makes existing messages.groupChat.historyLimit: 0 configs effective on upgrade instead of rejected.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live Gateway output showing runtime schema minimum: 0, config.patch accepting historyLimit: 0, and readback returning 0.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live Gateway output showing runtime schema minimum: 0, config.patch accepting historyLimit: 0, and readback returning 0.
Evidence reviewed

PR surface:

Source 0, Tests +63. Total +63 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 63 0 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 64 1 +63

What I checked:

  • repository policy applied: Root policy and the scoped Gateway guide were read; their config compatibility and Gateway-test guidance apply because this PR changes a runtime config validator and adds a Gateway config.patch test. (AGENTS.md:1, 4e6933c84f18)
  • PR diff changes the validator and tests the path: The diff changes GroupChatSchema.historyLimit from .positive() to .min(0), adds direct boundary tests for zero/positive/negative values, and adds a Gateway config.patch test for historyLimit: 0. (src/config/zod-schema.core.ts:534, a4f99c4cd2c0)
  • current main still rejects zero: Current main still uses .positive() for GroupChatSchema.historyLimit, while adjacent DM and reply runtime history-limit schemas use .min(0). (src/config/zod-schema.core.ts:613, 4e6933c84f18)
  • config validation reaches the changed schema: MessagesSchema wires messages.groupChat to GroupChatSchema, OpenClawSchema includes messages, and raw config validation calls OpenClawSchema.safeParse. (src/config/validation.ts:1055, 4e6933c84f18)
  • Gateway patch path is covered: config.patch validates the restored merge through validateConfigObjectRawWithPlugins and validateConfigObjectWithPlugins, so the added Gateway test covers the runtime API write path. (src/gateway/server-methods/config.ts:862, 4e6933c84f18)
  • runtime schema generation now derives from Zod: Current main computes the base config JSON Schema from OpenClawSchema.toJSONSchema; the older review request for src/config/schema.base.generated.ts is stale because that generated source file is no longer present. (src/config/schema-base.ts:233, 4e6933c84f18)

Likely related people:

  • patrick-slimelab: Recent merged work changed GroupChatSchema, message config types, and group-channel docs while adding channel-scoped mention pattern policy. (role: adjacent group-chat schema contributor; confidence: medium; commits: 9c1adf4e51a9; files: src/config/zod-schema.core.ts, src/config/types.messages.ts, docs/channels/groups.md)
  • amknight: Recent merged config work changed shared validation logic and the central schema file involved in this bug. (role: recent config validation contributor; confidence: medium; commits: 6810c67f0cdf; files: src/config/zod-schema.core.ts, src/config/validation.ts)
  • vincentkoc: Recent commits touched the central schema file and Gateway config handler path that validates config patch requests. (role: recent config and Gateway contributor; confidence: medium; commits: edd1d3319cce, deea78da72c5; files: src/config/zod-schema.core.ts, src/gateway/server-methods/config.ts)
  • joshavant: Recent merged work changed config.patch behavior and related Gateway config tests, the same API path extended by this PR. (role: adjacent Gateway config owner; confidence: medium; commits: 9f48254f099a; files: src/gateway/server-methods/config.ts, src/gateway/server.config-patch.test.ts)
  • ScientificProgrammer: Merged work changed public config JSON Schema generation from accepted input shapes, relevant to the runtime-schema concern raised during review. (role: schema generation contributor; confidence: medium; commits: 678a0ee9440b; files: src/config/schema-base.ts, src/config/schema.base.generated.test.ts, src/config/zod-schema.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 19, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@maxreith
maxreith force-pushed the fix/groupchat-historylimit-zero branch from cc931a4 to 1f33f52 Compare May 29, 2026 19:29
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S proof: supplied External PR includes structured after-fix real behavior proof. and removed size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 29, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 29, 2026
@maxreith
maxreith force-pushed the fix/groupchat-historylimit-zero branch from 1f33f52 to a4f99c4 Compare May 29, 2026 19:37
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 29, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels May 29, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 13, 2026
@clawsweeper clawsweeper Bot removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 17, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 17, 2026
@steipete steipete self-assigned this Jul 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 21, 2026
GroupChatSchema used .positive() which rejects 0, while all other
historyLimit schemas use .min(0). This caused a silent config reload
failure when setting messages.groupChat.historyLimit to 0.

Change .positive() to .min(0) and add test coverage.

Fixes #65305
@steipete
steipete force-pushed the fix/groupchat-historylimit-zero branch from a4f99c4 to b2a3ea8 Compare July 21, 2026 16:45
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(config): allow historyLimit: 0 in GroupChatSchema This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 40c2d27 into openclaw:main Jul 21, 2026
116 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
GroupChatSchema used .positive() which rejects 0, while all other
historyLimit schemas use .min(0). This caused a silent config reload
failure when setting messages.groupChat.historyLimit to 0.

Change .positive() to .min(0) and add test coverage.

Fixes openclaw#65305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GroupChatSchema historyLimit rejects 0 (uses .positive() instead of .min(0))

2 participants