Agent Script
Write Agent Script DSL for complex agent conversations. AI handles the tricky syntax so you can focus on the conversation design.
Skill Details
Install this skill
Works with
Agent Script is the code-first path for deterministic Agentforce agents. Use this skill when the user is authoring .agent files, building finite-state topic flows, or needs repeatable control over routing, variables, actions, and publish behavior.
Start with the shortest guide first: references/activation-checklist.md
When This Skill Owns the TaskWorkflow
Use sf-ai-agentscript when the work involves:
- creating or editing
.agentfiles - deterministic topic routing, guards, and transitions
- Agent Script CLI workflows (
sf agent generate,sf agent validate,sf agent publish) - slot filling, instruction resolution, post-action loops, or FSM design
Delegate elsewhere when the user is:
- maintaining legacy Setup UI / Agent Builder agents → sf-ai-agentforce
- designing persona / tone / voice → sf-ai-agentforce-persona
- building formal test plans or coverage loops → sf-ai-agentforce-testing
Required Context to Gather FirstWorkflow
Ask for or infer:
- agent purpose and whether Agent Script is truly the right fit
- Service Agent vs Employee Agent
- target org and publish intent
- expected actions / targets (Flow, Apex, PromptTemplate, etc.)
- whether the request is authoring, validation, preview, or publish troubleshooting
Activation Checklist
Before you author or fix any .agent file, verify these first:
start_agent blockTrue / Falseelse if and no nested ifactions: block@inputs in set expressionslinked variables have no defaultslinked variables do not use object / list typesagent_type@actions. prefixes consistentlyrun @actions.X only when X is a topic-level action definition with target:@system_variables.user_input contains/startswith/endswith for intent routingis_displayable: False + is_used_by_planner: True@outputs.X is scalar — inspect the output schema before branching or assignmentFor the expanded version, use references/activation-checklist.md.
Non-Negotiable Rules
1) Service Agent vs Employee Agent
| Agent type | Required | Forbidden / caution |
|---|---|---|
AgentforceServiceAgent | Valid default_agent_user, correct permissions, target-org checks | Publishing without a real Einstein Agent User |
AgentforceEmployeeAgent | Explicit agent_type | Supplying default_agent_user |
| Field | Rule | |
developer_name | Must match folder / bundle name | |
agent_description | Use instead of legacy description | |
agent_type | Set explicitly every time | |
default_agent_user | Service Agents only | |
| Task | Delegate to | Why |
Build flow:// targets | sf-flow | Flow creation / validation |
| Build Apex action targets | sf-apex | @InvocableMethod and business logic |
| Test topic routing / actions | sf-ai-agentforce-testing | Formal test specs and fix loops |
| Deploy / publish | sf-deploy | Deployment orchestration |
| Symptom | Likely cause | Read next |
Internal Error during publish | invalid Service Agent user or missing action I/O | references/agent-user-setup.md, references/actions-reference.md |
invalid input/output parameters on prompt template action | Target template is in Draft status — activate it first | references/action-prompt-templates.md |
| Parser rejects conditionals | else if, nested if, empty if body | references/syntax-reference.md |
| Action target issues | missing Flow / Apex target, inactive Flow, bad schemas | references/actions-reference.md |
| Prompt template runs but user sees blank response | prompt output marked is_displayable: True | references/production-gotchas.md, references/action-prompt-templates.md |
| Prompt action runs but planner behaves like output is missing | output hidden from direct display but not planner-visible | references/production-gotchas.md, references/actions-reference.md |
ACTION_NOT_IN_SCOPE on run @actions.X | run points at a utility / delegation / unresolved action instead of a topic-level target-backed definition | references/syntax-reference.md, references/instruction-resolution.md |
| Deterministic cancel / revise / URL checks behave inconsistently | raw @system_variables.user_input matching or string-method guards are being used as control-flow-critical validation | references/syntax-reference.md, references/production-gotchas.md |
@outputs.X comparisons or assignments behave unexpectedly | the action output is structured/wrapped, not a plain scalar | references/actions-reference.md, references/syntax-reference.md |
| Preview and runtime disagree | linked vars / context / known platform issues | references/known-issues.md |
| Validate passes but publish fails | org-specific user / permission / retrieve-back issue | references/production-gotchas.md, references/cli-guide.md |
| Score | Meaning | |
| 90+ | Deploy with confidence | |
| 75–89 | Good, review warnings | |
| 60–74 | Needs focused revision | |
| < 60 | Block publish |
Full rubric: references/scoring-rubric.md
Official Resources
More in Agentforce & AI
Agentforce Builder
Build Agentforce agents in Setup. AI writes the topics, actions, and prompt templates — and follows Salesforce's own best practices.
Agent Persona
Design your agent's personality, tone, and voice. AI produces a complete persona document you can paste directly into Agent Builder.
Agent Testing
Test your Agentforce agents before going live. AI writes test specs, simulates conversations, and tells you what needs fixing.
Navigate Agentforce & AI