Learn R Programming

aisdk (version 1.1.0)

Mission: Mission Class

Description

R6 class representing a persistent, goal-oriented execution mission. A Mission is the global leadership layer above Agent/AgentTeam/Flow.

Key capabilities:

  • Full state machine: pending -> planning -> running -> succeeded/failed/stalled

  • LLM-driven auto-planning: converts a goal string into ordered MissionSteps

  • Step-level retry with exponential backoff + error-context injection

  • DAG dependency resolution (depends_on)

  • Parallel step execution (parallel = TRUE groups)

  • Checkpoint persistence: save() / resume()

  • Full audit log for post-mortem analysis

  • MissionHookHandler integration for observability

Arguments

Public fields

id

Unique mission UUID.

goal

Natural language goal description.

steps

List of MissionStep objects.

status

Mission status string.

session

SharedSession used across all steps.

model

Default model ID for this mission.

stall_policy

Named list defining failure recovery behavior.

hooks

MissionHookHandler for lifecycle events.

audit_log

List of event records in chronological order.

auto_plan

If TRUE and steps is NULL, use LLM to plan before running.

default_executor

Default executor for auto-planned steps.

Methods


Method new()

Initialize a new Mission.

Usage

Mission$new(
  goal,
  steps = NULL,
  model = NULL,
  executor = NULL,
  stall_policy = NULL,
  hooks = NULL,
  session = NULL,
  auto_plan = TRUE
)

Arguments

goal

Natural language goal description.

steps

Optional list of MissionStep objects. If NULL and auto_plan=TRUE, the LLM plans them.

model

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

executor

Default executor for all steps (Agent, AgentTeam, Flow, or function). Used for auto-planned steps when no per-step executor is specified.

stall_policy

Named list with on_tool_failure, on_step_timeout, on_max_retries, escalate_fn. Defaults to default_stall_policy().

hooks

MissionHookHandler for lifecycle events.

session

Optional SharedSession. Created automatically if NULL.

auto_plan

If TRUE, call LLM to decompose goal into steps when steps is NULL.


Method run()

Run the Mission synchronously until completion or stall.

Usage

Mission$run(model = NULL, ...)

Arguments

model

Optional model override. Falls back to self$model.

...

Additional arguments (reserved for future use).

Returns

Invisible self (inspect $status, $steps, $audit_log for results).


Method save()

Save mission state to a file for later resumption.

Usage

Mission$save(path)

Arguments

path

File path (.rds).


Method resume()

Resume a Mission from a saved checkpoint.

Usage

Mission$resume(path)

Arguments

path

File path to a previously saved mission state (.rds).

Details

Steps that are already "done" are skipped. Pending/failed/retrying steps are re-executed. The executor must be re-attached via $set_executor() or by providing a default_executor at Mission creation.


Method step_summary()

Get a summary of step statuses.

Usage

Mission$step_summary()

Returns

Named character vector: step_id -> status.


Method print()

Print method.

Usage

Mission$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

Mission$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.