alibaba/page-agent · error · InvokeError

INVALID_TOOL_ARGS

INVALID_TOOL_ARGS

Error message

No tool call arguments found

What it means

The chosen tool call has no function.arguments string on the response, so there is nothing to parse into tool input; invoke() throws InvokeError INVALID_TOOL_ARGS. Some providers omit arguments entirely (rather than sending '{}') when a tool takes no parameters.

Source

Thrown at packages/llms/src/OpenAIClient.ts:204

				undefined,
				data
			)
		}

		const tool = tools[toolCallName]
		if (!tool) {
			throw new InvokeError(
				InvokeErrorTypes.UNKNOWN,
				`Tool "${toolCallName}" not found in tools`,
				undefined,
				data
			)
		}

		// Extract and parse tool arguments
		const argString = normalizedChoice.message?.tool_calls?.[0]?.function?.arguments
		if (!argString) {
			throw new InvokeError(
				InvokeErrorTypes.INVALID_TOOL_ARGS,
				'No tool call arguments found',
				undefined,
				data
			)
		}

		let parsedArgs: unknown
		try {
			parsedArgs = JSON.parse(argString)
		} catch (error) {
			throw new InvokeError(
				InvokeErrorTypes.INVALID_TOOL_ARGS,
				'Failed to parse tool arguments as JSON',
				error,
				data
			)
		}

View on GitHub (pinned to d02db1ee7c)

Solutions

  1. Inspect error.data.choices[0].message.tool_calls[0] to confirm arguments is missing
  2. Give the tool a schema (even an empty-object schema with additionalProperties:false) so the model emits '{}'
  3. Use normalizeResponse to default missing arguments to '{}' before parsing

Example fix

// before
const result = await llm.invoke(messages, tools)

// after
const result = await llm.invoke(messages, tools, {
  normalizeResponse: (data) => {
    const tc = data.choices?.[0]?.message?.tool_calls?.[0]
    if (tc && !tc.function?.arguments) tc.function.arguments = '{}'
    return data
  },
})
Defensive patterns

Strategy: fallback

Validate before calling

null

Type guard

null

Try / catch

try {
  await llm.invoke(messages, tools)
} catch (e) {
  if (e instanceof InvokeError && e.code === InvokeErrorTypes.INVALID_TOOL_ARGS && /No tool call arguments/.test(e.message)) {
    // provider omitted arguments for a zero-arg tool; retry with normalizeResponse defaulting to '{}'
  }
}

Prevention

When it happens

Trigger: invoke() returns a tool_call whose function.arguments is undefined/null/empty; typical for zero-argument tools on OpenAI-compatible providers, or providers that put arguments under a different field.

Common situations: Open-source model servers (Ollama/vLLM variants) that omit arguments for parameterless tools; a normalizeResponse that drops the field; schema-less tool definitions leading the model to skip arguments.

Related errors


AI-assisted analysis of alibaba/page-agent@d02db1ee7c (2026-08-28). Data as JSON: /api/errors/726d642c370bba1b. Report an issue: GitHub.