Repository navigation
fix(channels): group-capable channels reject the documented historyLimit override - #118152
ayaangazali wants to merge 10 commits into
Conversation
|
Codex review: found issues before merge. Reviewed August 25, 2026, 6:54 PM ET / 22:54 UTC. ClawSweeper reviewWhat this changesThis PR adds documented group-history-limit validation to bundled channel schemas and makes LINE and Mattermost pending-history buffers use the resolved channel/account setting. Merge readinessKeep open: the PR still validates account-scoped limits that its LINE and Mattermost buffers honor, while the canonical prompt and compaction limiter on current main only reads the channel-root value. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherChannel schemas accept operator configuration before channel plugins process inbound group messages and before the embedded agent trims its transcript. Pending-message context and the core transcript limiter must apply the same retention policy for one routed account. flowchart LR
A[Operator channel config] --> B[Bundled channel schemas]
B --> C[Resolved channel account]
C --> D[LINE and Mattermost pending buffers]
C --> E[Core history resolver]
D --> F[Inbound group context]
E --> G[Prompt and compaction transcript]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +27, Tests +366, Generated 0. Total +393 across 21 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Make the core history resolver account-aware at both prompt and compaction call sites, add direct account/root/zero coverage there, then rebase this schema repair on that canonical behavior. Do we have a high-confidence way to reproduce the issue? Yes, from source: configure a multi-account LINE or Mattermost channel with account historyLimit 3 and root historyLimit 20; the plugin buffer reads 3 while the current core limiter reads 20. This read-only review did not execute the contributor branch. Is this the best way to solve the issue? No. The schema and plugin changes are useful, but account scope must be implemented by the canonical core resolver rather than leaving two retention owners to disagree. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against df9b7a5fbe9b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (17 earlier review cycles; latest 8 shown)
|
|
Both items addressed. P1 account-scope claim: removed rather than papered over. You are right that Real behavior proof added, from from-scratch builds on both sides so a stale Contract test is 21 passing. PR body updated with the same evidence. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
On the remaining P1, I want to lay out the structural constraint rather than guess at it, because I think this is the maintainer-direction item your own next-step note flags. The finding is right that the account form is accepted while the resolver ignores it. The reason I cannot simply stop accepting the account form is that these channels build both scopes from one object. ClickClack is representative: That leaves the two options you named, and both are maintainer calls:
What I have already done is remove the false advertisement: the contract test no longer asserts account-scope support, and there is a comment at that spot explaining that the resolver takes no account id. So the PR does not claim precedence that does not exist. I am happy to implement either direction. I did not pick one myself because option 1 changes shared runtime semantics and option 2 is a deliberate contract decision, and guessing would either overreach or bake in something you would rather not have. |
|
This P1 is correct, and I am taking the first of the two options it offers, resolving the active account before reading the limit. Short version of why, with the detail and citations in #117306 (comment) so I am not pasting it twice:
So the repair goes in the resolver at the owner boundary, which fixes every channel at once instead of per schema. That is a separate core PR, which I will link here as soon as it is up; this one stays schema-only. Happy to rebase this on top of it if you would rather they land in order. Thanks for holding the line on this one. The silent-no-op framing was the right call and it turned out to point at a real gap in core rather than just in this diff. |
|
The resolver fix is up as #119326. It makes |
c8bb395 to
3b03d24
Compare
|
Acted on the sequencing rather than restating it. This branch is now stacked on #119326, so the account scope it accepts is also honored. First, the premise still holds on today's main, checked rather than assumed: Same trace, same config, on Worth calling out the first two rows: on main an account-scoped DM session resolves to I could not take the other branch of your suggestion. "Stop accepting account scope" is awkward here because these channels build root and account from one object through Two things happened while rebasing that are worth flagging:
Validation on the stacked head: If you would rather keep these as two independent PRs, say so and I will unstack; merging #119326 first makes this rebase collapse to nothing. AI-assisted. |
|
Unstacked. You are right that embedding the core resolver work here made this PR unreviewable on its own, so it is back to channel scope only. Concretely, I replayed just this branch's own commits onto current main with
That removes the unrelated compaction and legacy-model coverage in one move, since it only existed here because the prerequisite's commits were riding along. #119326 stays independently reviewable and this PR no longer depends on it landing first. On the P3: with the core work gone from this head, Worth stating plainly, since I went the other way last time on your earlier note: I read "land and rebase on #119326" as an instruction to stack, and that was the wrong call. Reducing this to channel scope and letting the core land separately is clearly the better shape. Validation on the unstacked head: AI-assisted. |
|
Rebased onto current The baseline was not hand-merged. I reset both generated files to main and re-ran both generators, so the artifacts match what CI regenerates: Local proof at head On the red marks: I also think I made that worse: I pushed nine rebases within about a minute, so nine fork CI runs hit dependency install at once. That was my mistake in batching, not a change in the code. Happy to re-push to re-trigger if you would rather see a clean run. AI-assisted. |
|
Rebased onto current One thing in the regenerated baseline is worth calling out so it is not mistaken for something this PR did. The I confirmed the direction by forcing I did not want to silently raise a ratchet budget, and I also did not want to hand you a red gate, so I have kept the regenerated value and am flagging it here instead. If you would rather this PR pin Separately, that drift looks worth a maintainer look on its own: the lane appears not to run on AI-assisted. |
|
Rebased onto current The Verified at this head, both generated-artifact gates clean and the suites this PR owns passing. Nothing about the change itself moved; same diff, newer base. AI-assisted. |
|
Rebased onto current The jump to ten red checks on the previous head, including
So this push simply moves the branch past that window. Nothing about the change itself moved; same diff, newer base. AI-assisted. |
|
On the P1 here: I agree with the diagnosis, and I do not think it should be fixed inside this PR. You are right that That account-blind resolver is exactly what #119326 repairs. It threads the routed account through
I posted a before/after trace there showing the split: pre-fix an account with So the inconsistency you describe closes when #119326 lands, and duplicating that resolver change here would put the same repair in two PRs. This PR stays what it says on the tin: the schema accepts the documented key. Happy to reorder them if you would rather #119326 go first, or to close this one and fold the schema change into that branch if keeping them together reviews better. Rebased and green either way. |
Both pending-history buffers read only messages.groupChat.historyLimit, so the documented per-channel and per-account override parsed and did nothing. Resolve account then channel then global, matching the zalouser precedent, and declare the key on both account config types.
Both build kind:group routes, so the session-key resolver applies channels.<id>.historyLimit for them, but their strict schemas rejected it. The contract selector keyed on groupPolicy/groups/groupAllowFrom, which neither publishes, so it could not catch the gap.
Twitch validates as a two-branch union and both branches are closed, so declaring historyLimit only on the account shape left channels.twitch.historyLimit rejected whenever accounts is present. Move it to the shared base so both branches accept it.
…ttermost Covers account over channel root, channel root when the account sets nothing, neither scope set, and an explicit 0 surviving rather than reading as unset.
Drives the spool deliver callback and reads what the handlers were given, so account, channel-root, global, and explicit-zero values are pinned at the boundary rather than only at the resolver.
…window Drives the post handler through the missing-mention drop path, which is where an inbound group post lands in the pending-history window, and asserts the limit handed to it for account, global-fallback, and explicit-zero settings.
The hoisted mock declared only mediaMaxBytes, so reading the history cap the bot hands to the handlers failed check-test-types even though vitest passed.
|
Superseded by merged #129710 (4c4152e). The replacement preserves all seven working root-level channel settings and the real LINE/Mattermost account-aware pending-history fixes, removes unsupported Buzz and inert account options, and preserves credit to @ayaangazali. Generic account-scoped transcript/compaction behavior remains tracked separately in #119326. |
What Problem This Solves
docs/gateway/config-channels.md:841documents the per-channel group history override:Six group-capable bundled channels reject that key, so following the docs refuses the whole config:
buzz,clickclack,line,mattermost,qa-channel,zalo.The reader is provider-agnostic.
src/agents/embedded-agent-runner/history.ts:117-146matchescfg.channelsby normalized provider id with no fixed list, then:163-166returnsproviderConfig.historyLimitforchannelandgroupsessions.Why This Change Was Made
Same owner-boundary shape as the merged #112392 and #117206: the runtime and docs agree on a key, and individual strict schemas do not.
historyLimitis part of the shared common channel account shape and ofReplyRuntimeConfigSchemaShape, which is why the other bundled channels already accept it. These six hand-roll their account schema and omit it.Each gets the same one-line optional non-negative integer beside its existing
configWritesentry, matching the shared shape's definition and the documented0semantics.User Impact
Operators of these six channels can set
channels.<id>.historyLimit(and the per-account form where the channel is multi-account) as documented, including0to disable group history. Purely additive and optional: absent means the existingmessages.groupChat.historyLimitdefault applies exactly as before.Evidence
The contract test derives its channel list from the generated metadata rather than hardcoding, so future group-capable channels are covered automatically. Before the schema change:
After:
What I checked and deliberately did not change:
nostr,raft,reef,sms,tlonandtwitchalso lack the key, but they declare nogroupPolicy,groupsorgroupAllowFrom, so nochannelorgroupsession exists for them and the resolver never reaches that branch. Adding it there would be inert config surface. The contract test applies the same filter rather than hardcoding a list.dmHistoryLimitor the per-DMdms.<id>.historyLimit; those are a separate documented path and are handled in fix(channels): DM-capable channels reject the documented DM history overrides #117306.allOfas an intersection where one closed component still refuses.AI-assisted: researched, written, and validated with Claude Code under my direction. I have read and understand the change.
Review follow-up
P1, account-scope over-claim: fixed by removing the claim.
getHistoryLimitFromSessionKeyreads the root provider object and takes no account id, so asserting that every account schema acceptshistoryLimitwould have advertised precedence the resolver does not implement, exactly the "validates then gets silently ignored" trap you describe. I removed the account-scope assertion and left a comment at the call site saying why, rather than plumbing account identity through the resolver, which is a runtime behavior change and a maintainer call.The key still validates at account scope because it sits on the shared account base alongside its siblings, but this PR no longer claims the resolver honors it. Same resolution I applied on #117306 for
dmHistoryLimit.Real behavior proof, from from-scratch builds on both sides (
rm -rf dist && pnpm build), isolated state dir:Before, clean build of
main(b7f9cd0a016):After, clean build of this branch: