Skip to main content

Managed Agent Runtime SDK β€” API Contract

The SDK exposes a single Anthropic-shaped surface for every runtime (Claude Managed Agents, Cursor, Gemini Antigravity, and any future runtime). Callers use the same four-step flow regardless of which runtime is active. Provider differences are fully encapsulated inside sdk/providers/<provider>/runtime/. Reference shape: Anthropic Managed Agents API

Public flow

let client = Lap::new(LapConfig::anthropic(api_key));  // or ::cursor / ::gemini_antigravity

let agent   = client.beta().agents().create(params).await?;
let agents  = client.beta().agents().list(params).await?;
let models  = client.beta().models().list(params).await?;
let env     = client.beta().environments().create(params).await?;
let session = client.beta().sessions().create(params).await?;

// send a prompt
client.beta().sessions().events().send(session_id, params).await?;

// stream the reply
let stream = client.beta().sessions().events().stream(session_id).await?;
The flow is identical for every runtime. No match runtime or if runtime == X blocks appear in calling code.

Input types

CreateAgentParams

FieldTypeNotes
lap_agent_runtimeAgentRuntimeRequired. Selects the runtime adapter.
nameStringAgent display name.
modelAgentModelAgentModel::Id("claude-opus-4-8") or AgentModel::Config { id, speed }.
systemStringSystem prompt. Cursor uses this as prompt.text; Gemini sends it as system_instruction.
descriptionOption<String>Optional description.
toolsVec<Value>Tool definitions. Cursor ignores this field. Gemini accepts code_execution, google_search, and url_context.
mcp_serversVec<Value>MCP server configs. Cursor maps these to mcpServers.
workspaceOption<AgentWorkspace>Repository + PR intent. Cursor maps to repos/autoCreatePR; Gemini maps the repository to base_environment.sources.
env_varsOption<HashMap<String, String>>Runtime environment variables. Reserved for future vault support.
metadataOption<HashMap<String, String>>Stored in provider metadata. Anthropic includes it; Cursor ignores.

AgentWorkspace

FieldTypeNotes
repositoryStringRepository URL.
ref_nameOption<String>Branch or commit ref. Defaults to "main".
auto_create_prboolWhether to open a PR when the run completes.

CreateEnvironmentParams

FieldTypeNotes
lap_agent_runtimeAgentRuntimeRequired.
nameStringEnvironment name. Cursor returns this as the synthetic environment ID.
configValueAnthropic environment config ({ "type": "cloud", "networking": {...} }). Cursor ignores.
descriptionOption<String>
scopeOption<String>

CreateSessionParams

FieldTypeNotes
agentStringAgent ID from agents.create.
environment_idStringEnvironment ID from environments.create.
titleStringSession title.
lap_agent_runtimeOption<AgentRuntime>Inferred from client config if only one runtime is configured.
metadataOption<HashMap<String, String>>Anthropic stores; Cursor ignores.
resourcesOption<Value>Reserved.

SendEventsParams

{
  "events": [
    {
      "type": "user.message",
      "content": [{ "type": "text", "text": "..." }]
    }
  ]
}

Agent CRUD

Gemini Antigravity additionally supports saved-agent management through the normalized agents resource:
client.beta().agents().list(ListAgentsParams { ... }).await?;
client.beta().agents().get(GetAgentParams { ... }).await?;
client.beta().agents().delete(DeleteAgentParams { ... }).await?;

Output types

ManagedAgent

Anthropic-shaped. All fields extracted from the raw response where available.
FieldTypeNotes
idStringProvider agent ID. Always present.
versionOption<u64>Anthropic only.
nameOption<String>
descriptionOption<String>
modelOption<String>Model ID string.
systemOption<String>
toolsVec<Value>
mcp_serversVec<Value>
metadataOption<Value>
created_atOption<i64>Unix timestamp.
updated_atOption<i64>Unix timestamp.
rawValueFull unmodified provider response. Escape hatch.

Environment

FieldTypeNotes
idStringProvider environment ID. Always present.
rawValueFull provider response. Cursor returns { "id": "<name>" }.

Session

Anthropic-shaped.
FieldTypeNotes
idStringProvider session ID. Always present.
agentOption<String>Agent ID.
environment_idOption<String>Environment ID.
statusOption<String>Session status string.
metadataOption<Value>
created_atOption<i64>Unix timestamp.
updated_atOption<i64>Unix timestamp.
rawValueFull provider response.

AgentEvent

Anthropic-shaped. Cursor events are normalized to this shape by the cursor adapter before the stream is returned to the caller.
FieldTypeNotes
event_typeStringAnthropic event type string (e.g. "agent.message", "session.status_idle").
dataMap<String, Value>Event payload.
Use event.kind() β†’ AgentEventKind and event.payload() β†’ AgentEventPayload for typed access. Key event types:
EventMeaning
session.status_runningSession is processing.
agent.messageAssistant reply. data.content is an array of content blocks.
agent.tool_useAgent called a tool.
agent.tool_resultTool returned a result.
session.status_idleSession is done. Terminal event β€” stop reading the stream.

Provider normalization

Each runtime maps its native response shape to the Anthropic-shaped outputs above. Callers never see provider-specific fields unless they inspect .raw.
ConcernAnthropicCursorGemini Antigravity
agents.create HTTP pathPOST /v1/agentsPOST /v1/agentsPOST /v1beta/agents
Agent CRUDCreate onlyCreate onlyCreate, list, get, delete
environments.createPOST /v1/environmentsSynthetic ({ id: name })Synthetic (remote or supplied ID)
sessions.createPOST /v1/sessionsSynthetic (uses agent ID)Synthetic conversation handle
send_eventsPOST /v1/sessions/{id}/eventsPOST /v1/agents/{id}/runsPOST /v1beta/interactions
stream_eventsGET /v1/sessions/{id}/events/streamGET /v1/agents/{id}/runs/{run_id}/streamGET /v1beta/interactions/{id}
Event normalizationNative Anthropic SSECursor events -> Anthropic shapeInteraction steps -> Anthropic shape
Initial run on createNo β€” send first prompt via send_eventsYes β€” agents.create starts a run immediatelyNo β€” send first prompt via send_events

Adapter contract

Each runtime implements RuntimeAdapter in sdk/providers/<runtime>/runtime/mod.rs. Required methods:
fn configure_request(&self, request: RequestBuilder, api_key: &str) -> RequestBuilder;
fn create_agent<'a>(&'a self, client: &'a Lap, params: CreateAgentParams) -> AdapterFuture<'a, ManagedAgent>;
fn create_environment<'a>(...) -> AdapterFuture<'a, Environment>;
fn create_session<'a>(...) -> AdapterFuture<'a, Session>;
fn send_events<'a>(...) -> AdapterFuture<'a, SendEventsResponse>;
fn stream_events<'a>(...) -> AdapterFuture<'a, AgentEventStream>;
Optional overrides (default: None):
fn normalize_stream(&self, stream: AgentEventStream) -> AgentEventStream;
fn provider_run_id_from_agent_raw(&self, raw: &Value) -> Option<String>;
fn provider_url_from_agent_raw(&self, raw: &Value) -> Option<String>;
fn provider_agent_id_from_session_id(&self, session_id: &str) -> Option<String>;
To add a new runtime: create sdk/providers/<name>/runtime/mod.rs, implement RuntimeAdapter, add RUNTIME_ID/RUNTIME_NAME/DEFAULT_API_BASE constants, and call registry.register(...) in the provider’s mod.rs. No other files change.