Repository navigation
feat(gateway): advertise chat attachment limits on hello-ok - #116188
omarshahine merged 2 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:23 PM ET / 17:23 UTC. ClawSweeper reviewWhat this changesThe PR adds optional Merge readinessNo blocking correctness finding surfaced. The current branch adds the requested Gateway capability without changing the authoritative attachment parser, documents the connection-snapshot limitation, and has strong after-fix Gateway proof; it should remain open for the normal exact-head automerge gates rather than be closed or sent to repair. Priority: P3 Review scores
Verification
How this fits togetherGateway clients receive flowchart LR
Client[Gateway client] --> Hello[WebSocket hello]
Hello --> Policy[hello-ok attachment policy]
Config[Operator media limit] --> Resolver[Shared limit resolver]
Resolver --> Policy
Resolver --> Parser[Attachment parser]
Policy --> Preflight[Client upload preflight]
Preflight --> Request[Chat or session request]
Request --> Parser
Parser --> Outcome[Accepted request or server rejection]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +43, Tests +155, Docs +52. Total +250 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the optional two-field policy as a documented connection snapshot, retain parser-side enforcement for all conditional attachment rules, and add any future conditional rejection metadata through a separate typed server error contract rather than overpromising in Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds a new optional Gateway capability rather than repairing a defined current failure. The after-fix proof does provide a high-confidence real Gateway handshake and client-preflight validation path. Is this the best way to solve the issue? Yes. Sharing the limit resolver between the parser and handshake is the narrowest maintainable design, and the docs correctly avoid representing MIME, model, and per-message rules that cannot be truthfully fixed at connection time. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8b994fc9e170. 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 (14 earlier review cycles; latest 8 shown)
|
f1d9689 to
4bbe617
Compare
8494ea1 to
e414ec3
Compare
|
Owner decision: yes, Reasoning, for the record: The field is optional, so every correct client already needs an Scope stays deliberately narrow and I want to keep it that way. Separately, and not a blocker here: the oversize rejection in |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Clients had no way to learn the gateway attachment ceilings, so external clients hardcoded guesses that drifted from server enforcement. Publish the two unconditional decoded-size ceilings on hello-ok policy.attachments from one shared resolver so advertised values cannot drift from the parser. MIME acceptance and per-message counts stay server-side: they depend on the entrypoint, the resolved model, and payload sniffing, so they cannot be stated once per connection. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 17d6c355-8948-4b48-a936-e08b1c8806ef
f0ada49 to
6d504c8
Compare
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
@clawsweeper approve |
|
Merged via squash.
|
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (#117555) fix(cli): explain filtered plugin policy without unsafe recovery (#117556) fix(irc): strip markdown from outbound text (#112961) refactor(plugins): consolidate registry snapshots (#117561) fix(plugins): fail blocked enable commands (#117536) test(secrets): dedupe runtime state fixtures (#117563) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
…#116188) * feat(gateway): advertise chat attachment limits on hello-ok Clients had no way to learn the gateway attachment ceilings, so external clients hardcoded guesses that drifted from server enforcement. Publish the two unconditional decoded-size ceilings on hello-ok policy.attachments from one shared resolver so advertised values cannot drift from the parser. MIME acceptance and per-message counts stay server-side: they depend on the entrypoint, the resolved model, and payload sniffing, so they cannot be stated once per connection. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 17d6c355-8948-4b48-a936-e08b1c8806ef * feat(gateway): advertise chat attachment limits on hello-ok --------- Co-authored-by: Omar Shahine <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Copilot-Session: 17d6c355-8948-4b48-a936-e08b1c8806ef
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (openclaw#117555) fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556) fix(irc): strip markdown from outbound text (openclaw#112961) refactor(plugins): consolidate registry snapshots (openclaw#117561) fix(plugins): fail blocked enable commands (openclaw#117536) test(secrets): dedupe runtime state fixtures (openclaw#117563) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
What Problem This Solves
The gateway accepts attachments on
chat.send,sessions.send, and session-creation initial turns, but never tells clients what it will accept. The real limits are operator-tunable and server-private, so every external client hardcodes a guess that silently disagrees with the server: files get uploaded and rejected after the round-trip, or valid files get blocked locally by a limit that is too tight. Fixes #116144.Why This Change Was Made
Adds an optional
attachmentsdescriptor tohello-ok.policy, next tomaxPayload, carrying the two ceilings a client can act on before sending:Both values come from one shared resolver (
src/gateway/chat-attachment-policy.ts) that the enforcement path also uses, so the advertised numbers cannot drift from what the parser actually rejects.Design notes:
maxImageBytesis the effective minimum, not the raw constant. The configured ceiling is checked first and the image ceiling second, so under a 1 MBmediaMaxMbadvertising the 6 MiB image constant would be a lie. It ismin(maxBytes, MAX_IMAGE_BYTES).acceptNonImageistrueforchat.sendbutfalsefor agent-content and node events; MIME is sniffed from payload content; image support depends on the resolved model; the text-only offload limit drops rather than rejects. None of that can be stated once per connection, so the server stays authoritative and returns a typed rejection.mediaMaxMbis only validated as positive, so a sub-byte value would floor to0and an enormous one would overflow toInfinity(serialized asnull) — either would violate the frame's integer schema and break the handshake.Additive, no protocol version bump: the field is optional in the schema, matching how
allowedSessionVisibilitiesandhasMultipleSessionSharingIdentitieswere previously added to the samepolicyobject. No shipped client validateshello-okagainst the schema at runtime — the reference TS client usesHelloOkas a type only, Swift decodespolicyas[String: AnyCodable], and Android has nopolicymodel — soadditionalProperties: falsehere is an authoring/codegen guard, not a client-enforced wire contract.User Impact
No behavior change to the send path; enforcement is untouched. Clients can now reject an oversized file locally with an accurate limit instead of uploading it and waiting for a server error, or guessing a limit that is wrong in either direction.
Documented in
docs/gateway/protocol.mdanddocs/gateway/clients.md, including the trap thatpolicy.attachmentsis a per-attachment decoded ceiling and never a promise the frame fits: attachments travel as base64, so a 20 MB file is about 26.7 MB on the wire and exceeds the default 25 MiBmaxPayloadon its own. The docs also note the values are a connection-time snapshot and should be re-read on reconnect.Evidence
Local (macOS, this checkout):
node scripts/run-vitest.mjs src/gateway/chat-attachment-policy.test.ts src/gateway/chat-attachments.test.ts src/gateway/server.hello-attachments.test.ts src/gateway/server-node-events.test.ts— 4 files, 112 tests passedpnpm protocol:check— passed; registry check, schema gen, Swift check, Kotlin gen, since guard, andgit diff --exit-codeon the committed generated artifacts all clean (no Swift/Kotlin model drift, as expected for a nestedpolicyfield)pnpm tsgo— cleanpnpm check:test-types— cleanoxfmt+scripts/run-oxlint.mjs src/gateway packages/gateway-protocol— cleanpnpm build— clean, no[INEFFECTIVE_DYNAMIC_IMPORT](the new module sits betweenconnect-hello.tsand the runtime barrel)autoreview --mode local(codex / gpt-5.6-sol / high) — two passes; one finding accepted and fixed (theInfinityoverflow clamp above), one rejected with the compatibility evidence cited in the previous sectionNew coverage:
src/gateway/chat-attachment-policy.test.ts— configured value, default fallback, invalid-value rejection, sub-byte clamp, overflow clamp, andmin()behavior in both directionssrc/gateway/server.hello-attachments.test.ts— real WebSocket handshake assertinghello-ok.policy.attachmentsreflects a configuredmediaMaxMb, and that the image ceiling clamps down when the configured ceiling is smallersrc/gateway/chat-attachments.test.ts— drift guard tying the advertised numbers to the parser's actual accept/reject boundariesLive gateway proof
Isolated gateway on a scratch state dir (
--port 18991 --auth none --bind loopback), driven by an external client built on the shipped reference client (@openclaw/gateway-client) that reads the advertised policy and preflights files locally before any upload.Run 1 — operator config
agents.defaults.mediaMaxMb: 3(proves the config ceiling is honored and that the image ceiling clamps down below the 6 MiB constant):Run 2 — default config (proves the two ceilings differ, and shows the base64/
maxPayloadinteraction a client must also check):The 6 MiB image ceiling and 20 MiB other-file ceiling match the enforcement constants exercised by the drift-guard tests, and the 3 MiB run matches the operator's configured value — the numbers a client sees are the numbers the parser enforces.
Rebased on
origin/mainafter the initial review.