File size: 13,848 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# Full reference trajectory configuration - LandingPageGenerator-A2A project
#
# 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. The orchestrator calls three independent servers via the A2A protocol (orchestrator.py):
#    - Idea Expansion Server: Product Idea Analyst uses bocha_websearch_tool for market research
#    - Template Selection Server: Template Selection Specialist uses learn_landing_page_options to pick a template
#    - Content Creation Server: Landing Page Content Generator uses read_file_content and write_file_with_content to produce HTML
#
# 2. Tool usage analysis:
#    - Server 1: bocha_websearch_tool (MCP tool, web search)
#    - Server 2: learn_landing_page_options (MCP tool, learn available templates)
#    - Server 3: read_file_content + write_file_with_content (MCP tools, file operations)
#
# 3. Execution flow (A2A architecture):
#    - The orchestrator creates a top-level SPAN: landing_page_generation-A2A
#    - The orchestrator creates a crew_execution SPAN containing 3 A2A calls
#    - Each A2A call has 3 nested SPAN layers:
#      * orchestrator method layer: expand_idea / select_template / create_content
#      * HTTP call layer: a2a_call_*
#      * server execution layer: *_server_execution
#    - Each server runs an independent Crew (Chain + Agent + Tools)
#    - The Agent uses the LLM to decide tool calls; after tool returns, the LLM generates the output
#
# 4. SPAN hierarchy (A2A-specific multi-level nesting):
#    - landing_page_generation-A2A (top level, orchestrator.py line 451)
#      └─ crew_execution (contains 3 A2A calls, orchestrator.py line 482)
#         ├─ expand_idea (orchestrator.py line 267)
#         │  └─ a2a_call_idea_expansion (orchestrator.py line 172)
#         │     └─ idea_expansion_server_execution (inside the A2A server)
#         │        └─ Crew***.kickoff (Crew chain)
#         │           └─ Agent execution
#         ├─ select_template (orchestrator.py line 305)
#         │  └─ a2a_call_template_selection (orchestrator.py line 172)
#         │     └─ template_selection_server_execution (inside the A2A server)
#         │        └─ Crew***.kickoff (Crew chain)
#         │           └─ Agent execution
#         └─ create_content (orchestrator.py line 350)
#            └─ a2a_call_content_creation (orchestrator.py line 172)
#               └─ content_creation_server_execution (inside the A2A server)
#                  └─ Crew***.kickoff (Crew chain)
#                     └─ Agent execution

# Project name
project_name: "LandingPageGenerator-A2A"

# Trajectory extraction types
extract_types:
  - "SPAN" # Multi-level SPAN structure
  - "Chain" # Crew kickoff chain
  - "AGENT" # Crew agent
  - "LLM" # LLM calls
  - "Tool" # MCP tool calls

# ============================================================================
# Reference trajectory (Ground Truth) - derived from the code design
# ============================================================================
#
# Visual structure (ideal execution path; A2A-specific multi-level SPAN nesting):
#
# [SPAN] landing_page_generation-A2A
# └─ [SPAN] crew_execution
#    ├─ [SPAN] expand_idea
#    │  └─ [SPAN] a2a_call_idea_expansion
#    │     └─ [SPAN] idea_expansion_server_execution
#    │        └─ [Chain] Crew***.kickoff
#    │           └─ [AGENT] Product Idea Analyst
#    │              ├─ [LLM] *
#    │              ├─ [Tool] bocha_websearch_tool
#    │              └─ [LLM] *
#    ├─ [SPAN] select_template
#    │  └─ [SPAN] a2a_call_template_selection
#    │     └─ [SPAN] template_selection_server_execution
#    │        └─ [Chain] Crew***.kickoff
#    │           └─ [AGENT] Template Selection Specialist
#    │              ├─ [LLM] *
#    │              ├─ [Tool] learn_landing_page_options
#    │              └─ [LLM] *
#    └─ [SPAN] create_content
#       └─ [SPAN] a2a_call_content_creation
#          └─ [SPAN] content_creation_server_execution
#             └─ [Chain] Crew***.kickoff
#                └─ [AGENT] Landing Page Content Generator
#                   ├─ [LLM] *
#                   ├─ [Tool] read_file_content
#                   ├─ [LLM] *
#                   ├─ [Tool] write_file_with_content
#                   └─ [LLM] *
#
# Design basis:
# - orchestrator.py: calls 3 independent servers via the A2A protocol
# - Each A2A call has 3 nested SPAN layers (orchestrator method layer + HTTP call layer + server execution layer)
# - Each server runs an independent Crew with 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 each server's config/agents.yaml
# - Tools are obtained from the MCP server via MCPServerAdapter (each A2A server connects independently)
#
# Notes on the ideal trajectory (A2A characteristics):
# - Top-level SPAN: landing_page_generation-A2A (created by the orchestrator)
# - Second-level SPAN: crew_execution (contains 3 A2A calls)
# - Each A2A call has additional 3 nested SPAN layers (orchestrator method → HTTP call → server execution)
# - Each server internally: Chain → Agent → LLM+Tool interaction
# - Idea Expansion: at least 2 LLM calls + 1 bocha_websearch_tool call
# - Template Selection: at least 2 LLM calls + 1 learn_landing_page_options call
# - Content Creation: at least 3 LLM calls + 1 read_file_content call + 1 write_file_with_content call
# - This trajectory represents an ideal, retry-free, and redundant-free execution path
#
# Notes:
# - "LLM: *" means any LLM model (wildcard match)
# - Agent names must match the `role` field in each agents.yaml exactly
# - Tool names must match the tool names provided by the MCP server exactly
# - [Crew Created] and [Task Created] are excluded (framework telemetry events, not business logic)
# - Real executions may contain more LLM calls (thinking, planning, etc.); this is normal
# - A2A has a deeper SPAN hierarchy than MCP (3 additional nested SPAN layers)
# ============================================================================

reference_trajectory:
  # ===== Top-level SPAN (created by the orchestrator) =====
  - "SPAN: landing_page_generation-A2A"

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

  # ===== A2A call 1: Idea Expansion =====
  - "SPAN: expand_idea" # orchestrator method
  - "SPAN: a2a_call_idea_expansion" # HTTP call layer
  - "SPAN: idea_expansion_server_execution" # server execution layer
  - "Chain: Crew***.kickoff"
  - "Agent: Product Idea Analyst"
  - "LLM: *" # decide which tool to call
  - "Tool: bocha_websearch_tool" # web search (market research)
  - "LLM: *" # generate the expanded idea

  # ===== A2A call 2: Template Selection =====
  - "SPAN: select_template" # orchestrator method
  - "SPAN: a2a_call_template_selection" # HTTP call layer
  - "SPAN: template_selection_server_execution" # server execution layer
  - "Chain: Crew***.kickoff"
  - "Agent: Template Selection Specialist"
  - "LLM: *" # decide which tool to call
  - "Tool: learn_landing_page_options" # learn available templates
  - "LLM: *" # select a template

  # ===== A2A call 3: Content Creation =====
  - "SPAN: create_content" # orchestrator method
  - "SPAN: a2a_call_content_creation" # HTTP call layer
  - "SPAN: content_creation_server_execution" # server execution layer
  - "Chain: Crew***.kickoff"
  - "Agent: Landing Page Content Generator"
  - "LLM: *" # decide to read the template
  - "Tool: read_file_content" # read template file
  - "LLM: *" # generate HTML content
  - "Tool: write_file_with_content" # write HTML file
  - "LLM: *" # final confirmation

# Target tools (for 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 notes - A2A specific
# ============================================================================
#
# 1. Trajectory hierarchy (A2A multi-level SPAN nesting):
#    - Level 1: SPAN (landing_page_generation-A2A) - orchestrator top level
#    - Level 2: SPAN (crew_execution) - orchestrator contains 3 A2A calls
#    - Level 3: SPAN (expand_idea, select_template, create_content) - orchestrator method layer
#    - Level 4: SPAN (a2a_call_*) - HTTP call layer
#    - Level 5: SPAN (*_server_execution) - A2A server execution layer
#    - Level 6: Chain (Crew***.kickoff) - Crew kickoff chain (wildcard for UUID)
#    - Level 7: Crew Created / AGENT / Task Created
#    - Level 8: LLM (wildcard for any model) / Tool (exact match for tool name)
#
# 2. Wildcard handling:
#    - Crew_<UUID>.kickoff -> Crew***.kickoff (handled automatically by evaluate_trajectory.py)
#    - LLM: * -> matches any model name (e.g., gpt-5-chat-latest, deepseek-reasoner, gemini-2.5-flash, etc.)
#
# 3. Exact matching requirements:
#    - SPAN names:
#      * top level: "landing_page_generation-A2A", "crew_execution"
#      * orchestrator method layer: "expand_idea", "select_template", "create_content"
#      * HTTP call layer: "a2a_call_idea_expansion", "a2a_call_template_selection", "a2a_call_content_creation"
#      * server execution layer: "idea_expansion_server_execution", "template_selection_server_execution", "content_creation_server_execution"
#    - Chain name: "Crew***.kickoff" (wildcard for the UUID part)
#    - AGENT names: "Product Idea Analyst", "Template Selection Specialist", "Landing Page Content Generator"
#      (must match the `role` field in each A2A server's config/agents.yaml)
#    - Event markers: "Crew Created", "Task Created" (auto-generated by the CrewAI framework)
#    - LLM name: "LLM: *" (wildcard for any model)
#    - Tool names: must match MCP tool names exactly (bocha_websearch_tool, learn_landing_page_options,
#      read_file_content, write_file_with_content)
#
# 4. Metric definitions:
#    - Exact Match: the entire trajectory must be identical (including the number of LLM calls and all SPAN levels)
#    - In-order Match: extra calls are allowed, but core steps must appear in order
#    - Any-order Match: must contain all required steps (order ignored)
#    - Precision: fraction of correct steps among predicted steps
#    - Recall: fraction of reference steps covered by the prediction
#    - Single-tool Use: checks usage of all 4 required tools
#    - unique_path_ratio: path diversity (number of unique full trajectories / samples)
#    - path_entropy: path entropy (Shannon entropy over trajectory frequencies, normalized to 0-1)
#
# 5. Run command:
#    python3 evaluate_trajectory.py --config reference_trajectory.yaml
#
# 6. Design notes (A2A characteristics):
#    - This reference trajectory represents an ideal execution path
#    - The orchestrator calls 3 independent servers via A2A (HTTP/JSONRPC)
#    - Each A2A call includes 3 nested SPAN layers (method layer + HTTP call layer + server execution layer)
#    - Each server runs an independent Crew to complete a specific task
#    - Server 1 (Idea Expansion): at least 2 LLM calls + 1 bocha_websearch_tool call
#    - Server 2 (Template Selection): at least 2 LLM calls + 1 learn_landing_page_options call
#    - Server 3 (Content Creation): at least 3 LLM calls + 1 read_file_content call + 1 write_file_with_content call
#    - Total: 2 top-level SPANs + 3 method SPANs + 3 call SPANs + 3 server SPANs + 3 Chains + 3 Agents + 7 LLM calls + 4 tools
#    - Trajectory length: 28 steps (excluding 6 framework event markers)
#    - In-order Match and Recall are often more suitable for evaluating actual performance
#
# 7. Differences from real trajectories:
#    - Real trajectories may include more LLM calls (thinking, planning, execution, summarization, etc.)
#    - Some models may call tools multiple times (retries or additional checks)
#    - Content Creation may read multiple files (e.g., CSS, JS, etc.)
#    - Some models may not use tools (e.g., Gemini may generate content directly without calling bocha_websearch_tool)
#    - These differences do not necessarily indicate errors; they reflect different execution strategies
#    - Exact Match may be low; focus on In-order Match and Recall
#
# 8. A2A architecture characteristics:
#    - Agent-to-agent communication via HTTP/JSONRPC
#    - Each A2A server runs independently and maintains its own MCP connection
#    - The SPAN hierarchy is deeper than the MCP monolithic version (3 additional nested SPAN layers)
#    - Tracing code in orchestrator.py creates the multi-level SPAN structure
#    - Each server returns results to the orchestrator after execution
#    - Supports distributed deployment and independent scaling
#
# 9. Known model behavior differences:
#    - Gemini family: may not call bocha_websearch_tool and instead rely on internal knowledge
#    - DeepSeek-R1: may call learn_landing_page_options and read_file_content multiple times
#    - GPT-5: typically follows the tool-calling workflow more strictly
#    - These differences reflect different planning and execution strategies