vercel/ai · error

`Harness '${input.harness.harnessId}' could not find parsed

Error message

`Harness '${input.harness.harnessId}' could not find parsed tool call '${pendingApproval.toolCallId}' for approval request '${pendingApproval.approvalId}'.`

What it means

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.

Source

Thrown at packages/harness/src/agent/internal/run-prompt.ts:1011

              pendingApproval,
            );
            const continuation = continuationsByApprovalId.get(
              pendingApproval.approvalId,
            );
            if (continuation != null) {
              const outcome = await processPendingApprovalContinuation(
                pendingApproval,
                continuation,
              );
              if (outcome === 'awaiting-tool-result') return;
              closingResumedStep = true;
              continue;
            }
            const pendingParsedToolCall = toolCallsByToolCallId.get(
              pendingApproval.toolCallId,
            );
            if (pendingParsedToolCall == null) {
              throw new Error(
                `Harness '${input.harness.harnessId}' could not find parsed tool call '${pendingApproval.toolCallId}' for approval request '${pendingApproval.approvalId}'.`,
              );
            }
            onPendingToolApproval(pendingApproval);
            enqueueApprovalRequest({
              approvalId: pendingApproval.approvalId,
              toolCall: pendingParsedToolCall,
            });
            if (
              expectedStepToolCallCount != null &&
              observedStepToolCallCount < expectedStepToolCallCount
            ) {
              pauseAfterStepToolCalls = true;
              continue;
            }
            await finishForHostInputPause({ completeCurrentStep: true });
            return;
          }

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Fix the adapter so each approval request is created directly from the parsed tool call (same toolCallId object).
  2. Ensure pending approvals are resolved or discarded within the same step/continuation in which the tool call was tracked.
  3. Avoid resetting `toolCallsByToolCallId` while approvals are still pending.

Example fix

// before
const approval = { approvalId, toolCallId: raw.id }; // raw id != parsed id

// after
const approval = { approvalId, toolCallId: parsedToolCall.toolCallId };
Defensive patterns

Strategy: validation

Validate before calling

if (!toolCallsByToolCallId.has(pendingApproval.toolCallId)) {
  throw new Error(`Pending approval ${pendingApproval.approvalId} references missing tool call ${pendingApproval.toolCallId}`);
}

Try / catch

try {
  await agent.run(...);
} catch (e) {
  if (e instanceof Error && e.message.includes('could not find parsed tool call')) {
    // ensure approvals are scoped to the step whose tool calls are still tracked
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/a362741dca7cb5a6. Report an issue: GitHub.