harness
Agents

Cursor

Using Cursor's headless agent with harness — flags, output format, and event mapping

Cursor's headless agent provides a Claude Code-compatible interface for non-interactive coding tasks.

Installation

Cursor's headless agent is typically installed via the Cursor IDE or as a standalone binary.

cursor-agent --version
# or
agent --version

Headless mode

cursor-agent -p --output-format stream-json "explain this codebase"

Note: the prompt is a positional argument; -p enables headless mode.

How harness maps to Cursor

harnessCursor
PermissionMode::FullAccess--force
PermissionMode::ReadOnly--mode plan
config.promptPositional argument (last)
config.model--model <model>
config.resume_session--resume <session-id>
Output format-p --output-format stream-json

Key flags

FlagDescription
-pRequired for headless mode
--output-format <fmt>Output format: stream-json for NDJSON
--model <model>Model to use
--forceAuto-approve all tool permissions
--mode planRead-only mode
--resume <session-id>Resume a previous session

Stream-JSON output format

Cursor emits NDJSON similar to Claude Code. Event types:

System init

{
  "type": "system",
  "subtype": "init",
  "session_id": "s-42",
  "model": "gpt-5.2",
  "cwd": "/home/user"
}

Assistant message

{
  "type": "assistant",
  "message": {
    "role": "assistant",
    "content": [
      {"type": "text", "text": "I found the bug."}
    ]
  }
}

Tool call started

{
  "type": "tool_call",
  "subtype": "started",
  "call_id": "c-1",
  "tool_call": {
    "readToolCall": {
      "args": {"path": "src/main.rs"}
    }
  }
}

Tool call completed

{
  "type": "tool_call",
  "subtype": "completed",
  "call_id": "c-1",
  "tool_call": {
    "readToolCall": {
      "result": {
        "success": {"content": "fn main() {}"}
      }
    }
  }
}

Result

{
  "type": "result",
  "subtype": "success",
  "is_error": false,
  "duration_ms": 2000,
  "result": "Task completed successfully."
}

Tool call naming

Tool calls are nested under keys following the *ToolCall pattern: readToolCall, writeToolCall, listToolCall, bashToolCall, searchToolCall.

Event mapping

Cursor eventharness event
system (init)SessionStart
assistantMessage (role: Assistant)
userMessage (role: User)
tool_call (started)ToolStart
tool_call (completed)ToolEnd
resultResult

Binary candidates

Harness searches for the Cursor binary in this order:

  1. cursor-agent (preferred)
  2. agent (fallback)

Environment variables

VariablePurpose
CURSOR_API_KEYAPI key for Cursor's API

On this page