mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 19:50:42 +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>
294 lines
11 KiB
Plaintext
294 lines
11 KiB
Plaintext
# System Instruction Overrides Pattern
|
|
# Customize agent behavior with dynamic system-level instructions
|
|
#
|
|
# ★ When To Use This Pattern:
|
|
# - Different behavior for different user segments (VIP, standard, etc.)
|
|
# - Time-based instruction changes (business hours vs after hours)
|
|
# - Feature flags that change agent personality
|
|
# - A/B testing different conversation styles
|
|
#
|
|
# ★ Key Insight:
|
|
# - System block defines BASE behavior (always applies)
|
|
# - Subagent instructions can OVERRIDE or EXTEND system behavior
|
|
# - Use conditionals in reasoning to dynamically adjust tone
|
|
# - Variables can control instruction branches
|
|
#
|
|
# ★ Important Limitation:
|
|
# - The system: block itself cannot use conditionals or variables
|
|
# - Dynamic behavior must be implemented in subagent reasoning
|
|
#
|
|
# This is a COMPLETE template - customize for your use case
|
|
|
|
system:
|
|
# Base instructions - always apply these guardrails
|
|
instructions: "You are a professional customer service agent. Always be helpful, courteous, and accurate. Never share confidential information. Escalate complex issues to human agents."
|
|
messages:
|
|
welcome: "Hello! How can I assist you today?"
|
|
error: "I apologize, but I encountered an issue. Let me try that again."
|
|
|
|
config:
|
|
agent_name: "Dynamic_Service_Agent"
|
|
default_agent_user: "agent@company.salesforce.com"
|
|
agent_label: "Dynamic Service Agent"
|
|
description: "Agent with dynamic instruction overrides based on context"
|
|
|
|
variables:
|
|
# Standard linked variables
|
|
EndUserId: linked string
|
|
source: @MessagingSession.MessagingEndUserId
|
|
description: "Messaging End User ID"
|
|
RoutableId: linked string
|
|
source: @MessagingSession.Id
|
|
description: "Messaging Session ID"
|
|
ContactId: linked string
|
|
source: @MessagingEndUser.ContactId
|
|
description: "Contact ID"
|
|
|
|
# Variables for dynamic instruction control
|
|
customer_tier: mutable string = "standard"
|
|
description: "Customer tier: standard, premium, or vip"
|
|
business_hours: mutable boolean = True
|
|
description: "Whether we're in business hours"
|
|
agent_mode: mutable string = "helpful"
|
|
description: "Agent personality mode: helpful, concise, formal"
|
|
feature_flags: mutable string = ""
|
|
description: "Comma-separated feature flags"
|
|
|
|
language:
|
|
default_locale: "en_US"
|
|
additional_locales: ""
|
|
all_additional_locales: False
|
|
|
|
start_agent agent_router:
|
|
label: "Subagent Router"
|
|
description: "Routes to appropriate subagent based on user tier"
|
|
|
|
# ★ Use before_reasoning to set up context-based variables
|
|
before_reasoning:
|
|
# In a real implementation, these would come from a Flow/Apex lookup
|
|
# Here we show the pattern
|
|
run @actions.get_customer_tier
|
|
with contact_id=@variables.ContactId
|
|
set @variables.customer_tier = @outputs.tier
|
|
run @actions.check_business_hours
|
|
set @variables.business_hours = @outputs.is_business_hours
|
|
|
|
reasoning:
|
|
# ★ OVERRIDE PATTERN: Conditional instructions based on variables
|
|
instructions: ->
|
|
# VIP customers get personalized treatment
|
|
if @variables.customer_tier == "vip":
|
|
| PRIORITY CUSTOMER DETECTED
|
|
| Provide white-glove service. Use their name when possible.
|
|
| Offer proactive solutions. Never say "I can't" without an alternative.
|
|
| You have authority to offer 20% discounts.
|
|
|
|
# Premium gets enhanced support
|
|
if @variables.customer_tier == "premium":
|
|
| PREMIUM CUSTOMER
|
|
| Provide thorough, detailed responses.
|
|
| Offer to connect with a specialist if needed.
|
|
| You can offer 10% discounts.
|
|
|
|
# Standard tier
|
|
if @variables.customer_tier == "standard":
|
|
| Provide helpful, efficient service.
|
|
| Focus on resolving the issue quickly.
|
|
|
|
# After-hours override
|
|
if @variables.business_hours == False:
|
|
| NOTE: We are currently outside business hours.
|
|
| Complex issues should be logged for follow-up tomorrow.
|
|
| You cannot transfer to live agents right now.
|
|
|
|
# Mode-based personality adjustments
|
|
if @variables.agent_mode == "concise":
|
|
| Keep responses brief and to the point. Use bullet points.
|
|
|
|
if @variables.agent_mode == "formal":
|
|
| Use formal language. Address customer as Sir/Madam.
|
|
|
|
| Route the customer to the appropriate subagent.
|
|
|
|
actions:
|
|
go_orders: @utils.transition to @subagent.orders
|
|
go_billing: @utils.transition to @subagent.billing
|
|
go_support: @utils.transition to @subagent.support
|
|
available when @variables.business_hours == True
|
|
|
|
actions:
|
|
get_customer_tier:
|
|
description: "Get customer tier from Salesforce"
|
|
inputs:
|
|
contact_id: string
|
|
description: "Contact ID to look up"
|
|
outputs:
|
|
tier: string
|
|
description: "Customer tier: standard, premium, vip"
|
|
target: "flow://Get_Customer_Tier"
|
|
|
|
check_business_hours:
|
|
description: "Check if currently in business hours"
|
|
outputs:
|
|
is_business_hours: boolean
|
|
description: "True if in business hours"
|
|
target: "flow://Check_Business_Hours"
|
|
|
|
subagent orders:
|
|
label: "Order Management"
|
|
description: "Handle order inquiries with tier-appropriate service"
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
# ★ Tier-specific instructions carry through to subagents
|
|
if @variables.customer_tier == "vip":
|
|
| This is a VIP customer. Expedite all order requests.
|
|
| Offer free shipping upgrades proactively.
|
|
|
|
| Help the customer with their order inquiry.
|
|
| Look up order status, process changes, or handle returns.
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
subagent billing:
|
|
label: "Billing Support"
|
|
description: "Handle billing with appropriate authority levels"
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
# ★ Different authority based on tier
|
|
if @variables.customer_tier == "vip":
|
|
| You can waive fees up to $100 for VIP customers.
|
|
| Proactively offer payment plan options.
|
|
|
|
if @variables.customer_tier == "premium":
|
|
| You can waive fees up to $25 for premium customers.
|
|
|
|
if @variables.customer_tier == "standard":
|
|
| Fee waivers require manager approval. Escalate if requested.
|
|
|
|
| Help the customer understand their bill and resolve issues.
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
escalate: @utils.escalate
|
|
description: "Transfer to billing specialist"
|
|
available when @variables.customer_tier == "standard"
|
|
|
|
subagent support:
|
|
label: "Technical Support"
|
|
description: "Technical support with business hours awareness"
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
if @variables.business_hours == False:
|
|
| Technical support is limited outside business hours.
|
|
| Log the issue for follow-up and provide self-service resources.
|
|
|
|
if @variables.business_hours == True:
|
|
| Full technical support available. Troubleshoot thoroughly.
|
|
|
|
| Help resolve the customer's technical issue.
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
# ★ SUBAGENT-LEVEL SYSTEM OVERRIDES (NEW PATTERN)
|
|
# These subagents demonstrate complete persona switching using subagent-level
|
|
# system: blocks that OVERRIDE the global system instructions.
|
|
# ═══════════════════════════════════════════════════════════════════════════
|
|
|
|
subagent formal_mode:
|
|
label: "Formal Communication"
|
|
description: "Professional business communication mode"
|
|
|
|
# ★ SUBAGENT-LEVEL SYSTEM OVERRIDE
|
|
# This completely replaces global system instructions for this subagent
|
|
system:
|
|
instructions: "You are a formal business professional. Use professional language at all times. Address users as Sir or Madam. Avoid contractions, slang, and casual expressions. Focus on efficiency and clarity. Maintain a respectful, corporate tone."
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
| [Formal Mode Engaged]
|
|
|
|
|
| Good day. How may I be of assistance?
|
|
| I am prepared to address your inquiry with the utmost professionalism.
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
subagent creative_mode:
|
|
label: "Creative Assistant"
|
|
description: "Creative and imaginative communication mode"
|
|
|
|
# ★ SUBAGENT-LEVEL SYSTEM OVERRIDE
|
|
# Different persona entirely
|
|
system:
|
|
instructions: "You are a creative and imaginative assistant. Be playful, use metaphors and analogies. Think outside the box. Encourage brainstorming and wild ideas. Use emojis sparingly but effectively. Make conversations engaging and fun while still being helpful."
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
| 🎨 [Creative Mode Activated!]
|
|
|
|
|
| Hey there, creative spirit! Ready to explore some ideas together?
|
|
| Think of me as your brainstorming buddy - no idea is too wild!
|
|
|
|
|
| What shall we dream up today?
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
subagent technical_expert:
|
|
label: "Technical Expert"
|
|
description: "Deep technical expertise mode"
|
|
|
|
# ★ SUBAGENT-LEVEL SYSTEM OVERRIDE
|
|
# Specialist persona
|
|
system:
|
|
instructions: "You are a technical expert with deep knowledge. Use precise technical terminology. Provide detailed explanations with examples. Reference documentation when helpful. Assume the user has technical background. Be thorough but avoid unnecessary verbosity."
|
|
|
|
reasoning:
|
|
instructions: ->
|
|
| [Technical Expert Mode]
|
|
|
|
|
| I'm ready to dive deep into technical details.
|
|
| Feel free to use technical terminology - I'll match your level.
|
|
|
|
|
| What technical challenge are we solving?
|
|
|
|
actions:
|
|
back: @utils.transition to @subagent.agent_router
|
|
|
|
# ★ Insight: Three Levels of Instruction Control
|
|
#
|
|
# LEVEL 1: GLOBAL SYSTEM BLOCK
|
|
# - Static text only (no variables, no conditionals)
|
|
# - Applies to ALL subagents as baseline
|
|
# - Good for: Guardrails, base personality, universal rules
|
|
# - Example: "Never share confidential information"
|
|
#
|
|
# LEVEL 2: SUBAGENT-LEVEL SYSTEM BLOCK (NEW!)
|
|
# - Placed inside subagent definition
|
|
# - COMPLETELY OVERRIDES global system for that subagent
|
|
# - Good for: Persona switching, mode changes, specialist behavior
|
|
# - Example: subagent formal_mode: system: instructions: "Be professional..."
|
|
#
|
|
# LEVEL 3: SUBAGENT REASONING INSTRUCTIONS
|
|
# - Dynamic (variables, conditionals, template expressions)
|
|
# - Extends/adjusts behavior within subagent
|
|
# - Good for: Context-aware responses, personalization
|
|
# - Example: if @variables.is_vip: | Provide priority service
|
|
#
|
|
# OVERRIDE HIERARCHY:
|
|
# Subagent system: > Global system: > Default behavior
|
|
#
|
|
# COMBINING APPROACHES:
|
|
# - Use GLOBAL system for universal guardrails
|
|
# - Use SUBAGENT system: for complete persona changes
|
|
# - Use SUBAGENT reasoning for dynamic conditional behavior
|
|
#
|
|
# Best Practice: Put guardrails in global system, personas in subagent system,
|
|
# and context-aware personalization in subagent reasoning instructions.
|