Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(feature-flags): add a mobile rollout flag for the multiplexed gateway (#20888)

Tsukiac3350f07f7e
diff --git a/docs/self-hosting/advanced/feature-flags.mdx b/docs/self-hosting/advanced/feature-flags.mdx
index 2cdbbf42bfe..fd2881f4751 100644
--- a/docs/self-hosting/advanced/feature-flags.mdx
+++ b/docs/self-hosting/advanced/feature-flags.mdx
@@ -43,6 +43,7 @@ You can achieve various feature combinations using the above configuration synta
| `api_key_manage` | Controls access to API key management page (/profile/apikey). | Disabled |
| `agent_share` | Gates new or re-enabled interactive Agent shares. Requires deployment support; see the boundary below. | Disabled |
| `agent_gateway_mux` | Routes agent runs over one multiplexed gateway socket per user. Requires a gateway that serves `/v2/ws` (`AGENT_GATEWAY_PROTOCOL=2`). | Disabled |
+| `agent_gateway_mux_mobile` | LobeHub Mobile rollout switch for the multiplexed gateway socket and protocol-v2 payloads; independent from `agent_gateway_mux`. Requires a gateway that serves `/v2/ws`. | Disabled |
| `agent_llm_relay` | Runs LLM calls for model providers only the user's device can reach (local Ollama / LM Studio, private-network endpoints) on the client that started the run, while the agent loop stays on the server. Requires an open LobeHub client for such runs. | Disabled |
| `dashboard` | Dashboards: the home and project dashboard pages, the widget Portal, in-chat widget previews and the `lobe-dashboard` agent tool that builds monitoring widgets. When off, these are hidden and the widget / dashboard APIs return FORBIDDEN; widgets already published keep refreshing on their schedule. | Disabled |
| `edit_agent` | Allows users to edit assistants. | Enabled |
diff --git a/docs/self-hosting/advanced/feature-flags.zh-CN.mdx b/docs/self-hosting/advanced/feature-flags.zh-CN.mdx
index d4f93b5c856..b3ff1c52463 100644
--- a/docs/self-hosting/advanced/feature-flags.zh-CN.mdx
+++ b/docs/self-hosting/advanced/feature-flags.zh-CN.mdx
@@ -41,6 +41,7 @@ tags:
| `api_key_manage` | 控制 API 密钥管理页面 (/profile/apikey) 的访问。 | 关闭 |
| `agent_share` | 控制新建或重新启用交互式助理分享;还需部署支持,详见下文边界。 | 关闭 |
| `agent_gateway_mux` | 让助理运行共用一条按用户复用的网关连接;需要网关提供 `/v2/ws`(`AGENT_GATEWAY_PROTOCOL=2`)。 | 关闭 |
+| `agent_gateway_mux_mobile` | LobeHub Mobile 使用多路复用网关连接与 v2 协议载荷的灰度开关,独立于 `agent_gateway_mux`;需要网关提供 `/v2/ws`。 | 关闭 |
| `agent_llm_relay` | 对只有用户设备能访问的模型服务商(本地 Ollama / LM Studio、私网地址),由发起运行的客户端执行单次模型调用,助理循环仍在服务端运行;这类运行需要有打开的 LobeHub 客户端。 | 关闭 |
| `dashboard` | 看板:首页与项目看板页面、监控组件侧边栏、对话内的组件预览,以及用于搭建监控组件的 `lobe-dashboard` 助理工具。关闭时以上入口均隐藏,组件与看板相关接口返回 FORBIDDEN;已发布的组件仍按计划刷新。 | 关闭 |
| `edit_agent` | 允许用户编辑助手。 | 开启 |
diff --git a/packages/app-config/src/featureFlags/schema.test.ts b/packages/app-config/src/featureFlags/schema.test.ts
index 889d3a6b4d6..d752907ac3a 100644
--- a/packages/app-config/src/featureFlags/schema.test.ts
+++ b/packages/app-config/src/featureFlags/schema.test.ts
@@ -193,6 +193,26 @@ describe('mapFeatureFlagsEnvToState', () => {
expect(mapFeatureFlagsEnvToState(config).enableAgentShare).toBe(false);
});
+ it('should gate the mobile gateway mux independently from the Web flag', () => {
+ expect(DEFAULT_FEATURE_FLAGS.agent_gateway_mux_mobile).toBe(false);
+ expect(mapFeatureFlagsEnvToState(DEFAULT_FEATURE_FLAGS, 'user-1').enableGatewayMuxMobile).toBe(
+ false,
+ );
+
+ const everyone = mapFeatureFlagsEnvToState({ agent_gateway_mux_mobile: true }, 'user-1');
+ expect(everyone.enableGatewayMuxMobile).toBe(true);
+ expect(everyone.enableGatewayMux).toBeFalsy();
+
+ const config = { agent_gateway_mux_mobile: ['user-123'] };
+ expect(mapFeatureFlagsEnvToState(config, 'user-123').enableGatewayMuxMobile).toBe(true);
+ expect(mapFeatureFlagsEnvToState(config, 'user-456').enableGatewayMuxMobile).toBe(false);
+ expect(mapFeatureFlagsEnvToState(config).enableGatewayMuxMobile).toBe(false);
+
+ const webOnly = mapFeatureFlagsEnvToState({ agent_gateway_mux: true }, 'user-1');
+ expect(webOnly.enableGatewayMux).toBe(true);
+ expect(webOnly.enableGatewayMuxMobile).toBeFalsy();
+ });
+
it('should keep dashboards off by default and enable them per user or globally', () => {
expect(DEFAULT_FEATURE_FLAGS.dashboard).toBe(false);
expect(mapFeatureFlagsEnvToState(DEFAULT_FEATURE_FLAGS, 'user-1').enableDashboard).toBe(false);
diff --git a/packages/app-config/src/featureFlags/schema.ts b/packages/app-config/src/featureFlags/schema.ts
index 3faca6445b2..62c86e2b8a9 100644
--- a/packages/app-config/src/featureFlags/schema.ts
+++ b/packages/app-config/src/featureFlags/schema.ts
@@ -50,6 +50,13 @@ export const FeatureFlagsSchema = z.object({
*/
agent_gateway_mux: FeatureFlagValue.optional(),
+ /**
+ * LobeHub Mobile rollout switch for the multiplexed gateway socket and
+ * protocol-v2 payloads. Independent from `agent_gateway_mux`: flipping one
+ * never changes the other client. Array values are user ids.
+ */
+ agent_gateway_mux_mobile: FeatureFlagValue.optional(),
+
/**
* Rollout gate for relaying LLM calls to the user's device: a model provider
* only that device can reach (a local Ollama / LM Studio, a private-network
@@ -133,6 +140,7 @@ export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = {
// Off until an admin publishes a user allowlist or flips it to true; the
// v1 socket stays the default everywhere until then.
agent_gateway_mux: false,
+ agent_gateway_mux_mobile: false,
// Off until the client executor ships everywhere; allowlist first.
agent_llm_relay: false,
@@ -172,6 +180,7 @@ export const mapFeatureFlagsEnvToState = (
enableAgentShare: evaluateFeatureFlag(config.agent_share, userId),
enableGatewayMux: evaluateFeatureFlag(config.agent_gateway_mux, userId),
+ enableGatewayMuxMobile: evaluateFeatureFlag(config.agent_gateway_mux_mobile, userId),
enableLlmRelay: evaluateFeatureFlag(config.agent_llm_relay, userId),
enableDashboard: evaluateFeatureFlag(config.dashboard, userId),
showProvider: evaluateFeatureFlag(config.provider_settings, userId),
diff --git a/packages/types/src/serverConfig.ts b/packages/types/src/serverConfig.ts
index 1b9a780cf4e..3ac5a21d141 100644
--- a/packages/types/src/serverConfig.ts
+++ b/packages/types/src/serverConfig.ts
@@ -39,6 +39,11 @@ export type IFeatureFlagsState = {
* `GlobalServerConfig.agentGatewayProtocol === 2`.
*/
enableGatewayMux: boolean | undefined;
+ /**
+ * LobeHub Mobile rollout gate for the multiplexed gateway socket and
+ * protocol-v2 payloads; independent from `enableGatewayMux`.
+ */
+ enableGatewayMuxMobile: boolean | undefined;
enableKnowledgeBase: boolean | undefined;
/**
* Rollout gate for relaying LLM calls of device-only model providers to the