Skip to main content
This page documents the raw HTTP protocol for WarpGrep (morph-warp-grep-v2.1). Use it to build a custom harness in any language. The API follows the OpenAI chat completions format with native tool calling. The model has its tools built in, so you do not pass a tools array. The model returns structured tool_calls, you execute them locally, and you send results back as tool messages. The tool schemas below are for reference so you know what to implement locally. For a complete implementation, see the Python Guide or the Python agent example. For TypeScript SDK wrappers, see Agent Tool.

Message Flow

The agent runs a multi-turn conversation with max 6 turns using OpenAI-compatible tool calling:

Initial User Message

The first user message contains two parts:
  1. Repository structure — flat list of absolute paths (depth 2)
  2. Search query — what the agent needs to find
The repo structure must be flat absolute paths, one per line. First line is the repo root. No indentation, no tree characters. Directories have no trailing /.

API Call

The model has its tools built in — you do not need to pass a tools array. Just send the messages and the model returns structured tool_calls.
Logged in? Your API key will auto-fill above. Otherwise, get it from your dashboard.

Agent Response Format

The model responds with a standard OpenAI tool_calls array. No XML parsing needed.
The content field is null on tool-call turns. Read only the tool_calls array. The finish_reason will be "tool_calls" when the model wants you to execute tools.
Execute each tool call locally and send results back as tool messages:

Tool Definitions

The model calls these tools internally — you don’t need to pass them in the request. However, you need to implement each tool locally to execute the calls the model returns:
Coerce argument types and tolerate off-schema arguments. The model sometimes sends arguments whose JSON type differs from the schema above, or arguments not listed here at all. Treat every argument leniently:
  • limit and case_sensitive may arrive as strings ("50", "false") rather than an integer or boolean. Coerce before use.
  • grep_search may emit output_lines (a string alias for limit) or output_context_lines (ripgrep -C context). Map them to your limit/context handling.
  • Ignore any argument you do not recognize rather than erroring. Only pattern (for grep_search) is guaranteed.
Parse defensively: read known keys with fallbacks, and never assume a value’s type from the schema alone.

Executing Tools

When the model returns tool_calls, execute each one locally and return the output as a tool message. Here’s a minimal Python implementation:

Turn Counter

After tool results, add a user message with a turn counter and context budget:
Turn messages by turn number:
If the model does not call finish within 6 turns, the search failed. Return an empty result to your caller.

Output Limits

Tools enforce output limits to prevent context explosion:

Complete Example

Putting it all together — a full agent loop: