API reference

The main Agentdock classes, functions, and options.

Create an agent

APIUse it to
defineTool(options)Define a tool with a Zod input schema.
new AgentDock(options)Create the AgentDock runtime.

AgentDock is the only agent construction API. Register tools with registerTool() or registerTools(), set the system prompt through defaults.systemPrompt, and pass a checkpoint adapter through checkpoint. Agentdock closes adapters passed as checkpoint; your app manages raw checkpoint savers.

Run methods

MethodResult
run(prompt, context, options)Promise with the final run result.
stream(prompt, context, options)Promise with an event stream and a promise for the final result.
resume(input, context, options)Continue a run that is waiting for approval.
resumeStream(input, context, options)Continue an approval-waiting run and stream its events.

Every run and resume needs a sessionId. context must be a JSON object.

Run results have one of four statuses: completed, waiting_for_approval, failed, or cancelled.

Session methods

MethodWhat it does
getSession(sessionId, options?)Read the current messages, or null if there are none.
getSessionHistory(sessionId, options?)Read the current session and its saved checkpoints.
deleteSession(sessionId, options?)Delete a session when it has no active run.

getSession() returns a session record with its messages, or null if there are none. Pass the same sessionNamespace to keep the session in the same app or tenant partition.

Tool methods

MethodWhat it does
registerTool(tool)Add one tool to an existing agent.
registerTools(tools)Add several tools.
getTool(name)Read a registered tool.
getTools()List registered tools.
getToolSchemas()Read the tool schemas sent to the model.

Lifecycle methods

  • initialize() prepares the checkpoint adapter. It is usually called automatically before the first operation.
  • stop(runId) cancels an active run and returns true; it returns false if the run is not active.
  • close({ gracePeriodMs? }) stops active runs and closes resources owned by Agentdock.
  • getUnfinishedRunIds() lists runs still active when a close grace period ends.

Common options

AgentDock requires a model. It also accepts:

  • defaults: default systemPrompt and maxSteps for runs.
  • checkpoint: an Agentdock checkpoint adapter. Agentdock owns and closes it.
  • contextManagement: optional conversation summarization settings.
  • registry: a ToolRegistry for registering tools during construction. Tools can also be registered after construction with registerTool() or registerTools().

Run options include sessionId, runId, sessionNamespace, systemPrompt, maxSteps, toolTimeout, authorizationTimeout, and abortSignal. See runs for their use.

On this page