Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(scheduler): append actionable hint to MCP utility-model errors (#3327)

Battleplus2cb28593655a
diff --git a/packages/lizi-mcps/src/scheduler/errors.test.ts b/packages/lizi-mcps/src/scheduler/errors.test.ts
index 9d1b9312b6..be437bf97e 100644
--- a/packages/lizi-mcps/src/scheduler/errors.test.ts
+++ b/packages/lizi-mcps/src/scheduler/errors.test.ts
@@ -13,6 +13,23 @@ describe('classifySchedulerError utility model diagnostics', () => {
new Error(`[${code}] safe diagnostic`),
);
- expect(result).toEqual({ code, message: `[${code}] safe diagnostic` });
+ expect(result.code).toBe(code);
+ // Message must contain the original diagnostic
+ expect(result.message).toContain(`[${code}] safe diagnostic`);
+ });
+
+ it.each([
+ 'UTILITY_MODEL_NO_CANDIDATE',
+ 'UTILITY_MODEL_ALL_CANDIDATES_FAILED',
+ 'UTILITY_MODEL_EMPTY_RESPONSE',
+ 'UTILITY_MODEL_TIMEOUT',
+ ] as const)('appends actionable hint for %s so agents can suggest passing script', (code) => {
+ const result = classifySchedulerError(
+ new Error(`[${code}] all candidates failed`),
+ );
+
+ // Must hint that passing "script" bypasses generation (#3317)
+ expect(result.message).toContain('script');
+ expect(result.message).toContain('bypass');
});
});
diff --git a/packages/lizi-mcps/src/scheduler/errors.ts b/packages/lizi-mcps/src/scheduler/errors.ts
index 2e4f16bdd0..31a0e607b7 100644
--- a/packages/lizi-mcps/src/scheduler/errors.ts
+++ b/packages/lizi-mcps/src/scheduler/errors.ts
@@ -35,7 +35,21 @@ export function classifySchedulerError(err: unknown): SchedulerToolError {
const utilityCode = /^\[(UTILITY_MODEL_(?:NO_CANDIDATE|ALL_CANDIDATES_FAILED|EMPTY_RESPONSE|TIMEOUT))\]/
.exec(message)?.[1];
if (utilityCode) {
- return { code: utilityCode as SchedulerToolErrorCode, message };
+ // Append actionable hint so the MCP caller (agent) can suggest a workaround
+ // instead of silently retrying the same failing utility-model chain.
+ // See #3317.
+ const hints: Record<string, string> = {
+ UTILITY_MODEL_ALL_CANDIDATES_FAILED:
+ ' All utility-model candidates failed. You can bypass generation by passing the "script" parameter directly with a hand-written check script.',
+ UTILITY_MODEL_NO_CANDIDATE:
+ ' No utility-model candidate is configured. You can bypass generation by passing the "script" parameter directly.',
+ UTILITY_MODEL_TIMEOUT:
+ ' The utility-model call timed out. You can bypass generation by passing the "script" parameter directly.',
+ UTILITY_MODEL_EMPTY_RESPONSE:
+ ' The utility-model returned an empty response. You can bypass generation by passing the "script" parameter directly.',
+ };
+ const hint = hints[utilityCode] ?? '';
+ return { code: utilityCode as SchedulerToolErrorCode, message: message + hint };
}
if (/scheduler not started/i.test(message)) {
return { code: 'SCHEDULER_NOT_READY', message };