feat: clean up keep-alive fallback handling (#663)

This commit is contained in:
cthomas
2026-01-27 17:50:37 -08:00
committed by GitHub
parent c2fd63f5b5
commit 0df8e51dac
4 changed files with 96 additions and 321 deletions

View File

@@ -1,10 +1,4 @@
import type { MessageCreate } from "@letta-ai/letta-client/resources/agents/agents";
import { getClient } from "./client";
import { APPROVAL_RECOVERY_PROMPT } from "./promptAssets";
// Error when trying to SEND approval but server has no pending approval
const APPROVAL_RECOVERY_DETAIL_FRAGMENT =
"no tool call is currently awaiting approval";
// Error when approval tool call IDs don't match what server expects
// Format: "Invalid tool call IDs: Expected [...], got [...]"
@@ -30,15 +24,6 @@ type RunErrorMetadata =
| undefined
| null;
export function isApprovalStateDesyncError(detail: unknown): boolean {
if (typeof detail !== "string") return false;
const lower = detail.toLowerCase();
return (
lower.includes(APPROVAL_RECOVERY_DETAIL_FRAGMENT) ||
lower.includes(INVALID_TOOL_CALL_IDS_FRAGMENT)
);
}
/**
* Check if error specifically indicates tool call ID mismatch.
* This is a subtype of desync where the server HAS pending approvals,
@@ -100,11 +85,3 @@ export async function fetchRunErrorDetail(
return null;
}
}
export function buildApprovalRecoveryMessage(): MessageCreate {
return {
type: "message",
role: "user",
content: [{ type: "text", text: APPROVAL_RECOVERY_PROMPT }],
};
}