[superlog] Downgrade agent stream cleanup Redis timeouts from ERROR to WARN#514
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Clean replacement for #499, rebased onto current What changed:
Local verification passed:
|
|
The latest updates on your projects. Learn more about Unkey Deploy
|
| if (!streamBufferWriteFailed) { | ||
| try { | ||
| await markStreamDone(streamKey); | ||
| } catch (cleanupError) { | ||
| warnAgentStreamRedisSideEffect( | ||
| cleanupError, | ||
| "mark_stream_done", | ||
| { | ||
| chatId, | ||
| websiteId: defaultWebsiteId, | ||
| } | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
Replay readers receive no done signal on buffer write failure
When appendStreamChunk fails and streamBufferWriteFailed is set, the loop exits via break and markStreamDone is skipped. Any active Redis replay reader that is polling for stream chunks and waiting on the done marker will never receive it — it must rely entirely on its own external timeout. If replay readers have long or absent timeouts, they will hang until they are garbage-collected or the connection drops. This is the intentional trade-off described in the PR, but it's worth confirming the replay reader side has an appropriate deadline in place.
| export function getAgentStreamErrorLevel( | ||
| failure: AgentStreamBackgroundFailure | ||
| ): "error" | "warn" { | ||
| return failure === "storage_reader" ? "error" : "warn"; | ||
| } |
There was a problem hiding this comment.
getAgentStreamErrorLevel is exported and tested but never called at runtime
No production call site invokes this function — warnAgentStreamRedisSideEffect hardcodes log.warn, and the storage_reader path in agent.ts still calls captureError directly. The classification is correct and verified by tests, but the function is decoupled from the actual dispatching logic. If a new failure kind is added and a caller forgets to also update the dispatch code, the tests would still pass while the wrong log level is emitted.
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!
Summary
Supersedes #499 with a clean branch from current
staging.Verification
Summary by cubic
Downgraded Redis side-effect failures in agent streaming (append/clear/done) from ERROR to WARN to cut noisy alerts, while keeping storage reader failures as ERROR. Also stops writing after the first Redis append failure to avoid per-chunk spam and logs one structured warning.
warnAgentStreamRedisSideEffectand a payload builder; logs viaevlogat WARN with chat/website context.append_stream_chunkfailure; only callmark_stream_doneif no prior failure.storage_readerfailures at ERROR.Written for commit f9ed7e1. Summary will update on new commits.