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

推荐订阅源

Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
宝玉的分享
宝玉的分享
量子位
Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
J
Java Code Geeks
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
S
SegmentFault 最新的问题
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
小众软件
小众软件
The Cloudflare Blog
Y
Y Combinator Blog
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
IT之家
IT之家

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(hooks): reject slug-generator error payloads · opencl...
openclaw-clo · 2026-06-14 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -116,4 +116,66 @@ describe("generateSlugViaLLM", () => {

116116

expect(options.provider).toBe("openai");

117117

expect(options.model).toBe("gpt-5.5");

118118

});

119+
120+

it("rejects error payloads before slugifying them into memory filenames", async () => {

121+

runEmbeddedAgentMock.mockResolvedValueOnce({

122+

payloads: [

123+

{

124+

isError: true,

125+

text: "Provider API error (429): quota exceeded",

126+

},

127+

],

128+

});

129+
130+

await expect(

131+

generateSlugViaLLM({

132+

sessionContent: "hello",

133+

cfg: {} as OpenClawConfig,

134+

}),

135+

).resolves.toBeNull();

136+

});

137+
138+

it.each([

139+

'HTTP 400: {"error":{"type":"insufficient_quota","message":"Your account has insufficient quota balance."}}',

140+

"Authentication failed: invalid API key",

141+

"Missing token or projectId in Google Cloud credentials. Use /login to re-authenticate.",

142+

"Provider API error (429): quota exceeded",

143+

])("rejects provider/auth/quota error text before slugifying: %s", async (text) => {

144+

runEmbeddedAgentMock.mockResolvedValueOnce({

145+

payloads: [{ text }],

146+

});

147+
148+

await expect(

149+

generateSlugViaLLM({

150+

sessionContent: "hello",

151+

cfg: {} as OpenClawConfig,

152+

}),

153+

).resolves.toBeNull();

154+

});

155+
156+

it("keeps normal short slugs that mention auth work", async () => {

157+

runEmbeddedAgentMock.mockResolvedValueOnce({

158+

payloads: [{ text: "auth-refresh" }],

159+

});

160+
161+

await expect(

162+

generateSlugViaLLM({

163+

sessionContent: "hello",

164+

cfg: {} as OpenClawConfig,

165+

}),

166+

).resolves.toBe("auth-refresh");

167+

});

168+
169+

it("strips leading and trailing dashes after truncating the slug", async () => {

170+

runEmbeddedAgentMock.mockResolvedValueOnce({

171+

payloads: [{ text: "12345678901234567890123456789 trailing" }],

172+

});

173+
174+

await expect(

175+

generateSlugViaLLM({

176+

sessionContent: "hello",

177+

cfg: {} as OpenClawConfig,

178+

}),

179+

).resolves.toBe("12345678901234567890123456789");

180+

});

119181

});

Original file line numberDiff line numberDiff line change

@@ -16,9 +16,17 @@ import { resolveDefaultModelForAgent } from "../agents/model-selection.js";

1616

import { resolveAgentTimeoutMs } from "../agents/timeout.js";

1717

import type { OpenClawConfig } from "../config/types.openclaw.js";

1818

import { createSubsystemLogger } from "../logging/subsystem.js";

19+

import {

20+

extractLeadingHttpStatus,

21+

parseApiErrorPayload,

22+

} from "../shared/assistant-error-format.js";

1923
2024

const log = createSubsystemLogger("llm-slug-generator");

2125

const DEFAULT_SLUG_GENERATOR_TIMEOUT_MS = 15_000;

26+

const PROVIDER_ERROR_PREFIX_RE =

27+

/^(?:provider\s+)?(?:api|llm|model|openai|anthropic|codex|gateway)\s+(?:request\s+)?(?:error|failed|failure)\b/i;

28+

const PROVIDER_ERROR_DETAIL_RE =

29+

/\b(?:insufficient[_ -]?quota|quota (?:exceeded|exhausted)|exceeded your current quota|payment required|insufficient credits|credit balance|insufficient[_ -]?(?:balance|funds)|rate[_ -]?limit(?:ed)?|too many requests|invalid[_ -]?api[_ -]?key|incorrect api key|authentication failed|oauth token refresh failed|missing (?:token|projectid|credentials)|google cloud credentials|re-?authenticate|unauthorized|forbidden|permission_error|billing hard limit|spend(?:ing)? limit)\b/i;

2230
2331

function resolveSlugGeneratorTimeoutMs(cfg: OpenClawConfig): number {

2432

const configuredTimeoutSeconds = cfg.agents?.defaults?.timeoutSeconds;

@@ -28,6 +36,37 @@ function resolveSlugGeneratorTimeoutMs(cfg: OpenClawConfig): number {

2836

return resolveAgentTimeoutMs({ cfg });

2937

}

3038
39+

function isErrorSlugPayload(payload: { text?: string; isError?: boolean } | undefined): boolean {

40+

if (!payload) {

41+

return false;

42+

}

43+

if (payload.isError === true) {

44+

return true;

45+

}

46+

const text = payload.text?.trim();

47+

if (!text) {

48+

return false;

49+

}

50+

if (parseApiErrorPayload(text)) {

51+

return true;

52+

}

53+

const leadingStatus = extractLeadingHttpStatus(text);

54+

if (leadingStatus) {

55+

if ([401, 402, 403, 429].includes(leadingStatus.code)) {

56+

return true;

57+

}

58+

if (

59+

leadingStatus.code === 400 &&

60+

(parseApiErrorPayload(leadingStatus.rest) ||

61+

PROVIDER_ERROR_PREFIX_RE.test(leadingStatus.rest) ||

62+

PROVIDER_ERROR_DETAIL_RE.test(leadingStatus.rest))

63+

) {

64+

return true;

65+

}

66+

}

67+

return PROVIDER_ERROR_PREFIX_RE.test(text) || PROVIDER_ERROR_DETAIL_RE.test(text);

68+

}

69+
3170

/**

3271

* Generate a short 1-2 word filename slug from session content using LLM

3372

*/

@@ -80,14 +119,19 @@ Reply with ONLY the slug, nothing else. Examples: "vendor-pitch", "api-design",

80119
81120

// Extract text from payloads

82121

if (result.payloads && result.payloads.length > 0) {

83-

const text = result.payloads[0]?.text;

122+

const payload = result.payloads[0];

123+

const text = payload?.text;

84124

if (text) {

125+

if (isErrorSlugPayload(payload)) {

126+

return null;

127+

}

85128

// Clean up the response - extract just the slug

86129

const slug = normalizeLowercaseStringOrEmpty(text)

87130

.replace(/[^a-z0-9-]/g, "-")

88131

.replace(/-+/g, "-")

89-

.replace(/^-|-$/g, "")

90-

.slice(0, 30); // Max 30 chars

132+

.replace(/^-+|-+$/g, "")

133+

.slice(0, 30)

134+

.replace(/^-+|-+$/g, ""); // Max 30 chars

91135
92136

return slug || null;

93137

}