-
Notifications
You must be signed in to change notification settings - Fork 198
[harness] Add Cursor CLI provider to Python SDK #292
Copy link
Copy link
Open
Labels
ai-friendlyWell-documented task suitable for AI-assisted developmentWell-documented task suitable for AI-assisted developmentarea:harnessCoding agent harness integrationCoding agent harness integrationcore-teamMaintained by core team — not open for external contributionMaintained by core team — not open for external contributionenhancementNew feature or requestNew feature or requestsdk:pythonPython SDK relatedPython SDK related
Description
Parent Epic
Part of #291 — Add Cursor as a Harness Provider
Summary
Add CursorProvider to the Python SDK harness system. This follows the exact same pattern as the existing ClaudeCodeProvider, CodexProvider, GeminiProvider, and OpenCodeProvider.
Files to Create/Modify
New
sdk/python/agentfield/harness/providers/cursor.py—CursorProviderclass
Modify
sdk/python/agentfield/harness/providers/_factory.py— Add"cursor"toSUPPORTED_PROVIDERS, wire factorysdk/python/agentfield/harness/_runner.py— Addcursor_binto config (if not already generic)sdk/python/agentfield/harness/providers/__init__.py— Export
Tests
sdk/python/tests/harness/test_cursor.py
Implementation Details
CLI Command Construction
cmd = ["agent", "-p", "--force", "--trust", "--output-format", "stream-json"]
if options.cwd:
cmd.extend(["--workspace", options.cwd])
if options.model:
cmd.extend(["--model", options.model])
if options.resume_session_id:
cmd.extend(["--resume", options.resume_session_id])
if options.permission_mode == "plan":
cmd.extend(["--mode", "plan"])
# API key via env
env["CURSOR_API_KEY"] = api_key
cmd.append(prompt)Output Parsing
Use stream-json mode (NDJSON). Parse events:
{"type": "result", "subtype": "success", "result": "<text>", "session_id": "<uuid>", "duration_ms": N}— final result- Tool call events for streaming (optional first pass — can use
jsonmode if simpler)
Session Resume
session_id from result event maps to --resume <chatId> on next invocation. Store in RawResult.session_id.
Config
Add to HarnessConfig:
cursor_bin: Optional[str] = None # Override binary path (default: "agent")Permission Mode Mapping
| AgentField | Cursor CLI |
|---|---|
"auto" |
--force (default, already in base flags) |
"plan" |
--mode plan |
None |
--mode ask |
Acceptance Criteria
-
CursorProviderimplementsHarnessProviderprotocol - Factory resolves
"cursor"toCursorProvider - Prompt passed as last positional argument
- JSON/stream-json output parsed correctly
- Session resume works via
--resume -
cursor_binconfig allows custom binary path - Schema validation uses same
.agentfield_output.jsonpattern - Tests cover: basic execution, session resume, error handling, timeout
- Follows exact patterns from existing providers (reference:
codex.py)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ai-friendlyWell-documented task suitable for AI-assisted developmentWell-documented task suitable for AI-assisted developmentarea:harnessCoding agent harness integrationCoding agent harness integrationcore-teamMaintained by core team — not open for external contributionMaintained by core team — not open for external contributionenhancementNew feature or requestNew feature or requestsdk:pythonPython SDK relatedPython SDK related