sf-ai-agentforce

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- TIER: 1 | ENTRY POINT --> <!-- This is the starting document — read this FIRST --> <!-- Progressive disclosure: SKILL.md → Detailed Docs (Tier 2–3) -->
<!-- TIER: 1 | ENTRY POINT --> <!-- This is the starting document — read this FIRST --> <!-- Progressive disclosure: SKILL.md → Detailed Docs (Tier 2–3) -->

sf-ai-agentforce: Standard Agentforce Platform Development

sf-ai-agentforce:标准Agentforce平台开发

Expert Agentforce developer specializing in the Setup UI / Agentforce Builder approach to agent development. Covers topic and action configuration, GenAiFunction/GenAiPlugin metadata, PromptTemplate authoring, Einstein Models API, and custom Lightning types.
Code-first alternative: For programmatic agent development using Agent Script DSL (
.agent
files), use sf-ai-agentscript instead. This skill covers the declarative, UI-driven approach.

专业Agentforce开发者,专注于通过Setup UI / Agentforce Builder方法进行代理开发。涵盖主题与动作配置、GenAiFunction/GenAiPlugin元数据、PromptTemplate编写、Einstein Models API以及自定义Lightning类型。
代码优先替代方案:如果要使用Agent Script DSL(
.agent
文件)进行程序化代理开发,请改用sf-ai-agentscript。本技能涵盖的是声明式、UI驱动的开发方法。

Overview

概述

Salesforce Agentforce enables organizations to build autonomous AI agents that handle customer interactions, automate tasks, and surface insights. This skill focuses on the standard platform approach:
  • Agentforce Builder (Setup UI) for visual agent configuration
  • GenAiFunction and GenAiPlugin metadata for registering actions
  • PromptTemplate metadata for reusable AI prompts
  • Einstein Models API (
    aiplatform.ModelsAPI
    ) for native LLM access in Apex
  • Custom Lightning Types (
    LightningTypeBundle
    ) for rich agent action UIs
Salesforce Agentforce 允许企业构建自主AI代理,用于处理客户交互、自动化任务并呈现洞察。本技能聚焦于标准平台方法
  • Agentforce Builder(Setup UI):用于可视化代理配置
  • GenAiFunctionGenAiPlugin 元数据:用于注册动作
  • PromptTemplate 元数据:用于可复用AI提示词
  • Einstein Models API
    aiplatform.ModelsAPI
    ):用于在Apex中原生访问大语言模型(LLM)
  • 自定义Lightning类型
    LightningTypeBundle
    ):用于丰富的代理动作UI

Two Approaches to Agentforce

Agentforce的两种开发方式

ApproachSkillWhen to Use
Setup UI / Agentforce Builder
sf-ai-agentforce
(this skill)
Declarative agent config, point-and-click topics/actions
Agent Script DSL
sf-ai-agentscript
Code-first
.agent
files, FSM architecture, version-controlled agents
Both approaches produce agents that run on the same Agentforce runtime. Choose based on team preference and complexity requirements.

方式对应技能使用场景
Setup UI / Agentforce Builder
sf-ai-agentforce
(本技能)
声明式代理配置,通过点击操作配置主题/动作
Agent Script DSL
sf-ai-agentscript
代码优先的
.agent
文件,有限状态机(FSM)架构,可版本控制的代理
两种方式构建的代理都运行在同一个Agentforce运行时。可根据团队偏好和复杂度需求进行选择。

Core Concepts

核心概念

Topics

主题(Topics)

Topics are the primary organizational unit for an agent's capabilities. Each topic groups related actions and instructions around a specific domain.
  • Description: Tells the LLM planner when to route to this topic (must be specific and unambiguous)
  • Scope: Defines what the topic can and cannot do (helps the planner make routing decisions)
  • Instructions: Step-by-step guidance the agent follows when a topic is active
  • Actions: The operations (Flow, Apex, Prompt Template) the agent can invoke within this topic
In the Agentforce Builder, topics are configured via Setup → Agentforce → Agents → [Agent] → Topics.
主题是代理能力的主要组织单元。每个主题围绕特定领域将相关的动作指令分组。
  • 描述:告知LLM规划器何时路由到该主题(必须具体且明确)
  • 范围:定义主题可处理和不可处理的内容(帮助规划器做出路由决策)
  • 指令:主题激活时代理需遵循的分步指导
  • 动作:代理在该主题内可调用的操作(Flow、Apex、Prompt Template)
在Agentforce Builder中,可通过Setup → Agentforce → Agents → [代理名称] → Topics配置主题。

Actions

动作(Actions)

Actions are the executable operations an agent can perform. Each action wraps an underlying invocation target:
Target TypeDescriptionRegistered Via
FlowInvokes an Autolaunched FlowGenAiFunction with
invocationTargetType: flow
ApexInvokes an
@InvocableMethod
GenAiFunction with
invocationTargetType: apex
Prompt TemplateInvokes a PromptTemplateGenAiFunction with
invocationTargetType: prompt
Standard ActionBuilt-in platform actions (send email, create record)Pre-registered by Salesforce
动作是代理可执行的操作。每个动作封装了底层的调用目标:
目标类型描述注册方式
Flow调用自动启动流通过
invocationTargetType: flow
的GenAiFunction
Apex调用
@InvocableMethod
通过
invocationTargetType: apex
的GenAiFunction
Prompt Template调用PromptTemplate通过
invocationTargetType: prompt
的GenAiFunction
标准动作平台内置动作(发送邮件、创建记录)由Salesforce预先注册

Instructions

指令(Instructions)

Instructions guide the agent's behavior within a topic. They are natural language directives that tell the LLM:
  • What steps to follow
  • When to invoke specific actions
  • How to handle edge cases and errors
  • When to escalate to a human agent

指令指导代理在主题内的行为。它们是自然语言指令,告知LLM:
  • 需要执行哪些步骤
  • 何时调用特定动作
  • 如何处理边缘情况和错误
  • 何时将问题升级给人工代理

Agent Builder Workflow

Agent Builder工作流

Step-by-Step: Creating an Agent via Setup UI

分步指南:通过Setup UI创建代理

1. Navigate to Agentforce Builder
Setup → Agentforce → Agents → New Agent
2. Choose Agent Type
  • Service Agent — Customer-facing support and service
  • Employee Agent — Internal productivity and automation
3. Add Topics For each capability area:
  • Provide a clear Name and Description
  • Write Instructions that guide the agent's reasoning
  • Add a Scope statement (what's in/out of bounds)
4. Configure Actions per Topic Assign actions to each topic. Actions can target:
  • Autolaunched Flows (most common)
  • Apex InvocableMethods (via GenAiFunction)
  • Prompt Templates (for LLM-generated content)
  • Standard platform actions
5. Set Action Inputs & Outputs For each action:
  • Define inputs the agent collects from the user (slot filling)
  • Define outputs the agent uses in its response
  • Mark which outputs are displayable to the user
6. Configure Agent-Level Settings
  • System Instructions: Global persona and behavior guidelines
  • Default Agent User: The running user context for the agent
  • Welcome Message: Initial greeting
  • Error Message: Fallback when something goes wrong
7. Preview & Test
bash
undefined
1. 导航至Agentforce Builder
Setup → Agentforce → Agents → New Agent
2. 选择代理类型
  • 服务代理 — 面向客户的支持与服务
  • 员工代理 — 内部生产力与自动化
3. 添加主题 针对每个能力领域:
  • 提供清晰的名称描述
  • 编写指导代理推理的指令
  • 添加范围声明(明确可处理和不可处理的内容)
4. 为每个主题配置动作 为每个主题分配动作。动作可指向:
  • 自动启动流(最常用)
  • Apex InvocableMethods(通过GenAiFunction)
  • Prompt Templates(用于LLM生成内容)
  • 标准平台动作
5. 设置动作输入与输出 针对每个动作:
  • 定义代理从用户处收集的输入(槽位填充)
  • 定义代理在响应中使用的输出
  • 标记哪些输出可展示给用户
6. 配置代理级设置
  • 系统指令:全局角色与行为准则
  • 默认代理用户:代理运行时的用户上下文
  • 欢迎消息:初始问候语
  • 错误消息:出现问题时的回退提示
7. 预览与测试
bash
undefined

Preview in Agentforce Builder (uses standard org auth)

在Agentforce Builder中预览(使用标准组织权限)

sf agent preview --api-name MyAgent --target-org MyOrg

**8. Publish**
```bash
sf agent publish authoring-bundle --api-name MyAgent --target-org MyOrg
sf agent preview --api-name MyAgent --target-org MyOrg

**8. 发布**
```bash
sf agent publish authoring-bundle --api-name MyAgent --target-org MyOrg

Publish (skip metadata retrieve for CI/CD pipelines, v2.122.6+)

发布(在CI/CD流水线中跳过元数据检索,版本v2.122.6+)

sf agent publish authoring-bundle --api-name MyAgent --skip-retrieve --target-org MyOrg

---
sf agent publish authoring-bundle --api-name MyAgent --skip-retrieve --target-org MyOrg

---

GenAiFunction & GenAiPlugin Metadata

GenAiFunction & GenAiPlugin元数据

GenAiFunction

GenAiFunction

A
GenAiFunction
registers a single action that an Agentforce agent can invoke. It wraps an underlying Flow, Apex method, or Prompt Template.
Metadata XML Structure:
xml
<?xml version="1.0" encoding="UTF-8"?>
<GenAiFunction xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Look Up Order Status</masterLabel>
    <developerName>Lookup_Order_Status</developerName>
    <description>Retrieves the current status of a customer order</description>

    <!-- Target: the Flow, Apex, or Prompt to invoke -->
    <invocationTarget>Get_Order_Status_Flow</invocationTarget>
    <invocationTargetType>flow</invocationTargetType>

    <!-- Capability: tells the LLM planner WHEN to use this action -->
    <capability>
        Look up the current status of a customer's order when they
        ask about shipping, delivery, or order tracking.
    </capability>

    <!-- Inputs: what the agent collects from the user -->
    <genAiFunctionInputs>
        <developerName>orderNumber</developerName>
        <description>The customer's order number</description>
        <dataType>Text</dataType>
        <isRequired>true</isRequired>
    </genAiFunctionInputs>

    <!-- Outputs: what the action returns -->
    <genAiFunctionOutputs>
        <developerName>orderStatus</developerName>
        <description>Current status of the order</description>
        <dataType>Text</dataType>
        <isRequired>true</isRequired>
    </genAiFunctionOutputs>
</GenAiFunction>
File Location:
force-app/main/default/genAiFunctions/Lookup_Order_Status.genAiFunction-meta.xml
GenAiFunction
用于注册Agentforce代理可调用的单个动作。它封装了底层的Flow、Apex方法或Prompt Template。
元数据XML结构:
xml
<?xml version="1.0" encoding="UTF-8"?>
<GenAiFunction xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Look Up Order Status</masterLabel>
    <developerName>Lookup_Order_Status</developerName>
    <description>Retrieves the current status of a customer order</description>

    <!-- Target: the Flow, Apex, or Prompt to invoke -->
    <invocationTarget>Get_Order_Status_Flow</invocationTarget>
    <invocationTargetType>flow</invocationTargetType>

    <!-- Capability: tells the LLM planner WHEN to use this action -->
    <capability>
        Look up the current status of a customer's order when they
        ask about shipping, delivery, or order tracking.
    </capability>

    <!-- Inputs: what the agent collects from the user -->
    <genAiFunctionInputs>
        <developerName>orderNumber</developerName>
        <description>The customer's order number</description>
        <dataType>Text</dataType>
        <isRequired>true</isRequired>
    </genAiFunctionInputs>

    <!-- Outputs: what the action returns -->
    <genAiFunctionOutputs>
        <developerName>orderStatus</developerName>
        <description>Current status of the order</description>
        <dataType>Text</dataType>
        <isRequired>true</isRequired>
    </genAiFunctionOutputs>
</GenAiFunction>
文件位置:
force-app/main/default/genAiFunctions/Lookup_Order_Status.genAiFunction-meta.xml

Invocation Target Types

调用目标类型

invocationTargetType
Target ValueNotes
flow
Flow API nameFlow must be Active
apex
Apex class nameClass must have
@InvocableMethod
prompt
PromptTemplate API nameTemplate must be Active
invocationTargetType
目标值说明
flow
Flow API名称Flow必须处于激活状态
apex
Apex类名类必须包含
@InvocableMethod
prompt
PromptTemplate API名称模板必须处于激活状态

GenAiPlugin

GenAiPlugin

A
GenAiPlugin
groups multiple
GenAiFunction
entries into a logical unit. This is useful for organizing related actions.
xml
<?xml version="1.0" encoding="UTF-8"?>
<GenAiPlugin xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Order Management Plugin</masterLabel>
    <developerName>Order_Management_Plugin</developerName>
    <description>Actions for managing customer orders</description>

    <genAiFunctions>
        <functionName>Lookup_Order_Status</functionName>
    </genAiFunctions>
    <genAiFunctions>
        <functionName>Cancel_Order</functionName>
    </genAiFunctions>
    <genAiFunctions>
        <functionName>Return_Order</functionName>
    </genAiFunctions>
</GenAiPlugin>
File Location:
force-app/main/default/genAiPlugins/Order_Management_Plugin.genAiPlugin-meta.xml
GenAiPlugin
将多个
GenAiFunction
条目分组为一个逻辑单元。这有助于组织相关动作。
xml
<?xml version="1.0" encoding="UTF-8"?>
<GenAiPlugin xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>Order Management Plugin</masterLabel>
    <developerName>Order_Management_Plugin</developerName>
    <description>Actions for managing customer orders</description>

    <genAiFunctions>
        <functionName>Lookup_Order_Status</functionName>
    </genAiFunctions>
    <genAiFunctions>
        <functionName>Cancel_Order</functionName>
    </genAiFunctions>
    <genAiFunctions>
        <functionName>Return_Order</functionName>
    </genAiFunctions>
</GenAiPlugin>
文件位置:
force-app/main/default/genAiPlugins/Order_Management_Plugin.genAiPlugin-meta.xml

Deployment Order

部署顺序

  1. Deploy the underlying Flow / Apex / PromptTemplate first
  2. Deploy GenAiFunction metadata (references the targets)
  3. Deploy GenAiPlugin metadata (references the functions)
  4. Publish the Agent (references the plugin/functions via topics)
bash
undefined
  1. 先部署底层的Flow / Apex / PromptTemplate
  2. 部署GenAiFunction元数据(引用目标)
  3. 部署GenAiPlugin元数据(引用函数)
  4. 发布代理(通过主题引用插件/函数)
bash
undefined

Step 1: Deploy targets

步骤1:部署目标

sf project deploy start -m "Flow:Get_Order_Status_Flow" --target-org MyOrg
sf project deploy start -m "Flow:Get_Order_Status_Flow" --target-org MyOrg

Step 2: Deploy GenAiFunction

步骤2:部署GenAiFunction

sf project deploy start -m "GenAiFunction:Lookup_Order_Status" --target-org MyOrg
sf project deploy start -m "GenAiFunction:Lookup_Order_Status" --target-org MyOrg

Step 3: Deploy GenAiPlugin (optional grouping)

步骤3:部署GenAiPlugin(可选分组)

sf project deploy start -m "GenAiPlugin:Order_Management_Plugin" --target-org MyOrg
sf project deploy start -m "GenAiPlugin:Order_Management_Plugin" --target-org MyOrg

Step 4: Publish agent

步骤4:发布代理

sf agent publish authoring-bundle --api-name MyAgent --target-org MyOrg

---
sf agent publish authoring-bundle --api-name MyAgent --target-org MyOrg

---

PromptTemplate Configuration

PromptTemplate配置

PromptTemplate
is the metadata type for creating reusable AI prompts. Templates can be invoked by Agentforce agents (via GenAiFunction), Einstein Prompt Builder, Apex code, and Flows.
Template Types:
flexPrompt
|
salesGeneration
|
fieldCompletion
|
recordSummary
Variable Types:
freeText
(runtime input) |
recordField
(SObject field binding) |
relatedList
(child records) |
resource
(Static Resource)
Key Integration Points:
  • Agent Action: Register a GenAiFunction with
    invocationTargetType: prompt
  • Apex:
    ConnectApi.EinsteinLlm.generateMessagesForPromptTemplate()
  • Flow: Use the "Prompt Template" action element
Full reference: See docs/prompt-templates.md for complete metadata structure, variable types, examples, Data Cloud grounding, and best practices.

PromptTemplate
是用于创建可复用AI提示词的元数据类型。模板可被Agentforce代理(通过GenAiFunction)、Einstein Prompt Builder、Apex代码以及Flow调用。
模板类型:
flexPrompt
|
salesGeneration
|
fieldCompletion
|
recordSummary
变量类型:
freeText
(运行时输入) |
recordField
(SObject字段绑定) |
relatedList
(子记录) |
resource
(静态资源)
关键集成点:
  • 代理动作:注册
    invocationTargetType: prompt
    的GenAiFunction
  • Apex
    ConnectApi.EinsteinLlm.generateMessagesForPromptTemplate()
  • Flow:使用“Prompt Template”动作元素
完整参考:请查看docs/prompt-templates.md获取完整元数据结构、变量类型、示例、Data Cloud grounding以及最佳实践。

Models API

Models API

The Einstein Models API (
aiplatform.ModelsAPI
) enables native LLM access from Apex without external HTTP callouts. Use it for custom AI logic beyond what Agentforce topics/actions provide.
Available Models:
  • sfdc_ai__DefaultOpenAIGPT4OmniMini
    — Cost-effective general tasks
  • sfdc_ai__DefaultOpenAIGPT4Omni
    — Complex reasoning
  • sfdc_ai__DefaultAnthropic
    — Nuanced understanding
  • sfdc_ai__DefaultGoogleGemini
    — Multimodal tasks
Key Patterns:
  • Queueable for single-record async AI processing
  • Batch for bulk processing (scope size 10–20)
  • Platform Events for notifying completion to LWC/Flow
Prerequisites: Einstein Generative AI enabled, API v61.0+, Einstein Generative AI User permission set assigned.
Full reference: See docs/models-api.md for complete Apex examples, Queueable/Batch patterns, Chatter integration, and governor limit guidance.

Einstein Models API
aiplatform.ModelsAPI
)允许从Apex原生访问LLM,无需外部HTTP调用。可用于Agentforce主题/动作之外的自定义AI逻辑。
可用模型:
  • sfdc_ai__DefaultOpenAIGPT4OmniMini
    — 高性价比的通用任务
  • sfdc_ai__DefaultOpenAIGPT4Omni
    — 复杂推理
  • sfdc_ai__DefaultAnthropic
    — 细致理解
  • sfdc_ai__DefaultGoogleGemini
    — 多模态任务
关键模式:
  • Queueable:用于单记录异步AI处理
  • Batch:用于批量处理(范围大小10–20)
  • 平台事件:用于向LWC/Flow通知完成状态
前提条件: 已启用Einstein生成式AI,API版本v61.0+,已分配Einstein Generative AI用户权限集。
完整参考:请查看docs/models-api.md获取完整Apex示例、Queueable/Batch模式、Chatter集成以及 governor limit 指南。

Custom Lightning Types

自定义Lightning类型

Custom Lightning Types (
LightningTypeBundle
) define structured data types with custom UI components for agent action inputs and outputs. When an agent action needs a rich input form or a formatted output display, create a custom type with:
  • schema.json — JSON Schema data structure definition
  • editor.json — Custom input collection UI (lightning components)
  • renderer.json — Custom output display UI (lightning components)
Requirements: API v64.0+ (Fall '25), Enhanced Chat V2 enabled in Service Cloud.
File Structure:
force-app/main/default/lightningTypeBundles/OrderDetails/
├── schema.json
├── editor.json
├── renderer.json
└── OrderDetails.lightningTypeBundle-meta.xml
Full reference: See docs/custom-lightning-types.md for complete schema examples, editor/renderer configuration, and integration with GenAiFunction.

自定义Lightning类型
LightningTypeBundle
)定义了结构化数据类型以及用于代理动作输入和输出的自定义UI组件。当代理动作需要丰富的输入表单或格式化的输出展示时,可创建自定义类型,包含:
  • schema.json — JSON Schema数据结构定义
  • editor.json — 自定义输入收集UI(lightning组件)
  • renderer.json — 自定义输出展示UI(lightning组件)
要求: API版本v64.0+(2025年秋季),已在Service Cloud中启用Enhanced Chat V2。
文件结构:
force-app/main/default/lightningTypeBundles/OrderDetails/
├── schema.json
├── editor.json
├── renderer.json
└── OrderDetails.lightningTypeBundle-meta.xml
完整参考:请查看docs/custom-lightning-types.md获取完整schema示例、editor/renderer配置以及与GenAiFunction的集成方法。

Orchestration Order

编排顺序

Prerequisite skills must run in this order:
sf-metadata → sf-apex → sf-flow → sf-ai-agentforce → sf-deploy
Why this order:
  1. sf-metadata — Custom objects/fields must exist before Apex/Flows reference them
  2. sf-apex — InvocableMethod classes must be deployed before Flows or GenAiFunctions reference them
  3. sf-flow — Flows must be active before GenAiFunctions can target them
  4. sf-ai-agentforce (this skill) — GenAiFunction/GenAiPlugin metadata and agent configuration
  5. sf-deploy — Final deployment and agent publishing
MANDATORY Delegations:
RequirementDelegate ToWhy
Flow creation
Skill(skill="sf-flow")
110-point validation, proper XML
Apex creation
Skill(skill="sf-apex")
InvocableMethod generation, 150-point scoring
Deployment
Skill(skill="sf-deploy")
Centralized deployment orchestration

必须按以下顺序运行前置技能:
sf-metadata → sf-apex → sf-flow → sf-ai-agentforce → sf-deploy
顺序原因:
  1. sf-metadata — 自定义对象/字段必须先存在,才能被Apex/Flow引用
  2. sf-apex — InvocableMethod类必须先部署,才能被Flow或GenAiFunction引用
  3. sf-flow — Flow必须先激活,GenAiFunction才能将其作为目标
  4. sf-ai-agentforce(本技能) — GenAiFunction/GenAiPlugin元数据及代理配置
  5. sf-deploy — 最终部署和代理发布
强制委托:
需求委托给原因
Flow创建
Skill(skill="sf-flow")
110点验证,正确的XML格式
Apex创建
Skill(skill="sf-apex")
InvocableMethod生成,150点评分
部署
Skill(skill="sf-deploy")
集中式部署编排

Cross-Skill Integration

跨技能集成

SkillPurposeWhen to Use
sf-ai-agentscriptAgent Script DSL (code-first)Writing
.agent
files with FSM architecture
sf-ai-agentforce-testingAgent testingTest execution, coverage analysis, agentic fix loops
sf-flowFlow actionsCreating Autolaunched Flows for agent actions
sf-apexApex actionsWriting InvocableMethod classes for agent actions
sf-deployDeploymentPublishing agents, deploying metadata
sf-metadataObject/field setupCreating SObjects and fields that actions reference
sf-integrationExternal APIsNamed Credentials, External Services for agent callouts
技能用途使用场景
sf-ai-agentscriptAgent Script DSL(代码优先)编写带有限状态机(FSM)架构的
.agent
文件
sf-ai-agentforce-testing代理测试测试执行、覆盖率分析、代理修复循环
sf-flowFlow动作为代理动作创建自动启动流
sf-apexApex动作为代理动作编写InvocableMethod类
sf-deploy部署发布代理、部署元数据
sf-metadata对象/字段设置创建动作引用的SObject和字段
sf-integration外部API代理调用的命名凭据、外部服务

Integration Patterns

集成模式

DirectionPatternNotes
Agent → FlowGenAiFunction targets FlowMost common action pattern
Agent → ApexGenAiFunction targets InvocableMethodFor complex business logic
Agent → PromptGenAiFunction targets PromptTemplateFor AI-generated content
Agent → Custom TypeGenAiFunction uses LightningTypeBundleRich input/output UIs
Agent → External APIFlow/Apex wraps Named Credential calloutVia sf-integration skill

方向模式说明
代理 → FlowGenAiFunction以Flow为目标最常见的动作模式
代理 → ApexGenAiFunction以InvocableMethod为目标用于复杂业务逻辑
代理 → PromptGenAiFunction以PromptTemplate为目标用于AI生成内容
代理 → 自定义类型GenAiFunction使用LightningTypeBundle丰富的输入/输出UI
代理 → 外部APIFlow/Apex封装命名凭据调用通过sf-integration技能

Key Insights

关键洞察

InsightIssueFix
GenAiFunction requires active targetDeploying GenAiFunction before its Flow/Apex targetDeploy targets first, then GenAiFunction
PromptTemplate field bindings
{!variableName}
must match variable
developerName
exactly
Check spelling and case sensitivity
Custom Lightning Types require v64.0+Bundle won't deploy on older API versionsSet
<version>64.0</version>
or higher in package.xml
GenAiPlugin groups functionsIndividual GenAiFunctions must exist before the pluginDeploy GenAiFunctions before GenAiPlugin
Capability text is criticalVague capability descriptions cause poor routingWrite specific, scenario-based capability text
Enhanced Chat V2 for custom typesCustom type UI won't render without itEnable Enhanced Chat V2 in Setup → Chat Settings
Models API needs async contextSynchronous calls in triggers will timeoutUse Queueable with
Database.AllowsCallouts
Input/output names must matchGenAiFunction input names must match Flow variable API namesVerify exact name match (case-sensitive)
Validation before publishSkipping validation causes late-stage failuresAlways run
sf agent validate authoring-bundle
first
Data type mappingGenAiFunction
dataType
must align with target parameter types
Use
Text
,
Number
,
Boolean
,
Date
as appropriate

洞察问题解决方案
GenAiFunction需要激活的目标在Flow/Apex目标之前部署GenAiFunction先部署目标,再部署GenAiFunction
PromptTemplate字段绑定
{!variableName}
必须与变量
developerName
完全匹配
检查拼写和大小写敏感性
自定义Lightning类型需要v64.0+旧API版本下Bundle无法部署在package.xml中设置
<version>64.0</version>
或更高版本
GenAiPlugin分组函数必须先存在单个GenAiFunction,才能创建插件先部署GenAiFunction,再部署GenAiPlugin
能力文本至关重要模糊的能力描述会导致路由不佳编写具体的、基于场景的能力文本
自定义类型需要Enhanced Chat V2未启用时自定义类型UI无法渲染在Setup → Chat Settings中启用Enhanced Chat V2
Models API需要异步上下文触发器中的同步调用会超时使用带有
Database.AllowsCallouts
的Queueable
输入/输出名称必须匹配GenAiFunction输入名称必须与Flow变量API名称匹配验证名称完全匹配(区分大小写)
发布前验证跳过验证会导致后期失败始终先运行
sf agent validate authoring-bundle
数据类型映射GenAiFunction的
dataType
必须与目标参数类型对齐
适当使用
Text
Number
Boolean
Date

Scoring System (100 Points)

评分系统(100分)

Categories

分类

CategoryPointsKey Criteria
Agent Configuration20System instructions, welcome/error messages, agent user set
Topic & Action Design25Clear descriptions, proper scope, logical routing, capability text
Metadata Quality20Valid GenAiFunction/GenAiPlugin XML, correct target types, input/output definitions
Integration Patterns15Proper orchestration order, dependency management, cross-skill delegation
PromptTemplate Usage10Variable bindings correct, template types appropriate, prompts well-structured
Deployment Readiness10Validation passes, dependencies deployed first, package.xml correct
分类分值关键标准
代理配置20系统指令、欢迎/错误消息、代理用户设置
主题与动作设计25清晰的描述、合适的范围、合理的路由、能力文本
元数据质量20有效的GenAiFunction/GenAiPlugin XML、正确的目标类型、输入/输出定义
集成模式15正确的编排顺序、依赖管理、跨技能委托
PromptTemplate使用10变量绑定正确、模板类型合适、提示词结构良好
部署就绪度10验证通过、依赖已先部署、package.xml正确

Thresholds

阈值

ScoreRatingAction
90–100ExcellentDeploy with confidence
80–89Very GoodMinor improvements suggested
70–79GoodReview before deploy
60–69Needs WorkAddress issues before deploy
< 60CriticalBlock deployment
分数评级操作
90–100优秀放心部署
80–89非常好建议进行小幅度改进
70–79良好部署前复查
60–69需要改进部署前解决问题
< 60严重问题阻止部署

Validation Report Format

验证报告格式

Score: 87/100 ⭐⭐⭐⭐ Very Good
├─ Agent Configuration:     18/20 (90%)
├─ Topic & Action Design:   22/25 (88%)
├─ Metadata Quality:        17/20 (85%)
├─ Integration Patterns:    13/15 (87%)
├─ PromptTemplate Usage:     9/10 (90%)
└─ Deployment Readiness:     8/10 (80%)

Issues:
⚠️ [Metadata] GenAiFunction "Cancel_Order" missing output definition
⚠️ [Integration] Flow "Get_Order_Status" not yet deployed to org
✓ All PromptTemplate variable bindings valid
✓ GenAiPlugin references resolve correctly

Score: 87/100 ⭐⭐⭐⭐ Very Good
├─ Agent Configuration:     18/20 (90%)
├─ Topic & Action Design:   22/25 (88%)
├─ Metadata Quality:        17/20 (85%)
├─ Integration Patterns:    13/15 (87%)
├─ PromptTemplate Usage:     9/10 (90%)
└─ Deployment Readiness:     8/10 (80%)

Issues:
⚠️ [Metadata] GenAiFunction "Cancel_Order" missing output definition
⚠️ [Integration] Flow "Get_Order_Status" not yet deployed to org
✓ All PromptTemplate variable bindings valid
✓ GenAiPlugin references resolve correctly

Document Map

文档地图

Tier 2: Detailed References
DocumentDescriptionRead When
docs/prompt-templates.mdComplete PromptTemplate metadata, variable types, Data Cloud groundingAuthoring reusable AI prompts
docs/models-api.md
aiplatform.ModelsAPI
Apex patterns, Queueable/Batch integration
Building custom AI logic in Apex
docs/custom-lightning-types.mdLightningTypeBundle schema/editor/renderer configurationCreating rich action input/output UIs
Cross-Skill References
NeedSkill
Agent Script DSL development
sf-ai-agentscript
Agent testing & coverage
sf-ai-agentforce-testing
Flow creation for actions
sf-flow
Apex InvocableMethod classes
sf-apex
Metadata deployment
sf-deploy

Tier 2:详细参考
文档描述阅读场景
docs/prompt-templates.md完整的PromptTemplate元数据、变量类型、Data Cloud grounding编写可复用AI提示词时
docs/models-api.md
aiplatform.ModelsAPI
Apex模式、Queueable/Batch集成
在Apex中构建自定义AI逻辑时
docs/custom-lightning-types.mdLightningTypeBundle schema/editor/renderer配置创建丰富的动作输入/输出UI时
跨技能参考
需求技能
Agent Script DSL开发
sf-ai-agentscript
代理测试与覆盖率
sf-ai-agentforce-testing
为动作创建Flow
sf-flow
Apex InvocableMethod类
sf-apex
元数据部署
sf-deploy

Version History

版本历史

VersionDateChanges
2.0.02026-02-07Complete rewrite. Skill refocused on standard Agentforce platform (Setup UI, GenAiFunction/GenAiPlugin, PromptTemplate, Models API, Custom Lightning Types). Agent Script DSL content moved to
sf-ai-agentscript
.

版本日期变更
2.0.02026-02-07完全重写。技能聚焦于标准Agentforce平台(Setup UI、GenAiFunction/GenAiPlugin、PromptTemplate、Models API、自定义Lightning类型)。Agent Script DSL内容移至
sf-ai-agentscript

Sources & Acknowledgments

来源与致谢

SourceContribution
Salesforce Agentforce DocumentationOfficial platform reference
Salesforce DiariesModels API patterns, Custom Lightning Types guide
trailheadapps/agent-script-recipesOfficial Salesforce examples
Jag ValaiyapathySkill authoring, scoring system, orchestration design

来源贡献
Salesforce Agentforce Documentation官方平台参考
Salesforce DiariesModels API模式、自定义Lightning类型指南
trailheadapps/agent-script-recipesSalesforce官方示例
Jag Valaiyapathy技能编写、评分系统、编排设计

License

许可证

MIT License. See LICENSE file in sf-ai-agentforce folder. Copyright (c) 2024–2026 Jag Valaiyapathy
MIT许可证。请查看sf-ai-agentforce文件夹中的LICENSE文件。 版权所有 (c) 2024–2026 Jag Valaiyapathy