moeru-ai/airi · error · Error

The selected invocation does not match the tool name.

Error message

The selected invocation does not match the tool name.

What it means

executeToolCallRerun verifies that a resolved invocation (found via invocationId) actually belongs to the tool named in the payload. A mismatch means the invocationId points to an invocation of a different tool, so rerunning would execute the wrong tool; it throws to prevent that.

Solutions

  1. Correct payload.toolName to match the invocation's actual call name, or pass the invocationId belonging to payload.toolName.
  2. Re-derive the rerun payload from the current message state instead of cached values.
  3. Clear stale rerun state in the UI after any message edit.

Example fix

// before
rerun({ toolCallId: 'call_1', toolName: 'search', invocationId: 'inv_of_translate' })
// after
rerun({ toolCallId: 'call_1', toolName: 'search', invocationId: 'inv_of_search' })
Defensive patterns

Strategy: validation

Validate before calling

const invocation = message.toolCalls.find(c => c.id === payload.toolCallId && c.invocationId === payload.invocationId)
if (invocation && invocation.name !== payload.toolName)
  throw new Error('invocation/toolName mismatch before rerun')

Try / catch

try {
  await executeToolCallRerun(payload)
} catch (e) {
  if (e.message.includes('does not match the tool name')) {
    // rebuild payload from current message state and retry once
  }
}

Prevention

When it happens

Trigger: Calling executeToolCallRerun with a payload whose invocationId resolves to an invocation whose call.name differs from payload.toolName, even though the toolCallId exists in the target message.

Common situations: Stale UI state after editing a message: the stored invocationId now maps to a different tool's call (e.g. after swapping or reordering tool calls), or a copy-paste of rerun parameters between different tool calls.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of moeru-ai/airi@438a067dde (2026-09-17). Data as JSON: /api/errors/f29af7c5464ebbde. Report an issue: GitHub.

Appendix: source

Thrown at packages/stage-ui/src/stores/tool-call-rerun.ts:136

 * The resolver is injected so callers can choose the runtime-specific tool list
 * without coupling this helper to app-local stores, Electron IPC, or browser state.
 */
export async function executeToolCallRerun<TToolset extends string = string>(
  options: ExecuteToolCallRerunOptions<TToolset>,
): Promise<ChatHistoryItem[]> {
  const { messages, payload } = options
  const targetIndex = findTargetMessageIndex(messages, payload)
  const targetMessage = messages[targetIndex]

  if (targetMessage?.role !== 'assistant')
    throw new Error('Tool call rerun target must be an assistant message.')

  if (!hasMatchingToolCall(targetMessage, payload))
    throw new Error(`Assistant message does not contain tool call "${payload.toolCallId}" for "${payload.toolName}".`)

  const invocation = findInvocation(targetMessage, payload.toolCallId, payload.invocationId)
  if (invocation && invocation.call.name !== payload.toolName)
    throw new Error('The selected invocation does not match the tool name.')

  const replaceTargetMessage = (result: ToolCallResultInput) => messages.map((item, itemIndex) => {
    if (itemIndex !== targetIndex)
      return item

    return replaceToolCallResult(targetMessage, result, payload.invocationId)
  })

  const tools = await options.resolveTools()
  const tool = tools.find(candidate => toolNameFrom(candidate) === payload.toolName)
  if (tool == null) {
    return replaceTargetMessage({
      id: payload.toolCallId,
      isError: true,
      result: `Tool "${payload.toolName}" is not available for rerun in this runtime.`,
    })
  }

View on GitHub (pinned to 438a067dde)