File size: 9,671 Bytes
8c10cf2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Full reference trajectory configuration - LandingPageGenerator-MCP project
#
# Version: ideal trajectory based on code design (applies to all models)
# Principle: only include steps explicitly required by the code design; do not rely on test statistics
#
# Code design analysis:
# 1. Three Crews run sequentially (orchestrator.py):
#    - IdeaExpansionCrew: Product Idea Analyst uses bocha_websearch_tool for market research
#    - TemplateSelectionCrew: Template Selection Specialist uses learn_landing_page_options to select templates
#    - ContentCreationCrew: Landing Page Content Generator uses read_file_content and write_file_with_content to generate HTML
#
# 2. Tool usage analysis:
#    - Crew 1: bocha_websearch_tool (MCP tool; web search)
#    - Crew 2: learn_landing_page_options (MCP tool; learn available templates)
#    - Crew 3: read_file_content + write_file_with_content (MCP tools; file operations)
#
# 3. Execution flow:
#    - orchestrator creates the top-level SPAN: landing_page_generation-MCP
#    - orchestrator creates crew_execution SPAN containing 3 child SPANs
#    - Crew SPANs: idea_expansion, template_selection, content_creation
#    - Each Crew includes one Chain and one Agent
#    - The Agent uses the LLM to decide tool calls; after tool returns, the LLM generates the output
#
# 4. SPAN hierarchy:
#    - landing_page_generation-MCP (top-level; orchestrator.py line 341)
#      └─ crew_execution (contains 3 Crews; orchestrator.py line 365)
#         ├─ idea_expansion (Crew 1; orchestrator.py line 70)
#         ├─ template_selection (Crew 2; orchestrator.py line 115)
#         └─ content_creation (Crew 3; orchestrator.py line 167)

# Project name
project_name: "LandingPageGenerator-MCP"

# Trajectory extraction type configuration
extract_types:
  - "SPAN" # Multi-level SPAN structure
  - "Chain" # Kickoff chain for each Crew
  - "AGENT" # Agent for each Crew
  - "LLM" # LLM calls
  - "Tool" # MCP tool calls

# ============================================================================
# Reference trajectory (Ground Truth) - based on code design
# ============================================================================
#
# Diagram (ideal execution path):
#
# [SPAN] landing_page_generation-MCP
# └─ [SPAN] crew_execution
#    ├─ [SPAN] idea_expansion
#    │  └─ [Chain] Crew***.kickoff
#    │     └─ [AGENT] Product Idea Analyst
#    │        ├─ [LLM] *
#    │        ├─ [Tool] bocha_websearch_tool
#    │        └─ [LLM] *
#    ├─ [SPAN] template_selection
#    │  └─ [Chain] Crew***.kickoff
#    │     └─ [AGENT] Template Selection Specialist
#    │        ├─ [LLM] *
#    │        ├─ [Tool] learn_landing_page_options
#    │        └─ [LLM] *
#    └─ [SPAN] content_creation
#       └─ [Chain] Crew***.kickoff
#          └─ [AGENT] Landing Page Content Generator
#             ├─ [LLM] *
#             ├─ [Tool] read_file_content
#             ├─ [LLM] *
#             ├─ [Tool] write_file_with_content
#             └─ [LLM] *
#
# Design basis:
# - orchestrator.py: runs 3 Crews sequentially
# - Each Crew has 1 Agent and 1 Task
# - idea_expansion_crew.py: Product Idea Analyst uses bocha_websearch_tool
# - template_selection_crew.py: Template Selection Specialist uses learn_landing_page_options
# - content_creation_crew.py: Landing Page Content Generator uses read_file_content and write_file_with_content
# - All Agent roles are defined in agents.yaml
# - Tools are retrieved from the MCP server via MCPServerAdapter
#
# Ideal trajectory notes:
# - Top-level SPAN: landing_page_generation-MCP
# - Second-level SPAN: crew_execution (contains 3 Crews)
# - The 3 Crews run sequentially; each has its own SPAN
# - Each Agent: at least 2 LLM calls + required tool calls
# - Idea Expansion: 1 tool call (bocha_websearch_tool)
# - Template Selection: 1 tool call (learn_landing_page_options)
# - Content Creation: 2 tool calls (read_file_content + write_file_with_content)
# - This trajectory represents the ideal execution path with no retries and no redundant steps
#
# Notes:
# - "LLM: *" means any LLM model (wildcard match)
# - Agent names must exactly match the role fields in agents.yaml
# - Tool names must exactly match the tool names provided by the MCP server
# - Actual execution may include more LLM calls (thinking/planning/etc.); this is expected
# ============================================================================

reference_trajectory:
  # ===== Top-level SPAN =====
  - "SPAN: landing_page_generation-MCP"

  # ===== Second-level SPAN (contains 3 Crews) =====
  - "SPAN: crew_execution"

  # ===== Crew 1: Idea Expansion =====
  - "SPAN: idea_expansion"
  - "Chain: Crew***.kickoff"
  - "Agent: Product Idea Analyst"
  - "LLM: *" # Decide to call tools
  - "Tool: bocha_websearch_tool" # Web search
  - "LLM: *" # Generate an expanded idea

  # ===== Crew 2: Template Selection =====
  - "SPAN: template_selection"
  - "Chain: Crew***.kickoff"
  - "Agent: Template Selection Specialist"
  - "LLM: *" # Decide to call tools
  - "Tool: learn_landing_page_options" # Learn available templates
  - "LLM: *" # Select a template

  # ===== Crew 3: Content Creation =====
  - "SPAN: content_creation"
  - "Chain: Crew***.kickoff"
  - "Agent: Landing Page Content Generator"
  - "LLM: *" # Decide to read the template
  - "Tool: read_file_content" # Read the template file
  - "LLM: *" # Generate HTML content
  - "Tool: write_file_with_content" # Write the HTML file
  - "LLM: *" # Final confirmation

# Target tool list (used by the single-tool use metric)
# List all required tools here
target_tools:
  - "Tool: bocha_websearch_tool"
  - "Tool: learn_landing_page_options"
  - "Tool: read_file_content"
  - "Tool: write_file_with_content"

# 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 (landing_page_generation-MCP)
#    - Level 2: SPAN (idea_expansion, template_selection, content_creation)
#    - Level 3: Chain (Crew***.kickoff; wildcard-normalized UUID)
#    - Level 4: AGENT (exact match on agent role)
#    - Level 5: LLM (wildcard match any model)
#    - Level 5: Tool (exact match on tool name)
#
# 2. Wildcard handling:
#    - Crew_<UUID>.kickoff -> Crew***.kickoff (handled automatically by evaluate_trajectory.py)
#    - LLM: * -> match any model name (e.g., gpt-4o-mini, deepseek-r1)
#
# 3. Exact match requirements:
#    - SPAN names: "landing_page_generation-MCP", "crew_execution", "idea_expansion", "template_selection", "content_creation"
#    - Chain names: "Crew***.kickoff" (wildcard match)
#    - AGENT names: "Product Idea Analyst", "Template Selection Specialist", "Landing Page Content Generator"
#      (exact match the role fields in agents.yaml)
#    - LLM: "LLM: *" (wildcard match any model)
#    - Tool: exact match MCP tool names (bocha_websearch_tool, learn_landing_page_options,
#      read_file_content, write_file_with_content)
#
# 4. Metric meanings:
#    - Exact Match: trajectories must be identical (including LLM call count)
#    - In-order Match: extra calls allowed, but core steps must appear in order
#    - Any-order Match: contains all required steps (order ignored)
#    - Precision: fraction of predicted steps considered correct
#    - Recall: fraction of reference steps covered
#    - Single-tool Use: checks usage of all 4 required tools
#    - unique_path_ratio: path diversity (unique full trajectories / sample count)
#    - path_entropy: path entropy (Shannon entropy over trajectory frequencies; normalized to 0-1)
#
# 5. Run command:
#    cd /Users/wzr/TOSEM-2025/RESULTS/RQ-Failure_Breakdown/LandingPageGenerator-MCP
#    python3 evaluate_trajectory.py --config reference_trajectory.yaml
#
# 6. Design notes:
#    - This reference trajectory represents the ideal execution path
#    - Three Crews run sequentially; each Crew completes its task independently
#    - Crew 1 (Idea Expansion): 1 LLM decision + 1 web search + 1 LLM generation
#    - Crew 2 (Template Selection): 1 LLM decision + 1 template-learning tool call + 1 LLM selection
#    - Crew 3 (Content Creation): 1 LLM decision + 1 template read + 1 LLM generation + 1 file write + 1 LLM confirmation
#    - Total: 2 top-level SPANs (landing_page_generation-MCP + crew_execution) + 3 Crew SPANs + 3 Chains + 3 Agents + 9 LLM calls + 4 tool calls
#    - In-order Match and Recall are often more suitable for evaluating real performance
#
# 7. Differences vs. actual trajectories:
#    - Actual trajectories may include more LLM calls (thinking/planning/execution/summarization)
#    - Some models may call tools multiple times (retries or extra checks)
#    - Template Selection may call learn_landing_page_options multiple times
#    - These differences are not necessarily errors; they reflect different execution strategies
#    - Exact Match may be low; focus on In-order Match and Recall
#
# 8. MCP version characteristics:
#    - All tools are provided via the MCP server using SSE for communication
#    - Tools are fetched from the server via MCPServerAdapter
#    - Includes a multi-level SPAN structure (orchestrator + crew_execution + 3 Crews)
#    - Three independent Crews collaborate to complete the landing page generation task
#    - Each Crew has clear responsibilities and required tools