mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
fix(agents): hide successful resume fallback prefix
This commit is contained in:
@@ -132,7 +132,7 @@ describe("exec approval followup", () => {
|
||||
expect(callGatewayTool).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("falls back to sanitized direct delivery when session resume fails", async () => {
|
||||
it("falls back to sanitized direct delivery without alarming prefix for successful completions", async () => {
|
||||
vi.mocked(callGatewayTool).mockRejectedValueOnce(new Error("session missing"));
|
||||
|
||||
await sendExecApprovalFollowup({
|
||||
@@ -148,7 +148,7 @@ describe("exec approval followup", () => {
|
||||
|
||||
expect(sendMessage).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
content: "Automatic session resume failed, so sending the status directly.\n\nall good",
|
||||
content: "all good",
|
||||
idempotencyKey: "exec-approval-followup:req-session-resume-failed",
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -120,6 +120,20 @@ function buildSessionResumeFallbackPrefix(): string {
|
||||
return "Automatic session resume failed, so sending the status directly.\n\n";
|
||||
}
|
||||
|
||||
function shouldPrefixDirectFollowupWithSessionResumeFailure(params: {
|
||||
resultText: string;
|
||||
sessionError: unknown;
|
||||
}): boolean {
|
||||
if (!params.sessionError) {
|
||||
return false;
|
||||
}
|
||||
const parsed = parseExecApprovalResultText(params.resultText);
|
||||
if (parsed.kind !== "finished") {
|
||||
return true;
|
||||
}
|
||||
return !normalizeLowercaseStringOrEmpty(parsed.metadata).includes("code 0");
|
||||
}
|
||||
|
||||
function canDirectSendDeniedFollowup(sessionError: unknown): boolean {
|
||||
return sessionError !== null;
|
||||
}
|
||||
@@ -173,7 +187,9 @@ async function sendDirectFollowupFallback(params: {
|
||||
return false;
|
||||
}
|
||||
|
||||
const prefix = params.sessionError ? buildSessionResumeFallbackPrefix() : "";
|
||||
const prefix = shouldPrefixDirectFollowupWithSessionResumeFailure(params)
|
||||
? buildSessionResumeFallbackPrefix()
|
||||
: "";
|
||||
await sendMessage({
|
||||
channel: params.deliveryTarget.channel,
|
||||
to: params.deliveryTarget.to ?? "",
|
||||
|
||||
Reference in New Issue
Block a user