fix(gateway): skip media sidecar for unrelated HTTP routes

This commit is contained in:
Vincent Koc
2026-05-05 14:43:19 -07:00
parent 8aa7b7a4ca
commit d38e30e02c
2 changed files with 21 additions and 14 deletions

View File

@@ -88,6 +88,7 @@ Docs: https://docs.openclaw.ai
- Discord/streaming: show live reasoning text in progress drafts instead of a bare `Reasoning` status line.
- Doctor/status: warn when `OPENCLAW_GATEWAY_TOKEN` would shadow a different active `gateway.auth.token` source for local CLI commands, while avoiding false positives when config points at the same env token. Fixes #74271. Thanks @yelog.
- Gateway/HTTP: avoid loading managed outgoing-image media handlers for unrelated requests, so disabled OpenAI-compatible routes return 404 without waiting on lazy media sidecars. Thanks @vincentkoc.
- Gateway/OpenAI-compatible: send the assistant role SSE chunk as soon as streaming chat-completion headers are accepted, so cold agent setup cannot leave `/v1/chat/completions` clients with a bodyless 200 response until their idle timeout fires.
- Agents/media: avoid direct generated-media completion fallback while the announce-agent run is still pending, so async video and music completions do not duplicate raw media messages. (#77754)
- TUI/sessions: bound the session picker to recent rows and use exact lookup-style refreshes for the active session, so dusty stores no longer make TUI hydrate weeks-old transcripts before becoming responsive. Thanks @vincentkoc.

View File

@@ -214,6 +214,10 @@ function isToolsInvokePath(pathname: string): boolean {
return pathname === "/tools/invoke";
}
function isManagedOutgoingImagePath(pathname: string): boolean {
return pathname.startsWith("/api/chat/media/outgoing/");
}
function isSessionKillPath(pathname: string): boolean {
return /^\/sessions\/[^/]+\/kill$/.test(pathname);
}
@@ -724,20 +728,22 @@ export function createGatewayHttpServer(opts: {
}),
);
requestStages.push({
name: "chat-managed-image-media",
run: async () =>
(await getManagedImageAttachmentsModule()).handleManagedOutgoingImageHttpRequest(
req,
res,
{
auth: resolvedAuth,
trustedProxies,
allowRealIpFallback,
rateLimiter,
},
),
});
if (isManagedOutgoingImagePath(scopedRequestPath)) {
requestStages.push({
name: "chat-managed-image-media",
run: async () =>
(await getManagedImageAttachmentsModule()).handleManagedOutgoingImageHttpRequest(
req,
res,
{
auth: resolvedAuth,
trustedProxies,
allowRealIpFallback,
rateLimiter,
},
),
});
}
if (controlUiEnabled) {
requestStages.push({