fix: ignore poisoned AgentRun session thread after resume failure
This commit is contained in:
@@ -1003,7 +1003,23 @@ function agentRunSessionRecordFromEnsure(value = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function agentRunSessionThreadIdFromEnsure(value = null) {
|
function agentRunSessionThreadIdFromEnsure(value = null) {
|
||||||
return safeOpaqueId(agentRunSessionRecordFromEnsure(value)?.threadId) || null;
|
const record = agentRunSessionRecordFromEnsure(value);
|
||||||
|
if (agentRunSessionThreadInvalidated(record)) return null;
|
||||||
|
return safeOpaqueId(record?.threadId) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function agentRunSessionThreadInvalidated(record = null) {
|
||||||
|
if (!record || typeof record !== "object") return false;
|
||||||
|
const failureMessage = firstNonEmpty(
|
||||||
|
record.failureMessage,
|
||||||
|
record.blocker?.message,
|
||||||
|
record.liveness?.terminalClassification?.reason,
|
||||||
|
record.supervisor?.terminalClassification?.reason
|
||||||
|
);
|
||||||
|
if (!agentRunFailureRequiresFreshSession(record.failureKind, failureMessage)) return false;
|
||||||
|
const terminalStatus = normalizeAgentRunStatus(record.terminalStatus ?? record.status);
|
||||||
|
const executionState = String(record.executionState ?? "").trim().toLowerCase();
|
||||||
|
return terminalStatus === "failed" || terminalStatus === "blocked" || executionState === "terminal";
|
||||||
}
|
}
|
||||||
|
|
||||||
function paramsWithAgentRunSessionThread(params = {}, threadId = null) {
|
function paramsWithAgentRunSessionThread(params = {}, threadId = null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user