refactor: centralize agent run pending status · openclaw/openclaw@7188e4f
steipete
·
2026-05-06
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -70,6 +70,7 @@ Docs: https://docs.openclaw.ai
|
70 | 70 | ### Fixes |
71 | 71 | |
72 | 72 | - 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. |
| 73 | +- 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) |
73 | 74 | - 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. |
74 | 75 | - Doctor/gateway: report recent supervisor restart handoffs in `openclaw doctor --deep`, using the installed service environment when available so service-managed clean exits are visible in guided diagnostics. Thanks @shakkernerd. |
75 | 76 | - Gateway/status: show recent supervisor restart handoffs in `openclaw gateway status --deep`, including JSON details, so clean service-managed restarts are reported as restart handoffs instead of opaque stopped-service diagnostics. Thanks @shakkernerd. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,7 @@ import { normalizeAccountId } from "../routing/session-key.js";
|
6 | 6 | import { defaultRuntime } from "../runtime.js"; |
7 | 7 | import { deriveSessionChatTypeFromKey } from "../sessions/session-chat-type-shared.js"; |
8 | 8 | import { isCronSessionKey } from "../sessions/session-key-utils.js"; |
| 9 | +import { isNonTerminalAgentRunStatus } from "../shared/agent-run-status.js"; |
9 | 10 | import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js"; |
10 | 11 | import { |
11 | 12 | mergeDeliveryContext, |
@@ -694,7 +695,7 @@ function isGatewayAgentRunPending(response: unknown): boolean {
|
694 | 695 | return false; |
695 | 696 | } |
696 | 697 | const status = (response as { status?: unknown }).status; |
697 | | -return status === "accepted" || status === "in_flight" || status === "started"; |
| 698 | +return isNonTerminalAgentRunStatus(status); |
698 | 699 | } |
699 | 700 | |
700 | 701 | function inferCompletionChatType(params: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { isNonTerminalAgentRunStatus } from "../../shared/agent-run-status.js"; |
1 | 2 | import { setSafeTimeout } from "../../utils/timer-delay.js"; |
2 | 3 | import type { DedupeEntry } from "../server-shared.js"; |
3 | 4 | |
@@ -91,7 +92,7 @@ function readTerminalSnapshotFromDedupeEntry(entry: DedupeEntry): AgentWaitTermi
|
91 | 92 | } |
92 | 93 | | undefined; |
93 | 94 | const status = typeof payload?.status === "string" ? payload.status : undefined; |
94 | | -if (status === "accepted" || status === "started" || status === "in_flight") { |
| 95 | +if (isNonTerminalAgentRunStatus(status)) { |
95 | 96 | return null; |
96 | 97 | } |
97 | 98 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { isNonTerminalAgentRunStatus } from "./agent-run-status.js"; |
| 3 | + |
| 4 | +describe("isNonTerminalAgentRunStatus", () => { |
| 5 | +it.each(["accepted", "started", "in_flight"])("recognizes %s as non-terminal", (status) => { |
| 6 | +expect(isNonTerminalAgentRunStatus(status)).toBe(true); |
| 7 | +}); |
| 8 | + |
| 9 | +it.each(["ok", "error", "timeout", "queued", "", null, undefined, 1, {}, []])( |
| 10 | +"does not recognize %s as non-terminal", |
| 11 | +(status) => { |
| 12 | +expect(isNonTerminalAgentRunStatus(status)).toBe(false); |
| 13 | +}, |
| 14 | +); |
| 15 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +const NON_TERMINAL_AGENT_RUN_STATUSES = new Set(["accepted", "started", "in_flight"]); |
| 2 | + |
| 3 | +export function isNonTerminalAgentRunStatus(status: unknown): boolean { |
| 4 | +return typeof status === "string" && NON_TERMINAL_AGENT_RUN_STATUSES.has(status); |
| 5 | +} |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。