create_agent: Create an Agent

View source: R/agent.R

create_agentR Documentation

Create an Agent

Description

Factory function to create a new Agent object.

Usage

create_agent(
  name,
  description,
  system_prompt = NULL,
  tools = NULL,
  skills = NULL,
  model = NULL,
  capability_models = NULL
)

Arguments

name

Unique name for this agent.

description

A clear description of what this agent does.

system_prompt

Optional system prompt defining the agent's persona.

tools

Optional list of Tool objects the agent can use.

skills

Optional character vector of skill paths or "auto".

model

Optional default model ID for this agent.

capability_models

Optional named list of capability-specific model routes.

Value

An Agent object.

Examples


if (interactive()) {
  # Create a simple math agent
  math_agent <- create_agent(
    name = "MathAgent",
    description = "Performs arithmetic calculations",
    system_prompt = "You are a math assistant. Return only numerical results."
  )

  # Run the agent
  result <- math_agent$run("Calculate 2 + 2", model = "openai:gpt-4o")

  # Create an agent with skills
  stock_agent <- create_agent(
    name = "StockAnalyst",
    description = "Stock analysis agent",
    skills = "auto"
  )
}


aisdk documentation built on May 29, 2026, 9:07 a.m.