Skip to content

defineAgent()

Helper to define an agent with type checking.

Signature

typescript
function defineAgent(config: {
  name: string;
  description: string;
  prompt: string;
  tools?: ToolDef[];
  handoffs?: string[];
  model?: string;
  mcpServers?: Record<string, McpServerConfig>;
}): AgentDef

Parameters

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

Returns

AgentDef — the agent definition object.

Example

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

const agent = defineAgent({
  name: "researcher",
  description: "Research agent that searches the web",
  prompt: "You are a research assistant. Use tools to find information.",
  tools: [searchTool],
  handoffs: ["math", "writer"],
});