惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The GitHub Blog
The GitHub Blog
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
腾讯CDC
博客园 - 聂微东
The Cloudflare Blog
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
Last Week in AI
Last Week in AI
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(gateway): allow chat.abort to stop agent RPC runs · o...
bitloi · 2026-04-25 · via Recent Commits to openclaw:main

@@ -1,5 +1,7 @@

11

import { isAbortRequestText } from "../auto-reply/reply/abort-primitives.js";

223+

const DEFAULT_CHAT_RUN_ABORT_GRACE_MS = 60_000;

4+35

export type ChatAbortControllerEntry = {

46

controller: AbortController;

57

sessionId: string;

@@ -8,6 +10,20 @@ export type ChatAbortControllerEntry = {

810

expiresAtMs: number;

911

ownerConnId?: string;

1012

ownerDeviceId?: string;

13+

/**

14+

* Which RPC owns this registration. Absent (undefined) is treated as

15+

* `"chat-send"` so pre-existing callers that constructed entries without

16+

* a kind keep their behavior. Consumers that need "chat.send specifically

17+

* is active" must check `kind !== "agent"`, not just `.has(runId)`.

18+

*/

19+

kind?: "chat-send" | "agent";

20+

};

21+22+

export type RegisteredChatAbortController = {

23+

controller: AbortController;

24+

registered: boolean;

25+

entry?: ChatAbortControllerEntry;

26+

cleanup: () => void;

1127

};

12281329

export function isChatStopCommandText(text: string): boolean {

@@ -21,14 +37,75 @@ export function resolveChatRunExpiresAtMs(params: {

2137

minMs?: number;

2238

maxMs?: number;

2339

}): number {

24-

const { now, timeoutMs, graceMs = 60_000, minMs = 2 * 60_000, maxMs = 24 * 60 * 60_000 } = params;

40+

const {

41+

now,

42+

timeoutMs,

43+

graceMs = DEFAULT_CHAT_RUN_ABORT_GRACE_MS,

44+

minMs = 2 * 60_000,

45+

maxMs = 24 * 60 * 60_000,

46+

} = params;

2547

const boundedTimeoutMs = Math.max(0, timeoutMs);

2648

const target = now + boundedTimeoutMs + graceMs;

2749

const min = now + minMs;

2850

const max = now + maxMs;

2951

return Math.min(max, Math.max(min, target));

3052

}

315354+

export function resolveAgentRunExpiresAtMs(params: {

55+

now: number;

56+

timeoutMs: number;

57+

graceMs?: number;

58+

}): number {

59+

const graceMs = Math.max(0, params.graceMs ?? DEFAULT_CHAT_RUN_ABORT_GRACE_MS);

60+

return resolveChatRunExpiresAtMs({

61+

now: params.now,

62+

timeoutMs: params.timeoutMs,

63+

graceMs,

64+

minMs: graceMs,

65+

maxMs: Math.max(0, params.timeoutMs) + graceMs,

66+

});

67+

}

68+69+

export function registerChatAbortController(params: {

70+

chatAbortControllers: Map<string, ChatAbortControllerEntry>;

71+

runId: string;

72+

sessionId: string;

73+

sessionKey?: string | null;

74+

timeoutMs: number;

75+

ownerConnId?: string;

76+

ownerDeviceId?: string;

77+

kind?: ChatAbortControllerEntry["kind"];

78+

now?: number;

79+

expiresAtMs?: number;

80+

}): RegisteredChatAbortController {

81+

const controller = new AbortController();

82+

const cleanup = () => {

83+

const entry = params.chatAbortControllers.get(params.runId);

84+

if (entry?.controller === controller) {

85+

params.chatAbortControllers.delete(params.runId);

86+

}

87+

};

88+89+

if (!params.sessionKey || params.chatAbortControllers.has(params.runId)) {

90+

return { controller, registered: false, cleanup };

91+

}

92+93+

const now = params.now ?? Date.now();

94+

const entry: ChatAbortControllerEntry = {

95+

controller,

96+

sessionId: params.sessionId,

97+

sessionKey: params.sessionKey,

98+

startedAtMs: now,

99+

expiresAtMs:

100+

params.expiresAtMs ?? resolveChatRunExpiresAtMs({ now, timeoutMs: params.timeoutMs }),

101+

ownerConnId: params.ownerConnId,

102+

ownerDeviceId: params.ownerDeviceId,

103+

kind: params.kind,

104+

};

105+

params.chatAbortControllers.set(params.runId, entry);

106+

return { controller, registered: true, entry, cleanup };

107+

}

108+32109

export type ChatAbortOps = {

33110

chatAbortControllers: Map<string, ChatAbortControllerEntry>;

34111

chatRunBuffers: Map<string, string>;