{"record":{"id":"a362741dca7cb5a6","repo":"vercel/ai","slug":"harness-input-harness-harnessid-could-not-fi-a36274","errorCode":null,"errorMessage":"`Harness '${input.harness.harnessId}' could not find parsed tool call '${pendingApproval.toolCallId}' for approval request '${pendingApproval.approvalId}'.`","messagePattern":"`Harness '(.+?)' could not find parsed tool call '(.+?)' for approval request '(.+?)'\\.`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness/src/agent/internal/run-prompt.ts","lineNumber":1011,"sourceCode":"              pendingApproval,\n            );\n            const continuation = continuationsByApprovalId.get(\n              pendingApproval.approvalId,\n            );\n            if (continuation != null) {\n              const outcome = await processPendingApprovalContinuation(\n                pendingApproval,\n                continuation,\n              );\n              if (outcome === 'awaiting-tool-result') return;\n              closingResumedStep = true;\n              continue;\n            }\n            const pendingParsedToolCall = toolCallsByToolCallId.get(\n              pendingApproval.toolCallId,\n            );\n            if (pendingParsedToolCall == null) {\n              throw new Error(\n                `Harness '${input.harness.harnessId}' could not find parsed tool call '${pendingApproval.toolCallId}' for approval request '${pendingApproval.approvalId}'.`,\n              );\n            }\n            onPendingToolApproval(pendingApproval);\n            enqueueApprovalRequest({\n              approvalId: pendingApproval.approvalId,\n              toolCall: pendingParsedToolCall,\n            });\n            if (\n              expectedStepToolCallCount != null &&\n              observedStepToolCallCount < expectedStepToolCallCount\n            ) {\n              pauseAfterStepToolCalls = true;\n              continue;\n            }\n            await finishForHostInputPause({ completeCurrentStep: true });\n            return;\n          }","sourceCodeStart":993,"sourceCodeEnd":1029,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness/src/agent/internal/run-prompt.ts#L993-L1029","documentation":"While enqueuing a pending approval request, the SDK looks up the parsed tool call referenced by `pendingApproval.toolCallId`; when it is missing from `toolCallsByToolCallId` it throws. A pending approval is meaningless without its corresponding parsed tool call (arguments, tool name, raw call), so this is treated as a fatal harness protocol error.","triggerScenarios":"Processing a pending approval whose `toolCallId` has no entry in `toolCallsByToolCallId` — typically because the tool call part was dropped, parsed under a different id, or the approval outlived the step that created the tool call.","commonSituations":"Approvals carried across step boundaries where tool call tracking was reset; adapters that generate approval objects independently of the parsed tool-call stream; id remapping or truncation in the adapter.","solutions":["Fix the adapter so each approval request is created directly from the parsed tool call (same toolCallId object).","Ensure pending approvals are resolved or discarded within the same step/continuation in which the tool call was tracked.","Avoid resetting `toolCallsByToolCallId` while approvals are still pending."],"exampleFix":"// before\nconst approval = { approvalId, toolCallId: raw.id }; // raw id != parsed id\n\n// after\nconst approval = { approvalId, toolCallId: parsedToolCall.toolCallId };","handlingStrategy":"validation","validationCode":"if (!toolCallsByToolCallId.has(pendingApproval.toolCallId)) {\n  throw new Error(`Pending approval ${pendingApproval.approvalId} references missing tool call ${pendingApproval.toolCallId}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agent.run(...);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('could not find parsed tool call')) {\n    // ensure approvals are scoped to the step whose tool calls are still tracked\n  }\n  throw e;\n}","preventionTips":["Resolve or discard pending approvals before resetting per-step tool call tracking.","Derive approval objects from the parsed tool call instance itself.","Test continuation/resume flows where approvals cross step boundaries."],"tags":["harness","tool-approval","id-mismatch","protocol-violation"],"backgroundTag":"unknown-tool-call-id","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}