Merge pull request #1679 from pikasTech/fix/agentrun-poisoned-profile-session
修复已污染 AgentRun profile session 的旧 thread 复用
This commit is contained in:
@@ -1003,7 +1003,23 @@ function agentRunSessionRecordFromEnsure(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) {
|
||||
|
||||
Reference in New Issue
Block a user