mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 11:43:26 +08:00
* @W-21955450@ Rename topic to subagent for Agent Script v2
Aligns with Agent Script v2 naming standards where `topic` is renamed
to `subagent` across all skill documentation and templates.
Changes:
- Agent Script templates: topic keyword → subagent keyword
- References: @topic.* → @subagent.*
- Documentation: Updated all skill references and guides
- Natural language references preserved in comments/descriptions
* Rename start_agent topic_selector to agent_router
Completes the topic → subagent terminology alignment by:
1. Renaming start_agent from topic_selector to agent_router (15 agent files)
2. Updating template topic declarations: topic {{placeholder}} → subagent {{placeholder}} (5 files)
3. Updating all @subagent.topic_selector references to @subagent.agent_router (35 occurrences)
4. Updating documentation: prose, examples, and diagrams (10 markdown files)
5. Updating comments to use agent_router terminology
Files affected:
- 22 agent template files
- 10 documentation/reference markdown files
- Template component files
The agent_router name is more descriptive of its actual function
(routing to different subagents) and completes the Agent Script v2
terminology standardization.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Rename files with "topic" to use "subagent" terminology
Completes the topic → subagent terminology alignment by renaming
files and updating all references:
**Files renamed (5):**
- multi-topic.agent → multi-subagent.agent
- template-single-topic.agent → template-single-subagent.agent
- template-multi-topic.agent → template-multi-subagent.agent
- topic-with-actions.agent → subagent-with-actions.agent
- agent-topic-map-diagrams.md → agent-subagent-map-diagrams.md
**References updated (6 docs):**
- Updated all filename references to point to new filenames
- Updated "Topic Map" → "Subagent Map" throughout documentation
- Updated "multi-topic"/"single-topic" → "multi-subagent"/"single-subagent"
Files modified:
- README.md, SKILL.md, agent-spec-template.md
- assets/agents/README.md, assets/README-legacy.md
- references/agent-design-and-spec-creation.md
This ensures consistent "subagent" terminology across filenames,
file content, and all documentation references.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Complete topic-to-subagent terminology update across skills
Comprehensive update replacing "topic" with "subagent" terminology throughout
the developing-agentforce and testing-agentforce skills to align with Agent
Script's `subagent` block naming.
Key changes:
- "Topic Selector" → "Subagent Router" in all agent templates and docs
- "Topic/action" → "Subagent/action" in documentation
- "Topic map" → "Subagent map" in diagram references
- Updated all architecture documentation to use "subagent" terminology
- Updated 19 .agent template files with new labels and comments
- Updated 8 reference documentation files with consistent terminology
API contract preservation:
- Test spec YAML files preserve "topic" terminology to match Testing Center API
- Added clarifying comments explaining topic/subagent equivalence in YAML files
- Field names like `expectedTopic` unchanged (Salesforce API requirement)
Preserved terms:
- "off-topic" (standard phrase for out-of-scope)
- "expectedTopic" field (Testing Center API)
- "platform topics" (Salesforce guardrail features)
32 files changed, 379 insertions(+), 366 deletions(-)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* Complete comprehensive topic-to-subagent terminology update
Thorough update replacing all remaining "topic" references with "subagent"
terminology across developing-agentforce, testing-agentforce, and
observing-agentforce skills to fully align with Agent Script's `subagent`
block naming.
Key changes:
- Agent Script syntax: @topic.<name> → @subagent.<name>
- Agent Script syntax: topic.actions → subagent.actions
- Shell script patterns: ^topic → ^subagent
- Documentation: "topic instructions" → "subagent instructions"
- observing-agentforce skill: Updated all agent architecture references
- Template files: Updated all inline comments and descriptions
- Variable names in scripts: TOPIC → SUBAGENT
Specific updates:
- 45 files changed, 294 insertions, 294 deletions
- Updated all Agent Script code examples to use @subagent syntax
- Updated observing-agentforce issue classification guide
- Updated shell script patterns in diagnostic tools
- Updated Apex comments to clarify topic field maps to subagents
Preserved (as required):
- "off-topic" and "off_topic" (standard out-of-scope phrase)
- Testing Center API fields: expectedTopic, topic: in YAML
- API response fields: .topic, generatedData.topic, topic_assertion
- STDM field names: ssot__TopicApiName__c (with clarifying docs)
- Template placeholders in test specs (API values)
- "Topic hash drift" (API field behavior)
- "Email topic/purpose" (means email subject)
- Explanatory comments about API field mapping
All Agent Script syntax and documentation now consistently uses "subagent"
while preserving backward compatibility with platform API field names.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* a few more topic -> subagent replacements
---------
Co-authored-by: Steve Hetzel <shetzel@salesforce.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
274 lines
8.4 KiB
Plaintext
274 lines
8.4 KiB
Plaintext
# Procedural Instructions Pattern
|
|
# Execute actions inline within instructions block for conditional data loading
|
|
#
|
|
# ★ When To Use This Pattern:
|
|
# - Fetch data only when needed (lazy loading)
|
|
# - Chain data lookups based on conditions
|
|
# - Build up context progressively
|
|
# - Reduce unnecessary API calls
|
|
#
|
|
# ★ Key Insights:
|
|
# - `run @actions.x` can appear INSIDE `instructions: ->` blocks
|
|
# - Actions execute when their containing conditional is true
|
|
# - Different from actions: block which defines what LLM CAN call
|
|
# - This is PROCEDURAL (you control when) vs DECLARATIVE (LLM chooses)
|
|
#
|
|
# ★ Use Case Distinction:
|
|
# - actions: block = "LLM, here are tools you MAY use"
|
|
# - run in instructions = "Do this NOW when condition met"
|
|
#
|
|
# This is a COMPLETE template - customize for your use case
|
|
|
|
system:
|
|
instructions: "You are a customer service agent. Efficiently gather context as needed to help customers. Only fetch data when required for the current task."
|
|
messages:
|
|
welcome: "Hello! How can I help you today?"
|
|
error: "I encountered an issue retrieving your information. Let me try again."
|
|
|
|
config:
|
|
agent_name: "Smart_Service_Agent"
|
|
default_agent_user: "agent@company.salesforce.com"
|
|
agent_label: "Smart Service Agent"
|
|
description: "Agent with procedural data loading"
|
|
|
|
variables:
|
|
# Standard linked variables
|
|
EndUserId: linked string
|
|
source: @MessagingSession.MessagingEndUserId
|
|
description: "Messaging End User ID"
|
|
ContactId: linked string
|
|
source: @MessagingEndUser.ContactId
|
|
description: "Contact ID"
|
|
|
|
# Progressive data loading variables
|
|
customer_loaded: mutable boolean = False
|
|
description: "Whether customer data has been loaded"
|
|
orders_loaded: mutable boolean = False
|
|
description: "Whether order data has been loaded"
|
|
cases_loaded: mutable boolean = False
|
|
description: "Whether case data has been loaded"
|
|
|
|
# Customer data
|
|
customer_name: mutable string = ""
|
|
description: "Customer's full name"
|
|
customer_tier: mutable string = ""
|
|
description: "Customer tier: standard, premium, vip"
|
|
account_id: mutable string = ""
|
|
description: "Associated account ID"
|
|
|
|
# Order data
|
|
recent_order_id: mutable string = ""
|
|
description: "Most recent order ID"
|
|
order_status: mutable string = ""
|
|
description: "Status of the recent order"
|
|
tracking_number: mutable string = ""
|
|
description: "Shipping tracking number"
|
|
|
|
# Case data
|
|
open_case_count: mutable number = 0
|
|
description: "Number of open support cases"
|
|
last_case_subject: mutable string = ""
|
|
description: "Subject of most recent case"
|
|
|
|
language:
|
|
default_locale: "en_US"
|
|
|
|
start_agent agent_router:
|
|
label: "Subagent Router"
|
|
description: "Routes to subagents with procedural data loading"
|
|
|
|
actions:
|
|
# Data loading actions
|
|
load_customer:
|
|
description: "Load customer profile data"
|
|
inputs:
|
|
contact_id: string
|
|
description: "Contact ID to look up"
|
|
is_required: True
|
|
outputs:
|
|
name: string
|
|
description: "Customer name"
|
|
tier: string
|
|
description: "Customer tier"
|
|
account_id: string
|
|
description: "Associated account"
|
|
target: "flow://Get_Customer_Profile"
|
|
|
|
load_orders:
|
|
description: "Load recent order data"
|
|
inputs:
|
|
contact_id: string
|
|
description: "Contact ID"
|
|
is_required: True
|
|
outputs:
|
|
order_id: string
|
|
description: "Most recent order ID"
|
|
status: string
|
|
description: "Order status"
|
|
tracking: string
|
|
description: "Tracking number"
|
|
target: "flow://Get_Recent_Orders"
|
|
|
|
load_cases:
|
|
description: "Load support case data"
|
|
inputs:
|
|
contact_id: string
|
|
description: "Contact ID"
|
|
is_required: True
|
|
outputs:
|
|
open_count: number
|
|
description: "Number of open cases"
|
|
last_subject: string
|
|
description: "Last case subject"
|
|
target: "flow://Get_Open_Cases"
|
|
|
|
reasoning:
|
|
# ★ PROCEDURAL INSTRUCTIONS with inline action execution
|
|
instructions: ->
|
|
# ★ STEP 1: Always load customer data first (if not already loaded)
|
|
# This runs BEFORE any conversation happens
|
|
if @variables.customer_loaded == False:
|
|
run @actions.load_customer
|
|
with contact_id=@variables.ContactId
|
|
set @variables.customer_name = @outputs.name
|
|
set @variables.customer_tier = @outputs.tier
|
|
set @variables.account_id = @outputs.account_id
|
|
set @variables.customer_loaded = True
|
|
|
|
# Now we have customer context
|
|
| Hello {!@variables.customer_name}!
|
|
|
|
|
if @variables.customer_tier == "vip":
|
|
| As a VIP customer, I'm here to provide priority support.
|
|
|
|
|
| How can I help you today?
|
|
| - Order status or tracking
|
|
| - Support cases
|
|
| - Account questions
|
|
|
|
actions:
|
|
go_orders: @utils.transition to @subagent.order_status
|
|
go_cases: @utils.transition to @subagent.support_cases
|
|
go_account: @utils.transition to @subagent.account_help
|
|
|
|
subagent order_status:
|
|
label: "Order Status"
|
|
description: "Check order status with lazy loading"
|
|
|
|
actions:
|
|
get_tracking_details:
|
|
description: "Get detailed tracking information"
|
|
inputs:
|
|
order_id: string
|
|
description: "Order ID to look up"
|
|
outputs:
|
|
carrier: string
|
|
description: "Shipping carrier"
|
|
estimated_delivery: string
|
|
description: "Estimated delivery date"
|
|
current_location: string
|
|
description: "Current package location"
|
|
target: "flow://Get_Tracking_Details"
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
# ★ LAZY LOADING: Only fetch orders when user enters this subagent
|
|
if @variables.orders_loaded == False:
|
|
run @actions.load_orders
|
|
with contact_id=@variables.ContactId
|
|
set @variables.recent_order_id = @outputs.order_id
|
|
set @variables.order_status = @outputs.status
|
|
set @variables.tracking_number = @outputs.tracking
|
|
set @variables.orders_loaded = True
|
|
|
|
# Now provide order information
|
|
| Here's your most recent order:
|
|
| Order ID: {!@variables.recent_order_id}
|
|
| Status: {!@variables.order_status}
|
|
|
|
|
if @variables.tracking_number != "":
|
|
| Tracking: {!@variables.tracking_number}
|
|
|
|
|
| Would you like more details or help with something else?
|
|
|
|
actions:
|
|
get_details: @actions.get_tracking_details
|
|
with order_id=@variables.recent_order_id
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
subagent support_cases:
|
|
label: "Support Cases"
|
|
description: "Review support cases with lazy loading"
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
# ★ LAZY LOADING: Only fetch cases when needed
|
|
if @variables.cases_loaded == False:
|
|
run @actions.load_cases
|
|
with contact_id=@variables.ContactId
|
|
set @variables.open_case_count = @outputs.open_count
|
|
set @variables.last_case_subject = @outputs.last_subject
|
|
set @variables.cases_loaded = True
|
|
|
|
# Present case information
|
|
if @variables.open_case_count == 0:
|
|
| You have no open support cases.
|
|
| Is there something I can help you with?
|
|
|
|
if @variables.open_case_count > 0:
|
|
| You have {!@variables.open_case_count} open case(s).
|
|
| Most recent: {!@variables.last_case_subject}
|
|
|
|
|
| Would you like to:
|
|
| - Check the status of a specific case
|
|
| - Create a new support case
|
|
| - Return to the main menu
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
escalate: @utils.escalate
|
|
description: "Transfer to support specialist"
|
|
|
|
subagent account_help:
|
|
label: "Account Help"
|
|
description: "Account questions - customer data already loaded"
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
# ★ DATA ALREADY AVAILABLE - no loading needed
|
|
# Customer data was loaded in agent_router
|
|
| Account Information:
|
|
| Name: {!@variables.customer_name}
|
|
| Tier: {!@variables.customer_tier}
|
|
| Account ID: {!@variables.account_id}
|
|
|
|
|
| What would you like to know about your account?
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
# ★ Insight: Procedural vs Declarative Actions
|
|
#
|
|
# PROCEDURAL (run in instructions):
|
|
# - You control WHEN the action runs
|
|
# - Executes based on conditionals
|
|
# - Good for: data loading, setup, guaranteed actions
|
|
# - Example: "Always load customer before greeting"
|
|
#
|
|
# DECLARATIVE (actions: block):
|
|
# - LLM decides IF and WHEN to call
|
|
# - Based on user request
|
|
# - Good for: optional tools, user-triggered actions
|
|
# - Example: "User can ask for refund if they want"
|
|
#
|
|
# COMBINE BOTH:
|
|
# - Use procedural for setup/loading
|
|
# - Use declarative for user interactions
|
|
# - Result: Efficient, context-aware agents
|
|
|
|
# ★ Performance Benefits:
|
|
# - Fetch only what's needed per subagent
|
|
# - Avoid loading all data upfront
|
|
# - Reduce API calls for simple conversations
|
|
# - Better response times
|