Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cline.bot/llms.txt

Use this file to discover all available pages before exploring further.

Agent is an alias for AgentRuntime from @cline/agents.
import { Agent, AgentRuntime, createAgent, createAgentRuntime } from "@cline/sdk"

Constructor

new Agent(config: AgentRuntimeConfig)
AgentRuntimeConfig accepts either:
  • a prebuilt model: AgentModel, or
  • providerId, modelId, and optional provider credentials (apiKey, baseUrl, headers).
Common fields:
FieldTypeRequiredDescription
providerIdstringYes, unless model suppliedProvider ID
modelIdstringYes, unless model suppliedModel ID
apiKeystringNoProvider API key
baseUrlstringNoCustom provider base URL
systemPromptstringNoSystem instructions
toolsAgentTool[]NoTools available to the runtime
initialMessagesAgentMessage[]NoPreloaded conversation
toolPoliciesRecord<string, ToolPolicy>NoPer-tool enablement/approval
hooksAgentRuntimeHooksNoRuntime lifecycle hooks

Methods

run(input)

const result = await agent.run("Analyze this codebase")
Starts a run with input.

continue(input?)

const result = await agent.continue("Now inspect the auth module")
Continues with optional new input.

abort(reason?)

agent.abort("User cancelled")
Aborts the active run.

subscribe(listener)

const unsubscribe = agent.subscribe((event) => {
  console.log(event.type)
})
Subscribes to AgentRuntimeEvent events.

restore(messages)

agent.restore(savedMessages)
Replaces conversation history and resets runtime state while preserving tools, hooks, model, agent identity, and subscribers.

snapshot()

const state = agent.snapshot()
Returns an AgentRuntimeStateSnapshot.

AgentRunResult

interface AgentRunResult {
  agentId: string
  agentRole?: string
  runId: string
  status: "completed" | "aborted" | "failed"
  iterations: number
  outputText: string
  messages: readonly AgentMessage[]
  usage: AgentUsage
  error?: Error
}

Factories

const agent = createAgent(config)
const runtime = createAgentRuntime(config)