mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-04 16:51:36 +00:00
* fix(anthropic): handle max_turns stop reason and surface retry-limit details to users * fix(anthropic): classify max_turns as length-limited * fix(anthropic): preserve max_turns diagnostics * fix(anthropic): preserve max_turns side-effect warning * fix(claude-cli): max-turn stops omit run and recovery context * fix(claude-cli): preserve max-turn terminal boundaries * refactor(claude-cli): centralize terminal error conversion Co-authored-by: zhang-guiping <zhang.guiping@xydigit.com> * fix(claude-cli): warn before retrying max-turn failures Co-authored-by: zhang-guiping <zhang.guiping@xydigit.com> * fix(claude-cli): preserve max-turn stops through wrappers Co-authored-by: zhang-guiping <zhang.guiping@xydigit.com> * fix(claude-cli): prioritize terminal max-turn output --------- Co-authored-by: 张贵萍 <zhangguiping@zhangguipingdeMac-mini.local> Co-authored-by: Peter Steinberger <steipete@gmail.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { formatCliOutputError, type CliOutput } from "../cli-output.js";
|
|
import { classifyFailoverReason } from "../embedded-agent-helpers.js";
|
|
import { FailoverError, resolveFailoverStatus } from "../failover-error.js";
|
|
|
|
export function createCliOutputFailoverError(params: {
|
|
output: CliOutput;
|
|
provider: string;
|
|
model: string;
|
|
runId?: string;
|
|
sessionId?: string;
|
|
lane?: string;
|
|
}): FailoverError | undefined {
|
|
if (!params.output.errorText) {
|
|
return undefined;
|
|
}
|
|
const message = formatCliOutputError(params.output, {
|
|
runId: params.runId,
|
|
sessionId: params.sessionId,
|
|
});
|
|
const reason = classifyFailoverReason(message, { provider: params.provider }) ?? "unknown";
|
|
const code =
|
|
params.output.terminalFailure?.reason === "max_turns"
|
|
? "cli_max_turns"
|
|
: reason === "context_overflow"
|
|
? "cli_context_overflow"
|
|
: undefined;
|
|
return new FailoverError(message, {
|
|
reason,
|
|
provider: params.provider,
|
|
model: params.model,
|
|
sessionId: params.sessionId,
|
|
lane: params.lane,
|
|
status: resolveFailoverStatus(reason),
|
|
code,
|
|
rawError: params.output.errorText,
|
|
});
|
|
}
|