mirror of
https://github.com/jcreek/AutomatedAssessmentFeedbackAgent.git
synced 2026-07-12 18:43:49 +00:00
feat(*): Ensure all threads are deleted when finished with
This commit is contained in:
@@ -320,6 +320,7 @@ export async function gradeSubmissionWithAgent(
|
||||
finalRun = await processRunStream(thread.id, initialStream, roomId);
|
||||
} catch (err) {
|
||||
logger.error(`Agent streaming failed on thread ${thread.id}:`, err);
|
||||
client.agents.deleteThread(thread.id);
|
||||
return fallbackGrade(submission, task);
|
||||
}
|
||||
|
||||
@@ -331,6 +332,8 @@ export async function gradeSubmissionWithAgent(
|
||||
const match = raw.match(/\{[\s\S]*\}$/);
|
||||
const jsonText = match ? match[0] : raw;
|
||||
|
||||
client.agents.deleteThread(thread.id);
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(jsonText) as OpenAIResponse;
|
||||
if (parsed.grade === 'HUMAN_REVIEW_REQUIRED') {
|
||||
@@ -376,6 +379,7 @@ export async function resumeAgentWithHumanReview(
|
||||
finalRun = await processRunStream(threadId, stream, roomId);
|
||||
} catch (err) {
|
||||
logger.error(`Agent streaming failed on thread ${threadId}:`, err);
|
||||
client.agents.deleteThread(threadId);
|
||||
return fallbackGrade('', '');
|
||||
}
|
||||
|
||||
@@ -387,6 +391,8 @@ export async function resumeAgentWithHumanReview(
|
||||
const match = raw.match(/\{[\s\S]*\}$/);
|
||||
const jsonText = match ? match[0] : raw;
|
||||
|
||||
client.agents.deleteThread(threadId);
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(jsonText) as OpenAIResponse;
|
||||
return parsed;
|
||||
|
||||
Reference in New Issue
Block a user