Quickstart
Create a model, add one tool, and run your first Agentdock agent.
This example uses OpenAI. Set OPENAI_API_KEY before running it.
Create the agent
import { AgentDock, ToolRegistry, defineTool } from "@agentdock-ai/agentdock";
import { AgentDockModel } from "@agentdock-ai/models";
import { z } from "zod";
const weather = defineTool({
name: "get_weather",
description: "Get the weather for a city.",
input: z.object({ city: z.string() }),
run: async ({ city }) => ({ city, forecast: "Sunny" }),
});
const registry = new ToolRegistry();
registry.register(weather);
const agent = new AgentDock({
model: AgentDockModel.openAI({ model: "gpt-5.4-mini" }),
defaults: {
systemPrompt: "Answer clearly. Use the weather tool when it helps.",
},
registry,
});Run it
Every run needs a session ID and a JSON object for context.
const result = await agent.run(
"What is the weather in Lahore?",
{ userId: "user-123" },
{ sessionId: "session-123" },
);
const answer = result.content
.filter((part) => part.type === "text")
.map((part) => part.text)
.join("");
console.log(answer);
await agent.close();result.status tells you whether the run completed, failed, was cancelled, or is waiting for tool approval. See tools, runs, and approvals to continue.

