Skip to content

🔨 chore: add GatewayStreamNotifier for Agent Gateway WebSocket push#13603

Merged
arvinxx merged 6 commits intocanaryfrom
feat/agent-gateway-notifier
Apr 7, 2026
Merged

🔨 chore: add GatewayStreamNotifier for Agent Gateway WebSocket push#13603
arvinxx merged 6 commits intocanaryfrom
feat/agent-gateway-notifier

Conversation

@arvinxx
Copy link
Copy Markdown
Member

@arvinxx arvinxx commented Apr 7, 2026

Summary

  • Add GatewayStreamNotifier decorator that wraps IStreamEventManager to push events to the Agent Gateway via HTTP (fire-and-forget)
  • Update createStreamEventManager factory to auto-wrap with gateway notifier when AGENT_GATEWAY_SERVICE_TOKEN is configured
  • Redis SSE remains the primary event channel; the gateway is an additive push layer for WebSocket delivery

How it works

AgentRuntimeService.executeStep()
  → publishStreamEvent() / publishStreamChunk() / etc.
    → GatewayStreamNotifier
      ├→ inner.publish*()  [Redis Streams, unchanged]
      └→ HTTP POST → agent-gateway/api/operations/push-event  [new, fire-and-forget]

Environment Variables

Variable Description
AGENT_GATEWAY_SERVICE_TOKEN Enables gateway push when set
AGENT_GATEWAY_URL Gateway URL (default: https://agent-gateway.lobehub.com)

Test plan

  • Type check passes
  • Verified with local dev server + CLI agent execution
  • Confirmed events arrive at gateway (/api/operations/status returns completed)
  • Existing Redis SSE path unaffected (CLI still receives events via SSE)

Fixes LOBE-6723

🤖 Generated with Claude Code

Add a decorator that wraps IStreamEventManager to additionally push
events to the Agent Gateway via HTTP (fire-and-forget). When
AGENT_GATEWAY_SERVICE_TOKEN is configured, the factory automatically
wraps the base stream manager with the gateway notifier. Redis SSE
remains the primary event channel; the gateway is an additive push
layer for WebSocket delivery.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Apr 7, 2026 3:46am

Request Review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot
Copy link
Copy Markdown
Member

@nekomeowww - This PR adds a GatewayStreamNotifier for Agent Gateway WebSocket push, touching backend server modules in src/server/modules/AgentRuntime/. Please take a look.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.61%. Comparing base (5b03f00) to head (cbc892f).
⚠️ Report is 10 commits behind head on canary.

Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #13603      +/-   ##
==========================================
+ Coverage   66.58%   66.61%   +0.03%     
==========================================
  Files        1999     2000       +1     
  Lines      165955   166107     +152     
  Branches    19193    19215      +22     
==========================================
+ Hits       110503   110659     +156     
+ Misses      55328    55324       -4     
  Partials      124      124              
Flag Coverage Δ
app 58.48% <100.00%> (+0.05%) ⬆️
database 92.60% <ø> (ø)
packages/agent-runtime 88.98% <ø> (ø)
packages/context-engine 85.51% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.66% <ø> (ø)
packages/prompts 65.80% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.02% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 67.10% <ø> (ø)
Services 51.55% <ø> (ø)
Server 66.08% <100.00%> (+0.12%) ⬆️
Libs 51.03% <ø> (ø)
Utils 91.01% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 388fae1ee2

ℹ️ 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".

Ensure the decorator always delegates to the inner stream event manager
first, gateway failure never drops Redis events, and the factory
correctly wraps/skips based on AGENT_GATEWAY_SERVICE_TOKEN.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 5s AbortSignal timeout on every gateway POST to prevent hanging sockets
- Max 20 inflight requests; excess silently dropped with a debug log
- Use url-join for URL construction instead of string concatenation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
arvinxx and others added 2 commits April 7, 2026 11:35
Read AGENT_GATEWAY_SERVICE_TOKEN and AGENT_GATEWAY_URL from the
validated appEnv config instead of raw process.env.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arvinxx arvinxx changed the title ✨ feat: add GatewayStreamNotifier for Agent Gateway WebSocket push 🔨 chore: add GatewayStreamNotifier for Agent Gateway WebSocket push Apr 7, 2026
@arvinxx arvinxx merged commit 6c9cbb0 into canary Apr 7, 2026
34 checks passed
@arvinxx arvinxx deleted the feat/agent-gateway-notifier branch April 7, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants