🤖 Understanding Agent Policy in Genie Framework
Quick Summary
Agent Policy is the brain 🧠 of the Genie framework that makes smart decisions about how to respond to users. Think of it as a very organized manager that always knows what to do next!
🎯 What is Agent Policy?
Agent Policy is a core component of the Genie framework that determines how the conversational agent should respond to user inputs. Unlike traditional LLM approaches that rely on the model to directly generate responses, Genie uses a symbolic module to compute agent responses in a more controlled and reliable way.
Key Difference
Traditional LLMs: "Let me generate whatever feels right" 🎲
Genie Agent Policy: "Let me follow these specific rules step by step" ✅
🤔 Why Use a Symbolic Agent Policy?
There are two main reasons:
-
Deterministic Responses 🎯
- By providing specific agent acts, the LLM generates responses that are governed by the policy
- No more random or unpredictable responses!
-
Better Instruction Following 📝
- LLMs often struggle with following complex developer-defined policies
- A symbolic module helps ensure all instructions are properly followed
⚙️ How Agent Policy Works
Input/Output Flow
Inputs 📥 - Previous dialogue state - Updated dialogue state from the parser - Worksheet specification
Outputs 📤 - New dialogue state - Set of agent acts to be performed
🔄 Core Steps of Agent Policy
graph TD
A[Start] --> B[Handle KB Queries]
B --> C[Process Field Assignments]
C --> D[Execute Complete Tasks]
D --> E[Request Missing Information]
E --> F[End]
-
Handle Knowledge Base (KB) Queries 🔍
if new_kb_record: if missing_required_parameters: ask_user() else: execute_query() report_results()
-
Process Field Assignments ✍️
for field in new_assignments: if needs_confirmation: ask_user_to_confirm() else: execute_actions() update_state()
-
Execute Complete Tasks ✅
for task in complete_tasks: if not executed: execute_worksheet_actions() update_state() add_agent_acts()
-
Request Missing Information ❓
for field in required_fields: if is_empty(field): ask_user(field) break
🎭 Types of Agent Acts
The Five Core Acts
-
Report 📊
Report(query, answer)
- Reports query results to user
- Example: "Here are the restaurants I found..."
- Used for sharing KB query results
-
Confirm ✔️
AskForFieldConfirmation(worksheet, field, value)
- Verifies field values with user
- Example: "Just to confirm, you want to book for 7 PM?"
- Ensures data accuracy
-
Say 💬
Say(utterance)
- Delivers direct messages
- Example: "I'll help you book a restaurant."
- Used for general communication
-
Propose 💡
ProposeWorksheet(worksheet, parameters)
- Suggests new tasks/actions
- Example: "Would you like to make a reservation?"
- Includes initial parameter values
-
Ask ❓
AskField(worksheet, field, field_description)
- Requests specific information
- Example: "What date would you like to book for?"
- Includes field description
🎯 Agent Acts in Action
Restaurant Booking Example
# Initial Search
[
Report(
query="looking for restaurants in SF",
answer=["Nice Place", "Good Food"]
)
]
# Proposing Booking
[
ProposeWorksheet(
worksheet="BookRestaurant",
parameters={"restaurant": "Nice Place"}
)
]
# Gathering Details
[
AskField(
worksheet="booking",
field="date",
description="Preferred booking date"
)
]
# Confirming Details
[
AskForFieldConfirmation(
worksheet="booking",
field="time",
value="19:00"
)
]
🔄 Common Act Sequences
Typical Flows
-
Search & Book Flow 📝
# 1. Report search results Report(query, results) # 2. Propose booking ProposeWorksheet("BookRestaurant", {...}) # 3. Ask for details AskField("booking", "date") # 4. Confirm final details AskForFieldConfirmation("booking", "all")
-
Information Query Flow 🔍
# 1. Report answer Report(query, answer) # 2. Ask if more info needed Say("Would you like to know anything else?")
-
Modification Flow ✏️
# 1. Confirm current value AskForFieldConfirmation(worksheet, field) # 2. Ask for new value AskField(worksheet, field) # 3. Confirm change Report("update_status", result)
⚙️ Act Parameters
Parameter Details
-
Worksheet 📋
- The form/task being handled
- Examples: BookRestaurant, CourseEnroll
- Must be a valid worksheet type
-
Field 🏷️
- Specific data point needed
- Examples: date, time, guests
- Must exist in worksheet
-
Description 📝
- User-friendly field explanation
- Helps generate clear questions
- Should be descriptive
-
Value 💡
- Current or proposed value
- Used in confirmations
- Must match field type
🎨 Response Generation
Response Guidelines
-
Formatting 📝
- Be polite and friendly
- Use conversation context
- Keep responses natural
-
Priority ⚡
if agent_acts: # Always perform listed actions first execute_acts_in_order() else: # Then handle direct responses respond_to_user()
-
Context 🔄
- Reference previous states
- Maintain conversation flow
- Use appropriate formality
Remember
Agent acts are the building blocks of conversation - they help create structured, reliable, and natural interactions! 🌟
🎬 Example Flow
Restaurant Booking Scenario
User: "I want to book a romantic restaurant in London" 🍽️
Agent Policy Process:
1. 🔍 Creates KB record to search restaurants
2. ✨ Checks required parameters (date, time needed)
3. ❓ Asks user: "What date would you like to book for?"
4. ⏰ After getting date, asks for time
5. 🎉 Once all parameters are present:
- Executes restaurant search
- Reports matching restaurants
- Proposes booking task with found restaurant
🌟 Benefits of Genie's Agent Policy
Key Advantages
- Reliable Context Management 🧠
- Never forgets important conversation details
- Controlled Flow 🎮
- Ensures all required information is collected
- Predictable Behavior 🎯
- Follows developer-defined rules consistently
- Mixed Initiative Handling 🤝
- Handles both user and system initiatives effectively
📊 Performance Impact
Real User Study Results
Genie's agent policy achieved impressive results:
Metric | Score | vs GPT-4 |
---|---|---|
Execution Accuracy | 86.5% | +21.1% |
Dialog Act Accuracy | 89.2% | +20.1% |
Goal Completion Rate | 82.8% | +61.0% |
🚀 Best Practices
Common Pitfalls to Avoid
- Don't skip confirmation steps for critical actions
- Always handle missing required fields
- Keep track of conversation state
- Handle user interruptions gracefully
🔍 Debugging Tips
Troubleshooting Guide
- Check dialogue state consistency
- Verify all required fields are being tracked
- Monitor agent act sequences
- Review KB query results
- Validate field assignments
🎓 Learning Resources
Further Reading
Remember
The power of Genie's Agent Policy lies in its ability to maintain structure while being flexible enough to handle natural conversations! 🌟