Skip to content

Agents

An agent is defined using defineAgent() and describes an LLM persona with a system prompt, tools, and optional handoff targets.

Defining an Agent

typescript
import { defineAgent } from "one-agent-sdk";

const agent = defineAgent({
  name: "assistant",
  description: "A helpful assistant",
  prompt: "You are a helpful assistant.",
  tools: [weatherTool, searchTool],
  handoffs: ["specialist"],
  model: "claude-sonnet-4-20250514",
});

AgentDef Properties

PropertyTypeRequiredDescription
namestringYesUnique identifier for the agent
descriptionstringYesHuman-readable description
promptstringYesSystem prompt for the LLM
toolsToolDef[]NoTools available to the agent
handoffsstring[]NoNames of agents this agent can hand off to
modelstringNoModel override (provider-specific)
mcpServersRecord<string, McpServerConfig>NoMCP server configurations

MCP Servers

Agents can connect to MCP (Model Context Protocol) servers for additional tool access:

typescript
const agent = defineAgent({
  name: "assistant",
  description: "An assistant with filesystem access",
  prompt: "You are a helpful assistant with access to the filesystem.",
  mcpServers: {
    filesystem: {
      command: "npx",
      args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
    },
  },
});

The McpServerConfig supports:

PropertyTypeRequiredDescription
commandstringYesCommand to launch the server
argsstring[]NoCommand arguments
envRecord<string, string>NoEnvironment variables
urlstringNoURL for remote MCP servers