I have try many time’s and different ways even with perplexity computer but it doesnt works at all… Mabe anyone do it already and have some setup tips for me
Hey! Have you read Perplexity with OpenClaw - Perplexity?
Yeah i see about search but i mean use as LLM model but have a problem, gpts does work at all, sonar same, claude works but only chat mode tools doesn’t work
[FIX] OpenClaw + Perplexity Agent API: all tool calls fail with empty arguments {}
OpenClaw version: 2026.4.9
Provider: Perplexity Agent API (https://api.perplexity.ai/v1)
API type: openai-responses
Model: perplexity/anthropic/claude-sonnet-4-6
Symptom
When using OpenClaw with the Perplexity Agent API in openai-responses mode, any tool (exec, write, read, etc.) fails with a validation error:
text
**Validation failed for tool "exec":
- command: must have required property 'command'
Received arguments:
{}**
Chat replies without tool calls work fine — only tool calling is broken. Arguments always come through as empty {}.
Cause
The streaming parser for the OpenAI Responses API (openai-responses-shared.js from @mariozechner/pi-ai) expects function call arguments to arrive incrementally via response.function_call_arguments.delta events.
However, Perplexity Agent API sends all arguments immediately in the first response.output_item.added event (inside item.arguments) and never emits subsequent delta or done events for function arguments.
Here’s what happens step by step:
-
On receiving
response.output_item.addedwithitem.type === "function_call", the parser creates acurrentBlockwitharguments: {}and storesitem.argumentsinpartialJson. -
It then waits for
response.function_call_arguments.deltaevents to fillargumentsfrompartialJson— but Perplexity never sends those. -
When
response.output_item.donecomes, the parser creates a newtoolCallobject with correctly parsed arguments frompartialJsonand passes it in the stream eventtoolcall_end, but does not update the existing entry inoutput.content. -
The agent loop (
agent-loop.jsin@mariozechner/pi-agent-core) reads tool calls frommessage.content— whereargumentsare still{}. -
Validation fails since required properties are missing.
Example from the session file:
json
{
"type": "toolCall",
"name": "exec",
"arguments": {},
"partialJson": "{\\"command\\": \\"echo \\\\\\"tools test ok\\\\\\"\\"}"
}
The arguments were correctly captured in partialJson, but never copied to arguments.
Fix
File to patch
text
/usr/lib/node_modules/openclaw/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses-shared.js
What to change
Find the response.output_item.done handler for type function_call (around lines 392–405). It looks like this:
javascript
else if (item.type === "function_call") {
const args = currentBlock?.type === "toolCall" && currentBlock.partialJson
? parseStreamingJson(currentBlock.partialJson)
: parseStreamingJson(item.arguments || "{}");
const toolCall = {
type: "toolCall",
id: `${item.call_id}|${item.id}`,
name: item.name,
arguments: args,
};
currentBlock = null;
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall, partial: output });
}
Add two lines before currentBlock = null;:
javascript
else if (item.type === "function_call") {
const args = currentBlock?.type === "toolCall" && currentBlock.partialJson
? parseStreamingJson(currentBlock.partialJson)
: parseStreamingJson(item.arguments || "{}");
const toolCall = {
type: "toolCall",
id: `${item.call_id}|${item.id}`,
name: item.name,
arguments: args,
};
// FIX: update entry in output.content so agent-loop sees correct arguments**
const idx = output.content.indexOf(currentBlock);
if (idx >= 0) { output.content[idx] = toolCall; }
currentBlock = null;
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall, partial: output });
}**
Restart gateway
After saving the file, restart the gateway service:
bash
systemctl --user restart openclaw-gateway
Why it works
The toolcall_end event already contains the correct toolCall object with parsed arguments.
The problem is that the agent loop reads tool calls from message.content, which still holds the old currentBlock with empty {} arguments.
The patch replaces that outdated record with the properly parsed toolCall before clearing currentBlock.
Warning about updates
This patch modifies a file inside node_modules.
Whenever OpenClaw is updated (npm update -g openclaw), the patch will be overwritten — you’ll need to reapply it until it’s merged upstream in @mariozechner/pi-ai.
Extra: proper configuration for Perplexity Agent API
Configuration file: ~/.openclaw/openclaw.json
| Parameter | Correct value | Common mistake |
|---|---|---|
apiType |
openai-responses |
openai-completions — doesn’t work |
baseUrl |
https://api.perplexity.ai/v1 |
/v1/agent — invalid path |
model |
perplexity/anthropic/claude-sonnet-4-6 |
— |
Note:
baseUrlmust behttps://api.perplexity.ai/v1, not/v1/agent.
The API type should beopenai-responses.