Skip to content

Allow zero group chat history limit - #65425

Closed
samrusani wants to merge 3 commits into
openclaw:mainfrom
samrusani:fix-groupchat-historylimit-zero
Closed

samrusani wants to merge 3 commits into
openclaw:mainfrom
samrusani:fix-groupchat-historylimit-zero

Conversation

@samrusani

@samrusani samrusani commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Allow channels.groupChat.historyLimit to be set to 0 so users can disable group history consistently with the rest of the config schema.

After review:

  • regenerated src/config/schema.base.generated.ts
  • renamed the regression test to match the repo unlimited-history wording

Validation:

  • pnpm config:schema:check
  • pnpm exec vitest run src/config/zod-schema.core.regressions.test.ts

@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: 7545a50e5c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@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 schema to keep historyLimit aligned

Switching GroupChatSchema.historyLimit to min(0) changes runtime validation, but the generated public schema still has exclusiveMinimum: 0 for the same field(s), so schema-driven consumers (for example config UI/lookup paths built from GENERATED_BASE_CONFIG_SCHEMA) can still reject 0 even though runtime parsing now accepts it. This commit should include regenerated config schema artifacts to keep runtime and public schema contracts consistent.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR aligns GroupChatSchema.historyLimit with every other historyLimit field in the config by changing .positive() to .min(0), and adds a small regression test. The Zod change itself is correct, but schema.base.generated.ts was not regenerated — it still emits exclusiveMinimum: 0 for the relevant fields, so pnpm config:schema:check (and JSON-schema-aware IDE validators) will continue to reject 0 until pnpm config:schema:gen is run and the updated file is committed.

Confidence Score: 4/5

Safe to merge after regenerating the JSON schema; the Zod change is correct but the generated file is stale.

One P1 issue: schema.base.generated.ts still has exclusiveMinimum: 0 for groupChat.historyLimit, contradicting the new Zod validation. This will cause pnpm config:schema:check to fail and IDE validators to reject the newly-allowed value until the file is regenerated.

src/config/schema.base.generated.ts — needs regeneration via pnpm config:schema:gen to reflect the min(0) change.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/config/zod-schema.core.ts
Line: 367

Comment:
**Generated JSON schema not regenerated**

`schema.base.generated.ts` still declares `exclusiveMinimum: 0` for `groupChat.historyLimit` (lines 6113 and 17705), meaning JSON-schema-aware validators (IDE LSP, `pnpm config:schema:check`) will still reject `0` even after this Zod change. Per the repo's drift-detection flow, `pnpm config:schema:gen` must be run and the updated `schema.base.generated.ts` committed alongside this change.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/config/zod-schema.core.regressions.test.ts
Line: 5-7

Comment:
**Misleading test description**

The test name says "disable group history" but `limitHistoryTurns(messages, 0)` returns all messages unchanged (unlimited), matching the established DM convention documented in `pi-embedded-runner.get-dm-history-limit-from-session-key.falls-back-provider-default-per-dm-not.test.ts` ("returns 0 when per-DM historyLimit is explicitly 0 (unlimited)"). Consider naming this `"accepts zero to signal unlimited history"` so the intent is consistent with the rest of the codebase.

```suggestion
  it("accepts zero to signal unlimited history", () => {
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(config): allow zero group chat histo..." | Re-trigger Greptile

.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.

P1 Generated JSON schema not regenerated

schema.base.generated.ts still declares exclusiveMinimum: 0 for groupChat.historyLimit (lines 6113 and 17705), meaning JSON-schema-aware validators (IDE LSP, pnpm config:schema:check) will still reject 0 even after this Zod change. Per the repo's drift-detection flow, pnpm config:schema:gen must be run and the updated schema.base.generated.ts committed alongside this change.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/zod-schema.core.ts
Line: 367

Comment:
**Generated JSON schema not regenerated**

`schema.base.generated.ts` still declares `exclusiveMinimum: 0` for `groupChat.historyLimit` (lines 6113 and 17705), meaning JSON-schema-aware validators (IDE LSP, `pnpm config:schema:check`) will still reject `0` even after this Zod change. Per the repo's drift-detection flow, `pnpm config:schema:gen` must be run and the updated `schema.base.generated.ts` committed alongside this change.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +5 to +7
it("accepts zero to disable group history", () => {
expect(() => GroupChatSchema.parse({ historyLimit: 0 })).not.toThrow();
});

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 Misleading test description

The test name says "disable group history" but limitHistoryTurns(messages, 0) returns all messages unchanged (unlimited), matching the established DM convention documented in pi-embedded-runner.get-dm-history-limit-from-session-key.falls-back-provider-default-per-dm-not.test.ts ("returns 0 when per-DM historyLimit is explicitly 0 (unlimited)"). Consider naming this "accepts zero to signal unlimited history" so the intent is consistent with the rest of the codebase.

Suggested change
it("accepts zero to disable group history", () => {
expect(() => GroupChatSchema.parse({ historyLimit: 0 })).not.toThrow();
});
it("accepts zero to signal unlimited history", () => {
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/config/zod-schema.core.regressions.test.ts
Line: 5-7

Comment:
**Misleading test description**

The test name says "disable group history" but `limitHistoryTurns(messages, 0)` returns all messages unchanged (unlimited), matching the established DM convention documented in `pi-embedded-runner.get-dm-history-limit-from-session-key.falls-back-provider-default-per-dm-not.test.ts` ("returns 0 when per-DM historyLimit is explicitly 0 (unlimited)"). Consider naming this `"accepts zero to signal unlimited history"` so the intent is consistent with the rest of the codebase.

```suggestion
  it("accepts zero to signal unlimited history", () => {
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: S and removed size: XS labels Apr 12, 2026

@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: 8c60bfa20e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +396 to +398
if (!this.fts.enabled || !this.fts.available) {
const fallbackResults = await this.searchKeywordFallback(cleaned, candidates);
return this.selectScoredResults(fallbackResults, maxResults, minScore, 0);

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.

P1 Badge Keep vector search active when hybrid mode is off

When query.hybrid.enabled is false, this.fts.enabled is also false (set from hybrid config), so this new branch always runs and returns searchKeywordFallback(...), bypassing the vector results computed just above. That changes vector-only mode into keyword-only mode for all users who disable hybrid search, which can drop valid semantic matches and return empty results for paraphrased queries that previously worked.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex automated review: keeping this open.

Keep this PR open. Current main still rejects messages.groupChat.historyLimit: 0 in the core runtime schema and generated public schema, while docs and channel/provider schemas treat zero as a supported group-history disable value. The PR contains the useful config fix, but it should not be landed as-is because its current diff also bundles unrelated memory-core search behavior with an unresolved vector-only search regression concern.

Best possible solution:

Keep this PR open, but ask the contributor to split/drop the unrelated memory-core changes or have a maintainer cherry-pick the scoped config fix: change GroupChatSchema.historyLimit to min(0), regenerate src/config/schema.base.generated.ts, and add focused regression coverage for accepting 0 and rejecting negatives. The memory-core text-search fallback should move to a separate PR after the vector-only search concern is resolved.

What I checked:

  • Current runtime schema rejects zero: GroupChatSchema.historyLimit is still z.number().int().positive().optional() on current main, while adjacent DM history uses min(0). (src/config/zod-schema.core.ts:391, 4878d3e059ce)
  • Generated schema still rejects zero: The generated base config schema still emits exclusiveMinimum: 0 for groupChat.historyLimit, so JSON-schema consumers would reject the value even if runtime validation were changed alone. (src/config/schema.base.generated.ts:7135, 4878d3e059ce)
  • Public docs advertise zero: The channel configuration docs say messages.groupChat.historyLimit is the global default and 0 disables group history. Public docs: docs/gateway/config-channels.md. (docs/gateway/config-channels.md:771, 4878d3e059ce)
  • Channel schemas already allow zero: Provider/channel-specific history limits, such as Telegram, already use z.number().int().min(0), matching the requested core schema behavior. (src/config/zod-schema.providers-core.ts:236, 4878d3e059ce)
  • Runtime treats zero as disabling group context: Telegram resolves cfg.messages?.groupChat?.historyLimit through Math.max(0, ...), and group history context is only included when historyLimit > 0. (extensions/telegram/src/bot-message-context.session.ts:288, 4878d3e059ce)
  • PR diff is not scoped to the config fix: Supplied PR metadata shows six changed files: the config schema/generated schema/test plus three unrelated extensions/memory-core files. The head includes commits for both fix(config): allow zero group chat history limit and add memory text-search fallback. (849c385029c8)

Remaining risk / open question:

  • Merging the current PR as-is would bundle a small config-schema fix with unrelated memory-core search behavior.
  • The memory-core fallback change needs separate review because it may regress vector-only search when hybrid search is disabled.
  • No local tests were run because this was a read-only review; the decision is based on source, docs, generated schema, PR diff context, and supplied review comments.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 4878d3e059ce.

@openclaw-clownfish

Copy link
Copy Markdown
Contributor

Thanks @samrusani for putting together the config fix here. I am closing this in favor of #65359 (#65359) because that PR is the narrower canonical path for the same GroupChatSchema.historyLimit: 0 root cause: it keeps the change scoped to the config schema, generated base schema, and focused regression coverage.

Clownfish is not landing this branch as-is because it also includes unrelated memory-core search changes with an unresolved vector-only search regression review comment. I am keeping credit and attribution to this source PR, #65425, in the cluster record so maintainers can carry that forward if they borrow any of the scoped config work. If there is a distinct memory-core fix to pursue, please split it into a separate PR; if this config fix still differs from #65359, reply here and we can reopen or reclassify.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant