Learn R Programming

aisdk (version 1.1.0)

create_mission: Create a Mission

Description

Factory function to create a new Mission object.

Usage

create_mission(
  goal,
  steps = NULL,
  model = NULL,
  executor = NULL,
  stall_policy = NULL,
  hooks = NULL,
  session = NULL,
  auto_plan = TRUE
)

Value

A Mission object.

Arguments

goal

Natural language goal description.

steps

Optional list of MissionStep objects. If NULL and auto_plan=TRUE, the LLM will decompose the goal into steps automatically.

model

Default model ID (e.g., "anthropic:claude-opus-4-6").

executor

Default executor (Agent, AgentTeam, Flow, or R function). Required when auto_plan = TRUE.

stall_policy

Named list for failure recovery. See default_stall_policy().

hooks

MissionHookHandler for lifecycle events.

session

Optional SharedSession. Created automatically if NULL.

auto_plan

If TRUE (default), use LLM to create steps when none are provided.

Examples

Run this code
# \donttest{
if (interactive()) {
  # Auto-planned mission
  agent <- create_agent("Analyst", "Analyzes data", model = "openai:gpt-4o")
  mission <- create_mission(
    goal     = "Load the iris dataset and summarize each species",
    executor = agent,
    model    = "openai:gpt-4o"
  )
  mission$run()

  # Manual steps
  mission2 <- create_mission(
    goal  = "Data pipeline",
    steps = list(
      create_step("step_1", "Load CSV data", executor = agent),
      create_step("step_2", "Summarize statistics", executor = agent,
                  depends_on = "step_1")
    ),
    model = "openai:gpt-4o"
  )
  mission2$run()
}
# }

Run the code above in your browser using DataLab