{"record":{"id":"4759e73a5dac19f3","repo":"vercel/ai","slug":"harness-input-harness-harnessid-emitted-appr","errorCode":null,"errorMessage":"`Harness '${input.harness.harnessId}' emitted approval request '${displayValue.approvalId}' for unknown tool call '${displayValue.toolCallId}'.`","messagePattern":"`Harness '(.+?)' emitted approval request '(.+?)' for unknown tool call '(.+?)'\\.`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness/src/agent/internal/run-prompt.ts","lineNumber":726,"sourceCode":"          (displayValue.type === 'tool-call' ||\n            displayValue.type === 'tool-approval-request') &&\n          settledBuiltinApprovalToolCallIds.has(displayValue.toolCallId);\n\n        if (settledHostInputReplay || settledBuiltinApprovalReplay) {\n          continue;\n        }\n\n        if (displayValue.type === 'finish-step' && closingResumedStep) {\n          closingResumedStep = false;\n          resetStepContent();\n          result.discardCurrentStepContent();\n          continue;\n        }\n\n        if (displayValue.type === 'tool-approval-request') {\n          const toolCall = toolCallsByToolCallId.get(displayValue.toolCallId);\n          if (toolCall == null) {\n            throw new Error(\n              `Harness '${input.harness.harnessId}' emitted approval request '${displayValue.approvalId}' for unknown tool call '${displayValue.toolCallId}'.`,\n            );\n          }\n          const rawToolCall = rawToolCallsByToolCallId.get(\n            displayValue.toolCallId,\n          );\n          const toolName = rawToolCall?.toolName ?? toolCall.toolName;\n          if (\n            !isHarnessV1BuiltinToolIncluded({\n              toolName,\n              toolFiltering: input.builtinToolFiltering,\n            })\n          ) {\n            if (control.submitToolApproval == null) {\n              throw new Error(\n                `Harness '${input.harness.harnessId}' emitted a built-in tool approval request but does not support approval responses.`,\n              );\n            }","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness/src/agent/internal/run-prompt.ts#L708-L744","documentation":"The harness emitted a `tool-approval-request` display value whose `toolCallId` does not match any tool call the SDK has parsed and tracked for the current run. The SDK keeps a lookup (`toolCallsByToolCallId`) of parsed tool calls and validates every approval request against it; an approval for an unknown tool call is a harness protocol violation, so runPrompt throws.","triggerScenarios":"During runPrompt stream processing, a display value of type 'tool-approval-request' arrives and `toolCallsByToolCallId.get(displayValue.toolCallId)` returns null — the harness references a tool call id it never emitted, already consumed, or fabricated.","commonSituations":"Harness adapters that generate approval requests from their own internal ids instead of the stream's tool call ids; adapters replaying stale approval requests after a resume/retry; id-mapping bugs where harness-side ids differ from LanguageModelV* tool call ids.","solutions":["Fix the harness adapter so approval requests always reference the `toolCallId` of a tool call emitted in the same run's stream.","Check for duplicate/replayed approval events in the adapter (e.g. resuming a session re-emits old approval requests) and filter them.","Ensure the harness forwards the model's tool call ids verbatim rather than remapping them."],"exampleFix":"// before\nharness.emit({ type: 'tool-approval-request', approvalId, toolCallId: internalId });\n\n// after\nharness.emit({ type: 'tool-approval-request', approvalId, toolCallId: modelToolCall.id });","handlingStrategy":"validation","validationCode":"const knownIds = new Set(streamToolCalls.map(c => c.toolCallId));\nfor (const req of approvalRequests) {\n  if (!knownIds.has(req.toolCallId)) {\n    throw new Error(`Approval ${req.approvalId} references unknown toolCallId ${req.toolCallId}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agent.run(...);\n} catch (e) {\n  if (e instanceof Error && /emitted approval request .* for unknown tool call/.test(e.message)) {\n    // log harness stream for debugging; fix adapter id mapping\n  }\n  throw e;\n}","preventionTips":["Forward model tool call ids verbatim into approval requests in your harness adapter.","Dedupe/replay-filter approval events when resuming sessions.","Add adapter tests asserting every approval request's toolCallId exists in the same stream."],"tags":["harness","tool-approval","protocol-violation","id-mismatch"],"backgroundTag":"unknown-tool-call-id","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}