vercel/ai · error

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

Error message

`Harness '${input.harness.harnessId}' could not find parsed tool call '${toolCall.toolCallId}' for custom tool approval.`

What it means

The harness emitted a host-side (non-provider-executed) `tool-call` stream part, but the SDK could not find a matching parsed tool call in `toolCallsByToolCallId` when preparing custom tool approval/execution. Every host tool call must have been parsed and registered earlier in the run; a missing entry means the stream is inconsistent, so runPrompt throws.

Source

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

            };
          }
        }

        if (value.type === 'finish') {
          await waitForOutstandingHostToolExecutions();
          finalFinish = value;
          await telemetry.end({
            finishReason: value.finishReason,
            usage: value.totalUsage,
          });
        }

        // Execute host-side tools when the harness asks for one.
        if (value.type === 'tool-call' && !value.providerExecuted) {
          const toolCall = value;
          const parsedToolCall = toolCallsByToolCallId.get(toolCall.toolCallId);
          if (parsedToolCall == null) {
            throw new Error(
              `Harness '${input.harness.harnessId}' could not find parsed tool call '${toolCall.toolCallId}' for custom tool approval.`,
            );
          }
          if (!hasTool({ tools: activeTools, toolName: toolCall.toolName })) {
            const output = {
              type: 'execution-denied',
              reason: getHarnessV1BuiltinToolFilteringDenialReason({
                toolName: toolCall.toolName,
              }),
            };
            await control.submitToolResult({
              toolCallId: toolCall.toolCallId,
              output,
            });
            await telemetry.toolEnd(toolCall.toolCallId, { ok: true, output });
            continue;
          }
          const customToolApprovalDecision = resolveCustomToolApproval({

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Verify the harness adapter emits raw tool calls through the standard stream path so the SDK parses and registers them before host execution.
  2. Check that `toolCallId` values are unique per run and forwarded unchanged from the raw tool call to the parsed tool call.
  3. Update the harness package and SDK to matching versions so stream part schemas agree.

Example fix

// before
stream.emit({ type: 'tool-call', toolCallId: 'call_2', toolName: 'bash', providerExecuted: false }); // id never parsed

// after
const parsed = parseToolCall(rawToolCall);
toolCallsByToolCallId.set(parsed.toolCallId, parsed);
stream.emit(parsed);
Defensive patterns

Strategy: validation

Validate before calling

if (toolCall.type === 'tool-call' && !toolCall.providerExecuted && !toolCallsByToolCallId.has(toolCall.toolCallId)) {
  throw new Error(`Unregistered host tool call ${toolCall.toolCallId}`);
}

Type guard

function isRegisteredHostToolCall(part: TextStreamPart, registry: Map<string, unknown>): part is ToolCallTextStreamPart {
  return part.type === 'tool-call' && !part.providerExecuted && registry.has(part.toolCallId);
}

Try / catch

try {
  await agent.run(...);
} catch (e) {
  if (e instanceof Error && e.message.includes('could not find parsed tool call')) {
    // inspect raw vs parsed tool call ids in the harness stream
  }
  throw e;
}

Prevention

When it happens

Trigger: A stream value with type 'tool-call' and `providerExecuted === false` arrives, and `toolCallsByToolCallId.get(toolCall.toolCallId)` returns null — the tool call was never parsed/registered (parsing failure, id mismatch, or duplicate id reuse).

Common situations: Harness adapters that skip or alter the raw tool-call phase; parse errors on earlier tool-call parts silently dropping entries; adapters reusing tool call ids across steps; version drift between harness output schema and SDK parser.

Related errors


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