Skip to content
Everything AgentsAgent Visualizer
Documentation

AgentScript primer

AgentScript is a YAML-flavored declarative format Salesforce Agentforce uses to describe an agent: its system instructions, configuration, variables, and the subagents that handle distinct intents. This primer covers the syntax surface this app visualizes.

File structure

A .agent file is a flat sequence of top-level blocks. Indentation defines containment (similar to YAML), and most blocks accept either inline values or block scalars introduced with | or ->.

system:
    instructions: |
        ...
config:
    developer_name: "Target_Service_Agent"
variables:
    order_number: mutable string = ""
start_agent subagent_selector:
    ...
subagent returns:
    ...
modality voice:
    voice_id: "..."

system

The systemblock carries the agent's top-level instructions and the built-in messages (e.g. welcome, error) returned to the customer.

system:
    instructions: |
        You are Target's customer service AI agent...
    messages:
        welcome: |
            Hi, I'm Target's AI assistant.
        error: "Sorry, something went wrong."

config

Identifies the agent and provides metadata used by the platform.

config:
    developer_name: "Target_Service_Agent"
    agent_label: "Target Service Agent"
    agent_type: "AgentforceServiceAgent"
    description: "Customer service agent for returns and price match."

variables

Typed slots referenced from reasoning and action wiring. Variables can be mutable or linked (bound to a record source like @VoiceCall.Id).

variables:
    order_number: mutable string = ""
        description: "The customer's order number..."
    customer_verified: mutable boolean = False
        description: "Identity-verification gate."
    VoiceCallId: linked string
        source: @VoiceCall.Id

start_agent

The entry router. Like a subagent, but it's where every conversation begins. Most start agents are pure routers — their only job is to call a transition action.

start_agent subagent_selector:
    label: "Subagent Selector"
    reasoning:
        instructions: |
            ...routing rules...
        actions:
            go_to_returns: @utils.transition to @subagent.returns
                description: "Returns, refunds..."

subagent

A focused workflow with its own reasoning instructions, action bindings, and (often) inline action definitions. Subagents communicate by transitioning to each other or by invoking actions.

subagent returns:
    label: "Order Returns"
    description: |
        Handles return, refund, exchange...
    before_reasoning:
        if @variables.customer_verified == False:
            transition to @subagent.customer_verification
    reasoning:
        instructions: ->
            | TARGET RETURNS WORKFLOW...
        actions:
            check_eligibility: @actions.Get_Return_Eligibility_By_Item
                with memberId = @variables.member_id
                with orderNumber = @variables.order_number

The graph view renders before_reasoning and after_reasoning transitions as dashed flow edges between subagents.

actions

Actions are typed, callable units backed by Apex (apex://...) or other runtime targets. They declare structured inputs and outputs that other parts of the script wire variables into.

actions:
    Get_Order_Details:
        label: "Get Order Details"
        target: "apex://NF_GetOrderDetailsHandler"
        inputs:
            orderNumber: string
                is_required: True
        outputs:
            isSuccess: boolean
            memberId: string

modality / connection

Channel configuration — voice settings, telephony adapters, and similar. The graph surfaces this on the system node so it's visible at a glance.

modality voice:
    voice_id: "UgBBYS2sOqTuMpoF3BR0"
    outbound_speed: 1.0
connection telephony:
    adaptive_response_allowed: True

Tip

Open any uploaded file from the sidebar to see how these constructs render in the graph. Click a node to inspect its source-derived metadata in the side panel. Switch to the Source tab to read the original file.

Upload your first .agent file →