vercel/ai · error
`Harness '${input.harness.harnessId}' could not execute host
Error message
`Harness '${input.harness.harnessId}' could not execute host tool '${toolCall.toolName}'.` What it means
The SDK attempted to execute a host-side (custom, non-provider-executed) tool requested by the harness, but the execution wrapper reported `executed: false` — i.e. no tool executor ran for this tool call. This indicates the tool could not be dispatched (no matching executor available for `toolCall.toolName`) and the run cannot produce a tool result, so runPrompt throws.
Source
Thrown at packages/harness/src/agent/internal/run-prompt.ts:1083
result: preliminaryOutput as Extract<
HarnessV1StreamPart,
{ type: 'tool-result' }
>['result'],
},
input.sessionWorkDir,
) as Extract<HarnessV1StreamPart, { type: 'tool-result' }>;
result.enqueue({
type: 'tool-result',
toolCallId: toolCall.toolCallId,
toolName: toolCall.toolName,
input: undefined,
output: stripped.result,
preliminary: true,
} as TextStreamPart<TOOLS>);
},
});
if (!execution.executed) {
throw new Error(
`Harness '${input.harness.harnessId}' could not execute host tool '${toolCall.toolName}'.`,
);
}
await telemetry.toolEnd(toolCall.toolCallId, execution.outcome);
})(),
);
}
}
await waitForOutstandingHostToolExecutions();
const isTurnSuspending = input.isTurnSuspending?.() === true;
if (isTurnSuspending) {
if (finalFinish == null) {
/*
* A timed slice may stop in the middle of a model step. Its partial
* content remains in the bridge replay log for the next slice, but it
* cannot form a valid StepResult in this slice because no finish-step
* has arrived yet.
*/View on GitHub (pinned to 69428b1f8b)
Solutions
- Ensure every tool the harness can request is declared in the agent's `tools` with an executable `execute` implementation.
- Verify tool names match exactly (case-sensitive) between harness configuration and the SDK toolset.
- Check `builtinToolFiltering`/tool filters are not excluding a tool the harness still tries to call.
- Keep the toolset stable across all steps of the run.
Example fix
// before
new HarnessAgent({ tools: { read_file: readFileTool } }); // harness calls 'bash'
// after
new HarnessAgent({ tools: { read_file: readFileTool, bash: bashTool } }); Defensive patterns
Strategy: validation
Validate before calling
for (const name of harnessRequestedToolNames) {
if (!hasTool({ tools: activeTools, toolName: name })) {
throw new Error(`Harness may request tool '${name}' which is not in the active toolset.`);
}
} Try / catch
try {
await agent.run(...);
} catch (e) {
if (e instanceof Error && e.message.includes('could not execute host tool')) {
// add the missing tool or correct its name/filtering
}
throw e;
} Prevention
- Declare every tool the harness can invoke with an `execute` implementation.
- Match tool names exactly (case-sensitive) between harness config and toolset.
- Verify tool filters do not exclude harness-requested tools.
When it happens
Trigger: During host tool execution inside runPrompt, `execution.executed` is false after invoking the tool execution machinery — the tool name has no registered executor/implementation in the active toolset or execution was refused.
Common situations: The harness requests a tool that was filtered out or not declared in `tools`; typos or casing differences in tool names between harness config and SDK toolset; toolset swapped between steps so a previously available tool vanished; provider-executed vs host-executed flag mismatch.
Related errors
- `Harness '${input.harness.harnessId}' could not find parsed
- CODE_MODE_HOST_TOOL_ERROR
- claude-code session ${sessionId} is already stopped; cannot
- claude-code session ${sessionId} is already stopped; cannot
- claude-code session ${sessionId} is stopped; cannot suspend.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/34de920c18fe494c.
Report an issue: GitHub.