fix(ulw-loop): add fallback for Oracle verification session tracking
The verification_session_id was never reliably set because the prompt-based attempt_id matching in tool-execute-after depends on metadata.prompt surviving the delegate-task execution chain. When this fails silently, the loop never detects Oracle's VERIFIED emission. Add a fallback: when exact attempt_id matching fails but oracle agent + verification_pending state match, still set the session ID. Add diagnostic logging to trace verification flow failures. Add integration test covering the full verification chain.
This commit is contained in:
@@ -48,22 +48,50 @@ export function createToolExecuteAfterHandler(args: {
|
||||
const prompt = typeof output.metadata?.prompt === "string" ? output.metadata.prompt : undefined
|
||||
const verificationAttemptId = prompt?.match(VERIFICATION_ATTEMPT_PATTERN)?.[1]?.trim()
|
||||
const loopState = directory ? readState(directory) : null
|
||||
|
||||
if (
|
||||
const isVerificationContext =
|
||||
agent === "oracle"
|
||||
&& sessionId
|
||||
&& verificationAttemptId
|
||||
&& directory
|
||||
&& !!sessionId
|
||||
&& !!directory
|
||||
&& loopState?.active === true
|
||||
&& loopState.ultrawork === true
|
||||
&& loopState.verification_pending === true
|
||||
&& loopState.session_id === input.sessionID
|
||||
|
||||
log("[tool-execute-after] ULW verification tracking check", {
|
||||
tool: input.tool,
|
||||
agent,
|
||||
parentSessionID: input.sessionID,
|
||||
oracleSessionID: sessionId,
|
||||
hasPromptInMetadata: typeof prompt === "string",
|
||||
extractedVerificationAttemptId: verificationAttemptId,
|
||||
})
|
||||
|
||||
if (
|
||||
isVerificationContext
|
||||
&& verificationAttemptId
|
||||
&& loopState.verification_attempt_id === verificationAttemptId
|
||||
) {
|
||||
writeState(directory, {
|
||||
...loopState,
|
||||
verification_session_id: sessionId,
|
||||
})
|
||||
log("[tool-execute-after] Stored oracle verification session via attempt match", {
|
||||
parentSessionID: input.sessionID,
|
||||
oracleSessionID: sessionId,
|
||||
verificationAttemptId,
|
||||
})
|
||||
} else if (isVerificationContext && !verificationAttemptId) {
|
||||
writeState(directory, {
|
||||
...loopState,
|
||||
verification_session_id: sessionId,
|
||||
})
|
||||
log("[tool-execute-after] Fallback: stored oracle verification session without attempt match", {
|
||||
parentSessionID: input.sessionID,
|
||||
oracleSessionID: sessionId,
|
||||
hasPromptInMetadata: typeof prompt === "string",
|
||||
expectedAttemptId: loopState.verification_attempt_id,
|
||||
extractedAttemptId: verificationAttemptId,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user