fix: add robustness for connection errors for approvals (#189)

Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: Charles Packer <packercharles@gmail.com>
This commit is contained in:
Sarah Wooders
2025-12-20 19:02:12 -08:00
committed by GitHub
parent f3d72361d1
commit 90d84482ef
4 changed files with 207 additions and 19 deletions

View File

@@ -17,7 +17,7 @@ export type ApprovalRequest = {
toolArgs: string;
};
type DrainResult = {
export type DrainResult = {
stopReason: StopReasonType;
lastRunId?: string | null;
lastSeqId?: number | null;
@@ -263,10 +263,14 @@ export async function drainStreamWithResume(
try {
const client = await getClient();
// Resume from Redis where we left off
const resumeStream = await client.runs.messages.stream(result.lastRunId, {
starting_after: result.lastSeqId,
batch_size: 1000, // Fetch buffered chunks quickly
});
const resumeStream = await client.runs.messages.stream(
result.lastRunId,
{
starting_after: result.lastSeqId,
batch_size: 1000, // Fetch buffered chunks quickly
},
{ maxRetries: 0 },
);
// Continue draining from where we left off
// Note: Don't pass onFirstMessage again - already called in initial drain