ACDL Examples

Explore ACDL specifications for common agentic patterns and real-world systems

Card Actions

Preview View rendered visualization
Open in Live Editor Modify the code interactively

Basic Patterns

Foundational structures for LLM context management

Basic Context

The simplest ACDL specification: a system message with instructions

Basic
Context[@T]: {
    S: PERSONA
    S: INSTRUCTIONS
}
Context[@T]:
Role: System
PERSONA
Role: System
INSTRUCTIONS

Basic RAG

Retrieval-augmented generation with document context

RAG
BasicRAG[@T]: {
    S: INSTRUCTIONS
    U: {
        Name docs := k_relevant_docs(env.user_input[@T])
        ForEach(i: range(1, $docs.len)) {
            $docs[i].source
            $docs[i].content
        }
        ANSWER_Q_FROM_DOCS
        env.user_input[@T]
    }
}
BasicRAG[@T]:
Role: System
INSTRUCTIONS
Role: User
↻ ForEach i : 1 ... $docs.len
$docs[i].source
$docs[i].content
ANSWER_Q_FROM_DOCS
env.user_input[@T]

ReAct Patterns

Reasoning and action loops for tool-using agents

ReAct Base

Basic ReAct loop with tool reasoning and responses

ReAct
ReactBase[@T]: {
    S: {
        INSTRUCTIONS
        AVAILABLE_TOOLS
    }
    U: env.user_input[@1]  // history
    ForEach(@t: range(1, @T-1)) {
        A: {
            resp.tool_reasoning[@t]
            sys.tool_used[@t]
        }
        T: sys.tool_used[@t].tool_response
    }
    S: USE_TOOLS_TO_SOLVE_TASK
}
ReactBase[@T]:
Role: System
INSTRUCTIONS
AVAILABLE_TOOLS
Role: User
env.user_input[@1]
↻ ForEach @t : 1 ... @T-1
Role: Assistant
resp.tool_reasoning[@t]
sys.tool_used[@t]
Role: Tool
sys.tool_used[@t].tool_response
Role: System
USE_TOOLS_TO_SOLVE_TASK

ReAct No Reasoning in History

Variant without reasoning traces in action history

ReAct Variant
ReactNoReasoningInHistory[@T]: {
    S: {
        INSTRUCTIONS
        AVAILABLE_TOOLS
    }
    U: env.user_input[@1]  // history
    ForEach(@t: range(1, @T-1)) {
        A: sys.tool_used[@t]
        T: sys.tool_used[@t].tool_response
    }
    S: USE_TOOLS_TO_SOLVE_TASK
}
ReactNoReasoningInHistory[@T]:
Role: System
INSTRUCTIONS
AVAILABLE_TOOLS
Role: User
env.user_input[@1]
↻ ForEach @t : 1 ... @T-1
Role: Assistant
sys.tool_used[@t]
Role: Tool
sys.tool_used[@t].tool_response
Role: System
USE_TOOLS_TO_SOLVE_TASK

ReAct with Tool-RAG

ReAct pattern with dynamic tool retrieval

ReAct RAG
ReactToolRag[@T]: {
    S: INSTRUCTIONS
    U: env.user_input[@1]
    ForEach(@t: range(1, @T-1)) {
        A: {
            resp.tool_reasoning[@t]
            sys.tool_used[@t]
        }
        T: sys.tool_used[@t].tool_response
    }
    S: {
        Name tools := retrieve_tools(env.context[@T])
        ForEach(tool: $tools) { $tool.description }
        USE_TOOLS_TO_SOLVE_TASK
    }
}
ReactToolRag[@T]:
Role: System
INSTRUCTIONS
Role: User
env.user_input[@1]
↻ ForEach @t : 1 ... @T-1
Role: Assistant
resp.tool_reasoning[@t]
sys.tool_used[@t]
Role: Tool
sys.tool_used[@t].tool_response
Role: System
↻ ForEach tool : $tools
$tool.description
USE_TOOLS_TO_SOLVE_TASK

Real-World Systems

Production-grade agent architectures

OpenCode (Claude Code-like)

Coding assistant with conversation compaction, plan mode, and tool use

ReAct Production
OpenCodeMain[@T.I]: {
  S: {
    SYSTEM_PROMPT
    ENV_INFO(env.working_directory[@1], ...)
  }
  Mark 2 {
  Name C := sys.last_compaction_time[@T]
  If @$C > 1 {
    U: WHAT_DID_WE_DO
    A: sys.conversation_summary[@$C]
  }
  }
  ForEach(@t: range(@$C, @T)) {
    U: {
      env.user_input[@t]
      Mark 3 {
      If @T == @t {
        If sys.is_plan_mode[@t] { PLAN_MODE_REMINDER }
        If sys.is_build_mode[@t] && sys.prev_is_plan[@t] {
          LEAVE_PLAN_MODE_REMINDER
        }
      }
      }
    }
    PromptEndsHere when (@T == @t && @T.0)
    ForEach(@i: range(1, @t.substeps)) {
      Mark 1 {
      A: {
        ForEach(tool: sys.tool_requests[@t.i]) {
          tool.id_name_and_args
        }
      }
      ForEach(tool: tool_requests[@t.i]) {
        T: tool.id_and_response
      }
      }
      PromptEndsHere when (@T == @t && @T.I)
    }
    A: sys.response[@t]
  }
}
OpenCodeMain[@T.I]:
Role: System
SYSTEM_PROMPT
ENV_INFO(env.working_directory[@1], ...)
Mark 2
? If @$C > 1
Role: User
WHAT_DID_WE_DO
Role: Assistant
sys.conversation_summary[@$C]
↻ ForEach @t : @$C ... @T
Role: User
env.user_input[@t]
Mark 3
? If @T == @t
? If sys.is_plan_mode[@t]
PLAN_MODE_REMINDER
? If sys.is_build_mode[@t] && sys.prev_is_plan[@t]
LEAVE_PLAN_MODE_REMINDER
PromptEndsHere when (@T == @t && @T.0)
Mark 1
↻ ForEach @i : 1 ... @t.substeps
Role: Assistant
↻ ForEach tool : sys.tool_requests[@t.i]
tool.id_name_and_args
↻ ForEach tool : tool_requests[@t.i]
Role: Tool
tool.id_and_response
PromptEndsHere when (@T == @t && @T.I)
Role: Assistant
sys.response[@t]

OpenClaw

Persistent agent with heartbeat timer, pending messages, and memory

ReAct
OpenClaw[@T.I]: {
  S: SystemPrompt()
  Mark 2 {
  Name C := sys.last_compaction_time[@T]
  If (@$C > 1) {
    U: { THIS_IS_A_SUMMARY  sys.conversation_summary[@$C] }
    A: resp.response[@$C]
  }
  }
  ForEach(t: range(@$C + 1, @T)) {
    U: {
      Mark 6 {
      ForEach(m: range(1, sys.pending_messages[@t].len)) {
        sys.pending_messages[@t][m].date_time
        sys.pending_messages[@t][m].message
      }
      }
      Mark 5 {
      Switch env.input_source[@t] {
        Case user: { Mark 4 { sys.date_time[@t] } env.user_query[@t] }
        Case heartbeat_timer: { HEARTBEAT_INSTRUCTIONS }
      }
      }
    }
    PromptEndsHere when (@t == @T && T.0)
    ForEach(i: range(1, @t.substeps)) {
      Mark 1 {
      A: {
        ForEach(tool: sys.tool_requests[@t.i]) {
          tool.id_name_and_arg
        }
      }
      ForEach(tool: sys.tool_requests[@t.i]) {
        T: tool.id_and_response
      }
      }
      PromptEndsHere when (@t == @T && @T.I)
    }
    A: resp.response[@t]
  }
}
OpenClaw[@T.I]:
Role: System
SystemPrompt()
Mark 2
? If @$C > 1
Role: User
THIS_IS_A_SUMMARY
sys.conversation_summary[@$C]
Role: Assistant
resp.response[@$C]
↻ ForEach t : @$C + 1 ... @T
Role: User
Mark 6
↻ ForEach m : 1 ... sys.pending_messages[@t].len
sys.pending_messages[@t][m].date_time
sys.pending_messages[@t][m].message
Mark 5
⇢ Switch env.input_source[@t]
Case user: Mark 4 sys.date_time[@t] env.user_query[@t]
Case heartbeat_timer: HEARTBEAT_INSTRUCTIONS
PromptEndsHere when (@t == @T && T.0)
Mark 1
↻ ForEach i : 1 ... @t.substeps
Role: Assistant
↻ ForEach tool : sys.tool_requests[@t.i]
tool.id_name_and_arg
↻ ForEach tool : sys.tool_requests[@t.i]
Role: Tool
tool.id_and_response
PromptEndsHere when (@t == @T && @T.I)
Role: Assistant
resp.response[@t]

Pokemon Agent

Game-playing agent with hierarchical summarization and critique

ReAct Memory
Pokemon[@T]: {
  U: env.image.HUD // heads up display screenshot
  S: { INTRO GOAL CONVENTIONS AVAILABLE_TOOLS }
  A: {
    If @T>1 {
      ForEach(i: range(@T-(@T%100),@T-1)) {
        resp.action[@i]
      }
      If @T%100==0 {
        Name actions := [resp.action[@t] for t in range(@T-100, @T)]
        summarize($actions)
      }
    }
  }
  If @T%25==0 {
    A: critique_performance(sys.history[@T])
  }
  U: env.xml_map[@T]
  S: INSTRUCTION_TO_EXPLORE
  S: CHOOSE_ACTION
}
Pokemon[@T]:
Role: User
env.image.HUD // heads up display screenshot
Role: System
INTRO GOAL CONVENTIONS AVAILABLE_TOOLS
Role: Assistant
? If @T > 1
↻ ForEach i : @T-(@T%100) ... @T-1
resp.action[@i]
? If @T%100 == 0
summarize($actions)
? If @T%25 == 0
Role: Assistant
critique_performance(sys.history[@T])
Role: User
env.xml_map[@T]
Role: System
INSTRUCTION_TO_EXPLORE
Role: System
CHOOSE_ACTION

Multi-Agent Simulation

Agent with memory, peer awareness, and conversation handling

Multi-Agent
// agent is self, agent2 is who we converse with
MultiAgent[@T, agent]: {
  S: INSTRUCTIONS
  U: {
    // history (last 50 actions)
    ForEach(@t: range(@T-50, @T-1)) {
      sys[agent].performed_action[@t]
      sys[agent].performed_action[@t].result
    }
    sys[agent].inventory[@T]
    // whom I see and what I know
    ForEach(a: env.seen_actors[@T]) {
      a.name  a.description
      retrieve(sys[agent].memory[@T], a.name)
    }
    If sys[agent].in_conversation[@T] {
      ForEach(convTurn: sys[agent].conversation[@T]) {
        convTurn.speaker  convTurn.content
      }
    }
  }
  S: {
    sys[agent].available_actions
    If sys[agent].in_conversation[@T] {
      CONTINUE_THE_CONVERSATION
    }
  }
}
MultiAgent[@T, agent]:
Role: System
INSTRUCTIONS
Role: User
// history (last 50 actions)
↻ ForEach @t : @T-50 ... @T-1
sys[agent].performed_action[@t]
sys[agent].performed_action[@t].result
sys[agent].inventory[@T] // whom I see and what I know
↻ ForEach a : env.seen_actors[@T]
a.name a.description
retrieve(sys[agent].memory[@T], a.name)
? If sys[agent].in_conversation[@T]
↻ ForEach convTurn : sys[agent].conversation[@T]
convTurn.speaker convTurn.content
Role: System
sys[agent].available_actions
? If sys[agent].in_conversation[@T]
CONTINUE_THE_CONVERSATION