AINativeBench / data /processed /RQ1 /SocialMediaManager-MCP /reference_trajectory.yaml
王子睿
restructure + add files
8c10cf2
Raw
History Blame Contribute Delete
21.8 kB
# Full reference trajectory configuration - SocialMediaManager-MCP
#
# Version: ideal trajectory derived from the code design (applicable to all models)
# Principle: include only steps explicitly required by the code design, not based on test statistics
#
# Code-design analysis:
# 1. Execution flow (orchestrator.py):
# - The Orchestrator manages the whole workflow with two layers of retry logic:
# (a) Orchestrator-level retry: for unexpected exceptions (up to 3 attempts; MAX_CREW_RETRIES=2)
# (b) Business-logic retry: for validation failures (up to 6 attempts; max_retries=5)
# - Ideal flow (no retries):
# Step 1: Topic Analysis (TopicAnalyzerCrew)
# Step 2-4: Content Generation with Feedback Loop
# - Generate X post (ShakespeareGeneratorCrew)
# - Validate X post (PostReviewCrew)
# - If valid=True, stop the loop; otherwise retry
# Step 5: Save Results
#
# 2. Agent structure of the three crews:
# - TopicAnalyzerCrew (topic_analyzer/topic_analyzer_crew.py):
# - Agent: Topic Analysis Expert
# Tools: keyword_extractor, topic_complexity_analyzer
# - ShakespeareGeneratorCrew (content_generator/shakespeare_generator_crew.py):
# - Agent: Shakespearean Bard
# Tools: keyword_extractor, character_counter_tool, emoji_detector_tool,
# post_structure_validator, shakespearean_style_detector, tone_analyzer
# - PostReviewCrew (post_reviewer/post_review_crew.py):
# - Agent: X Post Verifier
# Tools: character_counter_tool, emoji_detector_tool, post_structure_validator,
# shakespearean_style_detector, tone_analyzer
#
# 3. SPAN hierarchy:
# - shakespeare_x_post_orchestrator (top-level; orchestrator.py line 347)
# └─ crew_execution (contains retry logic; orchestrator.py line 362-393)
# ├─ topic_analysis (topic analysis; orchestrator.py line 114-141)
# └─ content_generation_loop (content generation + review loop; orchestrator.py line 143-250)
# Includes multiple iterations:
# - ShakespeareGeneratorCrew.kickoff (generate X post)
# - PostReviewCrew.kickoff (validate X post)
# - If valid=True then stop; otherwise continue
#
# 4. MCP tools (tools/mcp_server.py):
# - Character count: character_counter_tool (validate 200-280 characters)
# - Emoji detection: emoji_detector_tool (ensure no emoji)
# - Structure validation: post_structure_validator (validate 1-3-1 structure, 5 lines)
# - Style detection: shakespearean_style_detector (detect Shakespearean style elements)
# - Tone analysis: tone_analyzer (ensure satire and humor)
# - Keyword extraction: keyword_extractor (extract key topic concepts)
# - Complexity analysis: topic_complexity_analyzer (estimate topic complexity)
# Project name
project_name: "SocialMediaManager-MCP"
# Trajectory extraction types
extract_types:
- "SPAN" # Multi-level SPAN hierarchy
- "Chain" # Each Crew kickoff chain
- "Agent" # Agents inside each Crew
- "LLM" # LLM calls
- "Tool" # MCP tool calls
# Repeatable pattern configuration
# SocialMediaManager-MCP has a self-evaluation loop (ideal trajectory uses only 1 iteration)
repeatable_patterns: []
# ============================================================================
# Reference trajectory (ground truth) - derived from the code design
# ============================================================================
#
# Diagram (ideal execution path: no retries, no errors, first generation passes validation):
#
# [SPAN] shakespeare_x_post_orchestrator
# └─ [SPAN] crew_execution
# ├─ [SPAN] topic_analysis
# │ └─ [Chain] Crew***.kickoff
# │ └─ [AGENT] Topic Analysis Expert
# │ ├─ [LLM] * (understand the topic)
# │ ├─ [Tool] keyword_extractor (extract keywords)
# │ ├─ [LLM] * (analyze extracted keywords)
# │ ├─ [Tool] topic_complexity_analyzer (analyze complexity)
# │ └─ [LLM] * (produce topic analysis report)
# └─ [SPAN] content_generation_loop
# ├─ [Chain] Crew***.kickoff (ShakespeareGeneratorCrew - iteration 1 generation)
# │ └─ [AGENT] Shakespearean Bard
# │ ├─ [LLM] * (plan the generation strategy)
# │ ├─ [Tool] keyword_extractor (understand topic keywords)
# │ ├─ [LLM] * (draft the initial X post)
# │ ├─ [Tool] character_counter_tool (check character count)
# │ ├─ [LLM] * (adjust character count)
# │ ├─ [Tool] emoji_detector_tool (check emoji)
# │ ├─ [LLM] * (confirm no emoji)
# │ ├─ [Tool] post_structure_validator (validate 1-3-1 structure)
# │ ├─ [LLM] * (adjust structure)
# │ ├─ [Tool] shakespearean_style_detector (check style)
# │ ├─ [LLM] * (strengthen style)
# │ ├─ [Tool] tone_analyzer (check tone)
# │ └─ [LLM] * (final polish and output)
# └─ [Chain] Crew***.kickoff (PostReviewCrew - iteration 1 validation)
# └─ [AGENT] X Post Verifier
# ├─ [LLM] * (read and do an initial assessment)
# ├─ [Tool] character_counter_tool (validate character count)
# ├─ [LLM] * (record character count result)
# ├─ [Tool] emoji_detector_tool (validate no emoji)
# ├─ [LLM] * (record emoji check result)
# ├─ [Tool] post_structure_validator (validate 1-3-1 structure)
# ├─ [LLM] * (record structure check result)
# ├─ [Tool] shakespearean_style_detector (validate style)
# ├─ [LLM] * (record style check result)
# ├─ [Tool] tone_analyzer (validate tone)
# └─ [LLM] * (final decision, output valid=True)
#
# Design basis:
# - orchestrator.py: execute topic_analysis → content_generation_loop sequentially
# - TopicAnalyzerCrew contains 1 Agent, using 2 tools to analyze the topic
# - ShakespeareGeneratorCrew contains 1 Agent, using multiple tools for generation and self-validation
# - PostReviewCrew contains 1 Agent, using multiple tools for comprehensive validation
# - Ideal situation: first generation passes validation (valid=True), no retries needed
# - All Agent roles are defined in each crew's config/agents.yaml
# - All tasks are defined in each crew's config/tasks.yaml, specifying the use of specific tools
# - Tools are obtained from the MCP server through MCPServerAdapter
# - PostReviewCrew contains 1 Agent, using multiple tools for comprehensive validation
# - Ideal situation: first generation passes validation (valid=True), no retries needed
# - All Agent roles are defined in each crew's config/agents.yaml
# - All tasks are defined in each crew's config/tasks.yaml, specifying the use of specific tools
# - Tools are obtained from the MCP server through MCPServerAdapter
#
# Ideal trajectory notes:
# - Top-level SPAN: shakespeare_x_post_orchestrator
# - Second-level SPAN: crew_execution (contains two layers of retry logic)
# - Two sub-SPANs executed sequentially: topic_analysis → content_generation_loop
# - Topic analysis stage: Topic Analyst uses keyword_extractor and topic_complexity_analyzer
# - content_generation_loop stage contains a self-evaluation loop:
# - Iteration 1 (ideal case):
# * ShakespeareGeneratorCrew generates the X post and self-validates with multiple tools
# * PostReviewCrew validates the X post using all required validation tools and returns valid=True
# - No iterations 2-N needed (because iteration 1 already passes)
# - This trajectory represents the ideal execution path: no retries and no errors
#
# Notes:
# - "LLM: *" means any LLM model (wildcard match)
# - Agent names must exactly match the role field in agents.yaml
# - Tool names must exactly match tool names provided by the MCP server
# - Both Generator and Verifier use multiple tools (as required by tasks.yaml)
# - Tool call order may vary by agent decisions
# - Some LLM calls may be merged/split, but core tool calls must appear
# ============================================================================
reference_trajectory:
# ===== Top-level SPAN =====
- "SPAN: shakespeare_x_post_orchestrator"
# ===== Second-level SPAN (contains two layers of retry logic) =====
- "SPAN: crew_execution"
# ===== Stage 1: Topic Analysis (TopicAnalyzerCrew) =====
- "SPAN: topic_analysis"
- "Chain: Crew***.kickoff"
- "Agent: Topic Analysis Expert"
- "LLM: *" # Initial understanding of the topic and analysis planning
- "Tool: keyword_extractor" # Required by tasks.yaml (no order constraint)
- "LLM: *" # Analyze keyword extraction results
- "Tool: topic_complexity_analyzer" # Required by tasks.yaml (no order constraint)
- "LLM: *" # Synthesize and produce the topic insight report
# ===== Stage 2: Content Generation Loop (Self-Evaluation Loop) =====
- "SPAN: content_generation_loop"
# === Iteration 1: Content generation (ShakespeareGeneratorCrew) ===
- "Chain: Crew***.kickoff"
- "Agent: Shakespearean Bard"
- "LLM: *" # Understand topic and topic_insights; plan generation strategy
- "Tool: keyword_extractor" # MUST be first: tasks.yaml STEP 1 requires it
- "LLM: *" # Draft the initial X post based on extracted keywords
# The following tools are required by tasks.yaml for validation (no order constraint):
- "Tool: character_counter_tool" # Validate character count (200-280)
- "LLM: *" # Adjust based on character count results
- "Tool: emoji_detector_tool" # Ensure no emoji
- "LLM: *" # Confirm emoji check passes
- "Tool: post_structure_validator" # Validate 1-3-1 structure (5 lines)
- "LLM: *" # Adjust based on structure results
- "Tool: shakespearean_style_detector" # Check Shakespearean style
- "LLM: *" # Strengthen style elements
- "Tool: tone_analyzer" # Validate satire/humor tone
- "LLM: *" # Final polish and output the X post
# === Iteration 1: Content verification (PostReviewCrew) ===
- "Chain: Crew***.kickoff"
- "Agent: X Post Verifier"
- "LLM: *" # Read the X post and plan a verification strategy
# The following 5 tools are REQUIRED by tasks.yaml (no order constraint):
- "Tool: character_counter_tool" # Validate character count (200-280)
- "LLM: *" # Analyze character count results
- "Tool: emoji_detector_tool" # Validate no emoji
- "LLM: *" # Analyze emoji check results
- "Tool: post_structure_validator" # Validate 1-3-1 structure (5 lines)
- "LLM: *" # Analyze structure results
- "Tool: shakespearean_style_detector" # Validate Shakespearean style
- "LLM: *" # Analyze style results
- "Tool: tone_analyzer" # Validate satire/humor tone
- "LLM: *" # Combine all results; output valid=True, feedback=""
# Target tool list (for the single-tool-use metric)
# This lists all tools filtered for each agent in the configuration
target_tools:
# Topic Analysis stage
- "Tool: keyword_extractor"
- "Tool: topic_complexity_analyzer"
# Content Generation stage
- "Tool: character_counter_tool"
- "Tool: emoji_detector_tool"
- "Tool: post_structure_validator"
- "Tool: shakespearean_style_detector"
- "Tool: tone_analyzer"
# Post Review stage (shares tools with Generation; not duplicated)
# ============================================================================
# Dynamic tool permutation configuration
# ============================================================================
# Define permutable tool groups for some stages to generate reference trajectories
# with different tool orders. During evaluation, all permutations are tried and
# the best-matching one is selected as the reference.
#
# Notes:
# - Topic Analyst's two tools can be in any order (tasks.yaml does not specify)
# - Shakespearean Bard's keyword_extractor MUST be the first tool (explicitly required by tasks.yaml)
# but the subsequent 5 validation tools can be in any order
# - X Post Verifier's 5 validation tools can be in any order (tasks.yaml does not specify)
permutable_tool_groups:
# Topic Analysis stage tools can be in any order
topic_analysis_tools:
- "Tool: keyword_extractor"
- "Tool: topic_complexity_analyzer"
# Shakespearean Bard validation tools can be in any order
# Note: the first keyword_extractor is NOT included (it must remain the first tool)
shakespearean_bard_validation_tools:
- "Tool: character_counter_tool"
- "Tool: emoji_detector_tool"
- "Tool: post_structure_validator"
- "Tool: shakespearean_style_detector"
- "Tool: tone_analyzer"
# X Post Verifier validation tools can be in any order
x_post_verifier_tools:
- "Tool: character_counter_tool"
- "Tool: emoji_detector_tool"
- "Tool: post_structure_validator"
- "Tool: shakespearean_style_detector"
- "Tool: tone_analyzer"
# Models to evaluate
models:
- "GPT-5"
- "GPT-4o-mini"
- "DeepSeek-V3-1"
- "DeepSeek-R1"
- "Gemini-2.5-flash"
- "Gemini-2.5-flash-nothinking"
- "Qwen3-235b"
# ============================================================================
# Usage
# ============================================================================
#
# 1. Trajectory hierarchy:
# - Level 1: SPAN (shakespeare_x_post_orchestrator)
# - Level 2: SPAN (crew_execution)
# - Level 3: SPAN (topic_analysis, content_generation_loop)
# - Level 4: Chain (Crew***.kickoff; wildcard-normalized UUID)
# - Level 5: AGENT (exact match for agent role)
# - Level 6: LLM (wildcard match for any model)
# - Level 6: Tool (exact match for tool name)
#
# 2. Wildcard handling:
# - Crew_<UUID>.kickoff -> Crew***.kickoff (handled by evaluate_trajectory.py)
# - LLM: * -> matches any model name (e.g., gpt-4o-mini, deepseek-reasoner, gemini-2.5-flash)
# - Agent names must match fully (including the complete role name)
#
# 3. Exact-match requirements:
# - SPAN names: "shakespeare_x_post_orchestrator", "crew_execution",
# "topic_analysis", "content_generation_loop"
# - Chain name: "Crew***.kickoff" (wildcard match)
# - Agent names: "Agent: Topic Analysis Expert",
# "Agent: Shakespearean Bard",
# "Agent: X Post Verifier"
# (must exactly match the role field in agents.yaml)
# - LLM name: "LLM: *" (wildcard match for any model)
# - Tool names: must exactly match MCP tool names (keyword_extractor, topic_complexity_analyzer,
# character_counter_tool, emoji_detector_tool, post_structure_validator,
# shakespearean_style_detector, tone_analyzer)
#
# 4. Metric meanings:
# - Exact Match: trajectories must be identical (including the number of LLM and tool calls)
# - In-order Match: extra calls allowed, but core steps must appear in order
# - Any-order Match: all required steps must appear (order ignored)
# - Precision: fraction of predicted steps that are correct
# - Recall: fraction of reference steps covered by the prediction
# - Single-tool Use: checks usage of core tools
# - unique_path_ratio: path diversity (unique full trajectories / samples)
# - path_entropy: path entropy (Shannon entropy over trajectory frequencies, normalized to 0-1)
#
# 5. Run:
# python3 evaluate_trajectory.py --config reference_trajectory.yaml
#
# 6. Design notes:
# - This reference trajectory represents the ideal execution path (no retries, no errors)
# - Two main stages execute sequentially: Topic Analysis → Content Generation Loop
# - Stage 1 (Topic Analysis): Topic Analyst uses 2 tools to analyze the topic
# - Stage 2 (Content Generation Loop): contains a self-evaluation loop
# * Shakespearean Bard generates the X post and self-validates with multiple tools
# * X Post Verifier performs comprehensive validation using all validation tools
# * Ideal case: valid=True on the first attempt, no retries needed
# - In-order Match and Recall are often more suitable for evaluating practical performance
# - The reference trajectory defines only core required steps and allows extra tool/LLM calls
#
# 7. Differences from real trajectories:
# - Real trajectories may include business-logic retries (validation failure triggers regeneration)
# - Real trajectories may include orchestrator-level retries (exceptions trigger workflow retry)
# - Generator may use a different tool order (but should still use tools required by tasks.yaml)
# - Verifier may use a different tool order (but must use all 5 validation tools)
# - Some reasoning models (e.g., DeepSeek-R1) may include many extra LLM calls
# - Some models (e.g., Gemini) may skip tool calls and directly generate outputs (non-compliant)
# - These differences are not necessarily errors, but skipping required tools or failing validation is abnormal
#
# 8. MCP version characteristics:
# - All tools are provided by an MCP server using the SSE protocol
# - Tools are obtained from the server via MCPServerAdapter
# - Includes multi-level SPAN structure (orchestrator + crew_execution + 2 stage SPANs)
# - Three specialized crews collaborate to generate Shakespeare-style X posts
# - Each crew has a clear responsibility and an explicit set of available tools
# - TopicAnalyzerCrew: 1 agent, analyzes the topic and extracts insights
# - ShakespeareGeneratorCrew: 1 agent, generates and self-validates the X post
# - PostReviewCrew: 1 agent, comprehensively validates the X post
# - Tool categories: analysis tools (keyword_extractor, topic_complexity_analyzer) and
# validation tools (character_counter_tool, emoji_detector_tool, post_structure_validator,
# shakespearean_style_detector, tone_analyzer)
#
# 9. Business-logic notes:
# - The self-evaluation loop is critical: generation must be followed by validation
# - If validation fails (valid=False), regenerate with feedback (up to 6 attempts)
# - If all attempts fail, the workflow ends and the failed X post is saved
# - The ideal trajectory assumes the first generation passes validation (best case)
# - Generator should self-validate using all tools required by tools.yaml
# - Verifier must use all 5 validation tools for thorough validation
# - Some real trajectories may include multiple generation-validation cycles (normal business retries)
#
# 10. Tool usage requirements (based on tasks.yaml):
# - Topic Analyst (analyze_topic task):
# * Explicit requirement: "Start by using the available analytical tools"
# * Must use: keyword_extractor, topic_complexity_analyzer
# * Order: none (tasks.yaml does not specify)
# - Shakespearean Bard (write_x_post task):
# * Explicit requirement: "STEP 1 - REQUIRED: First, use the keyword_extractor tool"
# * Explicit requirement: "IMPORTANT: Before finalizing, use the available tools to verify quality"
# * Must use: keyword_extractor (must be the first tool)
# * Should use: character_counter_tool, emoji_detector_tool, post_structure_validator,
# shakespearean_style_detector, tone_analyzer (quality validation)
# * Order: keyword_extractor must be first; remaining validation tools have no order constraint
# - X Post Verifier (verify_x_post task):
# * Explicit requirement: "CRITICAL: You MUST use the following tools to perform thorough validation"
# * Must use: character_counter_tool, emoji_detector_tool, post_structure_validator,
# shakespearean_style_detector, tone_analyzer (all 5)
# * Requirement: "Base your validation decision on these tool results, not assumptions"
# * Order: none (tasks.yaml does not specify)
#
# 11. Tool ordering notes:
# - **Ordered scenario**:
# * Shakespearean Bard's keyword_extractor must be the first tool
# (tasks.yaml line 7-8: "STEP 1 - REQUIRED: First, use the keyword_extractor tool")
# - **Unordered scenarios**:
# * Topic Analyst's two tools (keyword_extractor, topic_complexity_analyzer) can be in any order
# * Shakespearean Bard's 5 validation tools can be in any order (as long as after keyword_extractor)
# * X Post Verifier's 5 validation tools can be in any order
# - **Order in the reference trajectory**:
# * The listed order reflects common observed patterns
# * Evaluation should allow flexible tool ordering (except the Bard's keyword_extractor-first constraint)
# * The evaluator should enforce the "keyword_extractor must be first" constraint for the Bard
#
# 12. Dynamic tool permutation optimization:
# - **Idea**: tool calls within each AGENT can have different orders
# - **Mechanism**:
# * permutable_tool_groups defines permutable tool groups
# * The evaluator generates all tool-order permutations (Cartesian product)
# * For each sample, select the permutation with the highest combined score across
# exact_match, in_order_match, and any_order_match
# - **Number of permutations**:
# * topic_analysis_tools: 2! = 2
# * shakespearean_bard_validation_tools: 5! = 120
# * x_post_verifier_tools: 5! = 120
# * Total: 2 × 120 × 120 = 28,800 candidate reference trajectories
# - **Evaluation strategy**:
# * Dynamically select the best reference trajectory per test sample
# * Combined score = exact_match×3 + in_order_match×2 + any_order_match×1
# * This is fairer and adapts to different models' tool-calling strategies
# - **Notes**:
# * The Bard's first keyword_extractor is not permuted (must remain first)
# * Permutations are within an AGENT boundary only (not across AGENT boundaries)
# * Tool permutations do not change the positions or counts of LLM calls