[Fix] Throttle agent event fanout#80335
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98ec3eeef4
ℹ️ 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".
|
Codex review: needs changes before merge. Summary Reproducibility: Partially: current-main source gives a high-confidence path for burst fanout because non-tool agent events broadcast immediately while chat deltas are throttled. I did not execute a live current-main repro in this read-only pass, and the PR body supplies after-fix GatewayClient output for the ordering case. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land the Gateway throttle after preserving scoped wrappers for deprecated config helpers and adding coverage that proves all runtime config helpers run under the owning plugin scope. Do we have a high-confidence way to reproduce the issue? Partially: current-main source gives a high-confidence path for burst fanout because non-tool agent events broadcast immediately while chat deltas are throttled. I did not execute a live current-main repro in this read-only pass, and the PR body supplies after-fix GatewayClient output for the ordering case. Is this the best way to solve the issue? Not yet: the Gateway design is narrow and consistent with the affected fanout path, but the plugin registry update should keep the deprecated load/write wrappers while adding scoped current/mutate/replace wrappers. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against e44b915dbf6b. |
98ec3ee to
240d48c
Compare
97e3934 to
13f6e8a
Compare
13f6e8a to
2f5f574
Compare
2f5f574 to
8071fc3
Compare
3daef21 to
2f5f574
Compare
2f5f574 to
7af45dc
Compare
|
@codex review |
Signed-off-by: samzong <samzong.lu@gmail.com>
Signed-off-by: samzong <samzong.lu@gmail.com>
Signed-off-by: samzong <samzong.lu@gmail.com>
8fe89bf to
5dddb40
Compare
|
Merged via squash.
Thanks @samzong! |
Summary
agenttext events could fan out too frequently while a run was streaming, and the throttle path could drop an intermediate buffered delta when a later post-window delta arrived.chat.abortrequest path to clear agent throttle buffers.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
External contributors must show after-fix evidence from a real OpenClaw setup. Unit tests, mocks, lint, typechecks, snapshots, and CI are supplemental only. Screenshots are encouraged even for CLI, console, text, or log changes; terminal screenshots and copied live output count. Be mindful of private information like IP addresses, API keys, phone numbers, non-public endpoints, or other private details when providing evidence.
GatewayClientconnected as an auto-approved operator device withoperator.read,operator.write, andoperator.adminscopes.pnpm exec tsx -with a temporary proof script that startsstartGatewayServer, connectsGatewayClient, registerssessionKey: "main", emits assistant deltasHel,lo, and!with 50ms/170ms timing around the 150ms throttle window, and asserts the WebSocket client receives all three deltas in order.lo) before the later post-window delta (!), preserving assistant text order and content across the throttle boundary.Hel/lo/!burst could be observed asHel/!.Root Cause (if applicable)
chat.abortrequest path also did not receive the new agent throttle maps, so it could not clear stale assistant/thinking throttle state.agentevent channel, so throttle state needs to distinguish stream family from run lifecycle and be cleaned through every run-abort path.Regression Test Plan (if applicable)
src/gateway/server-chat.agent-events.test.ts,src/gateway/server-methods/chat.abort-authorization.test.ts,src/gateway/chat-abort.test.ts,src/gateway/server-maintenance.test.ts,src/gateway/server-startup-early.test.ts,src/gateway/server-request-context.test.tsUser-visible / Behavior Changes
Gateway clients may receive fewer redundant high-frequency assistant/thinking text
agentevents during streaming bursts, while receiving the same cumulative text content after throttled flushes.Diagram (if applicable)
Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
pnpmscriptsSteps
Expected
Actual
["Hel","lo","!"]with seqs[1,2,3].Test Files 6 passed (6),Tests 85 passed (85).pnpm check:changed,pnpm check:changed --staged,pnpm format:check -- <changed gateway files>, andgit diff --checkpassed locally.Evidence
Human Verification (required)
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations