File size: 14,046 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# Full reference-trajectory configuration - SocialMediaManager-H_A2A
#
# Version: ported from SocialMediaManager-A2A and adapted to the A2A_mix hybrid architecture
# Principle: keep business logic unchanged while adapting to the hybrid framework hierarchy (LangGraph + CrewAI + AutoGen)
#
# A2A_mix hybrid-architecture characteristics:
# - Stage 1 (Topic Analysis): LangGraph
#   * Uses [Chain] LangGraph instead of CrewAI's Crew***.kickoff
#   * Uses a simplified AGENT name: "agent" (not the full role name)
#   * Tool calls appear under [Chain] tools, supporting batched execution
#   * LangGraph-specific chains: _should_continue and format_output
#
# - Stage 2 (Content Generation): CrewAI
#   * Keeps the standard [Chain] Crew***.kickoff structure
#   * Uses the full agent role name: "Shakespearean Bard._execute_core"
#   * Tool calls appear directly under AGENT (no intermediate Chain)
#
# - Stage 3 (Post Review): AutoGen
#   * AGENT pattern: create_agent + invoke_agent
#   * Ignore create_agent (excluded from evaluation)
#   * Focus on invoke_agent execution
#   * Tool prefix is "execute_tool"
#   * Filter all [SPAN] mcp client/operation and its children
#
# Dynamic reference-trajectory design (5-way dynamic composition):
# 1. LangGraph tools batched-execution grouping (2 options):
#    - [1,1]: two Chain: tools, each containing 1 tool
#    - [2]: one Chain: tools containing 2 tools
#
# 2. LangGraph tools order (2! = 2 options):
#    - keyword_extractor → topic_complexity_analyzer
#    - topic_complexity_analyzer → keyword_extractor
#
# 3. AutoGen LLM/Tool insertion pattern (2^4 = 16 options):
#    Rule: must start and end with an LLM; between adjacent tools there may be 0 or 1 LLM
#    - 5 tools have 4 adjacency gaps → 2^4 = 16 combinations
#    - Example: LLM → Tool1 → Tool2 → Tool3 → Tool4 → Tool5 → LLM (no insertion)
#              LLM → Tool1 → LLM → Tool2 → LLM → Tool3 → LLM → Tool4 → LLM → Tool5 → LLM (insert everywhere)
#
# 4. AutoGen tools order (5! = 120 options):
#    - The 5 verification tools can appear in any order
#    - character_counter_tool, emoji_detector_tool, post_structure_validator,
#      shakespearean_style_detector, tone_analyzer
#
# 5. CrewAI tool order (5! = 120 options):
#    - Shakespearean Bard's 5 validation tools can appear in any order
#    - keyword_extractor must be the first tool (not permuted)
#
# Total combinations: 2 × 2 × 16 × 120 × 120 = 921,600 reference variants
#
# Evaluation strategy: for each sample, select the variant with the highest score:
# exact_match×3 + in_order_match×2 + any_order_match×1

# Project name
project_name: "SocialMediaManager-H_A2A"

# Extraction types
extract_types:
  - "SPAN" # multi-level SPAN structure
  - "Chain" # Chain nodes for LangGraph/CrewAI
  - "AGENT" # Agent nodes (AutoGen: only invoke_agent is extracted)
  - "LLM" # LLM calls
  - "Tool" # tool calls

# ============================================================================
# Reference trajectory (Ground Truth) - A2A_mix hybrid architecture
# ============================================================================
#
# Visual structure (ideal execution path; example with batched tools execution):
#
# [SPAN] shakespeare_x_post_orchestrator
# └─ [SPAN] crew_execution
#    ├─ [SPAN] analyze_topic (LangGraph)
#    │  └─ [SPAN] a2a_call_topic_analyzer
#    │     └─ [SPAN] topic_analyzer_server_execution
#    │        └─ [Chain] LangGraph
#    │           ├─ [AGENT] agent
#    │           │  ├─ [LLM] *
#    │           │  └─ [Chain] _should_continue
#    │           ├─ [Chain] tools (batched execution of 2 tools; possible groupings: 1+1, 2)
#    │           │  ├─ [Tool] keyword_extractor
#    │           │  └─ [Tool] topic_complexity_analyzer
#    │           ├─ [AGENT] agent
#    │           │  ├─ [LLM] *
#    │           │  └─ [Chain] _should_continue
#    │           └─ [Chain] format_output
#    └─ [SPAN] content_generation_loop
#       ├─ [SPAN] a2a_call_content_generator (CrewAI)
#       │  └─ [SPAN] content_generator_server_execution
#       │     └─ [Chain] Crew***.kickoff
#       │        └─ [AGENT] Shakespearean Bard
#       │           ├─ [LLM] *
#       │           ├─ [Tool] keyword_extractor
#       │           ├─ [LLM] *
#       │           ├─ [Tool] character_counter_tool
#       │           ├─ [LLM] *
#       │           ├─ [Tool] emoji_detector_tool
#       │           ├─ [LLM] *
#       │           ├─ [Tool] post_structure_validator
#       │           ├─ [LLM] *
#       │           ├─ [Tool] shakespearean_style_detector
#       │           ├─ [LLM] *
#       │           ├─ [Tool] tone_analyzer
#       │           └─ [LLM] *
#       └─ [SPAN] a2a_call_post_reviewer (AutoGen)
#          └─ [SPAN] post_reviewer_autogen_execution
#             └─ [AGENT] invoke_agent x_post_verifier
#                ├─ [LLM] *
#                ├─ [Tool] execute_tool character_counter_tool
#                ├─ [Tool] execute_tool emoji_detector_tool
#                ├─ [Tool] execute_tool post_structure_validator
#                ├─ [Tool] execute_tool shakespearean_style_detector
#                ├─ [Tool] execute_tool tone_analyzer
#                └─ [LLM] *
#
# Notes:
# - Under LangGraph's [Chain] tools there may be batched calls (2 tools can be grouped as 1+1 or 2)
# - AutoGen create_agent nodes are excluded from the reference trajectory
# - AutoGen [SPAN] mcp client/operation and its children are excluded from the reference trajectory
# - Between AutoGen tools there may be 0 or 1 LLM; the evaluator will generate all valid patterns
# ============================================================================

# Default reference trajectory (compatibility): batched LangGraph tools, AutoGen compact mode
reference_trajectory:
  # ===== Top-level SPAN =====
  - "SPAN: shakespeare_x_post_orchestrator"

  # ===== Second-level SPAN (includes retry logic) =====
  - "SPAN: crew_execution"

  # ===== Stage 1: Topic Analysis (LangGraph; 2 tools) =====
  - "SPAN: analyze_topic"
  - "SPAN: a2a_call_topic_analyzer"
  - "SPAN: topic_analyzer_server_execution"
  - "Chain: LangGraph"
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  - "Chain: tools"
  - "Tool: keyword_extractor"
  - "Tool: topic_complexity_analyzer"
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  - "Chain: format_output"

  # ===== Stage 2: Content Generation (CrewAI) =====
  - "SPAN: content_generation_loop"
  - "SPAN: a2a_call_content_generator"
  - "SPAN: content_generator_server_execution"
  - "Chain: Crew***.kickoff"
  - "AGENT: Shakespearean Bard"
  - "LLM: *"
  - "Tool: keyword_extractor"
  - "LLM: *"
  - "Tool: character_counter_tool"
  - "LLM: *"
  - "Tool: emoji_detector_tool"
  - "LLM: *"
  - "Tool: post_structure_validator"
  - "LLM: *"
  - "Tool: shakespearean_style_detector"
  - "LLM: *"
  - "Tool: tone_analyzer"
  - "LLM: *"

  # ===== Stage 3: Post Review (AutoGen) =====
  - "SPAN: a2a_call_post_reviewer"
  - "SPAN: post_reviewer_autogen_execution"
  - "AGENT: invoke_agent x_post_verifier"
  - "LLM: *"
  - "Tool: execute_tool character_counter_tool"
  - "Tool: execute_tool emoji_detector_tool"
  - "Tool: execute_tool post_structure_validator"
  - "Tool: execute_tool shakespearean_style_detector"
  - "Tool: execute_tool tone_analyzer"
  - "LLM: *"

# Target tool list (used for the single-tool use metric)
target_tools:
  # Topic Analysis stage (LangGraph)
  - "Tool: keyword_extractor"
  - "Tool: topic_complexity_analyzer"
  # Content Generation stage (CrewAI)
  - "Tool: character_counter_tool"
  - "Tool: emoji_detector_tool"
  - "Tool: post_structure_validator"
  - "Tool: shakespearean_style_detector"
  - "Tool: tone_analyzer"
  # Post Review stage (AutoGen; note the execute_tool prefix)
  - "Tool: execute_tool character_counter_tool"
  - "Tool: execute_tool emoji_detector_tool"
  - "Tool: execute_tool post_structure_validator"
  - "Tool: execute_tool shakespearean_style_detector"
  - "Tool: execute_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"

# Permutable tool-group configuration (for dynamic tool-order matching)
permutable_tool_groups:
  # Shakespearean Bard validation tools can be in any order (CrewAI part)
  # Note: keyword_extractor must be the first tool and is not permuted
  shakespearean_bard_validation_tools:
    - "Tool: character_counter_tool"
    - "Tool: emoji_detector_tool"
    - "Tool: post_structure_validator"
    - "Tool: shakespearean_style_detector"
    - "Tool: tone_analyzer"
# ============================================================================
# Usage notes - A2A_mix hybrid architecture
# ============================================================================
#
# 1. Hybrid framework characteristics:
#    - Stage 1 (Topic Analysis): LangGraph
#      * Chain name: LangGraph (not Crew***.kickoff)
#      * Simplified AGENT name: agent (not a full role name)
#      * Batched tool execution: [Chain] tools may contain multiple Tool nodes
#      * Special chains: _should_continue and format_output
#
#    - Stage 2 (Content Generation): CrewAI
#      * Standard CrewAI structure: Crew***.kickoff → AGENT → LLM/Tool
#      * Full AGENT name: Shakespearean Bard
#      * keyword_extractor must be the first tool; subsequent validation tools may be in any order
#
#    - Stage 3 (Post Review): AutoGen
#      * Ignore create_agent (excluded from evaluation)
#      * Focus on invoke_agent x_post_verifier
#      * Tool prefix: execute_tool
#      * Filter all [SPAN] mcp client/operation and its children
#
# 2. LangGraph dynamic tool mode (grouping + order):
#    The evaluator automatically detects the tools grouping pattern and tool order in each sample,
#    and dynamically generates matching reference variants.
#
#    Grouping patterns (2 options):
#    - [1,1]: 2 Chain: tools, each with 1 Tool
#    - [2]:   1 Chain: tools, with 2 Tools
#
#    Tool order (2! = 2 options):
#    - keyword_extractor → topic_complexity_analyzer
#    - topic_complexity_analyzer → keyword_extractor
#
# 3. AutoGen dynamic mode (LLM insertion + tool order):
#    The evaluator automatically detects the LLM/Tool calling pattern and tool order in AutoGen,
#    and dynamically generates matching reference variants.
#
#    LLM insertion patterns (2^4 = 16 options):
#    - Compact: LLM → Tool1 → Tool2 → Tool3 → Tool4 → Tool5 → LLM
#      (consecutive tool calls with no LLM between tools)
#    - Interleaved: LLM → Tool1 → LLM → Tool2 → ... → Tool5 → LLM
#      (LLM calls interleaved between tools)
#    - Mixed: LLM is inserted between some tools but not others (16 combinations)
#
#    Tool order (5! = 120 options):
#    - The 5 verification tools can be in any order
#    - character_counter_tool, emoji_detector_tool, post_structure_validator,
#      shakespearean_style_detector, tone_analyzer
#
#    Validation rules:
#    - Must start and end with an LLM
#    - Must contain all 5 target tools in the middle (order can vary)
#    - At most one LLM between adjacent tools
#
# 4. Dynamic reference selection strategy (5-way combination):
#    For each sample:
#    a) Detect the actual LangGraph tools grouping pattern
#    b) Enumerate LangGraph tool order (2! = 2)
#    c) Detect the actual AutoGen Post Review LLM/Tool pattern
#    d) Enumerate AutoGen tool order (5! = 120)
#    e) Enumerate CrewAI tool permutations (5! = 120)
#    f) Enumerate all combinations
#       - LangGraph grouping: 2
#       - LangGraph order: 2
#       - AutoGen LLM insertion: 16
#       - AutoGen order: 120
#       - CrewAI permutations: 120
#       - Total variants: 2 × 2 × 16 × 120 × 120 = 921,600
#    g) For each variant compute exact_match, in_order_match, any_order_match
#    h) Select the variant with the highest composite score
#       Composite score = exact_match×3 + in_order_match×2 + any_order_match×1
#
# 5. Metric definitions (consistent with A2A):
#    - Exact Match: predicted trajectory matches the reference exactly
#    - In-order Match: reference is a subsequence of the predicted trajectory
#    - Any-order Match: all required steps are present (order ignored)
#    - Precision: fraction of predicted steps that are correct
#    - Recall: fraction of reference steps covered by prediction
#    - Single-tool Use: average usage rate of target tools
#    - unique_path_ratio: path diversity
#    - path_entropy: path entropy
#
# 6. Run command:
#    cd /Users/wzr/TOSEM-2025/RESULTS/RQ-Failure_Breakdown/SocialMediaManager-H_A2A
#    python3 evaluate_trajectory.py --config reference_trajectory.yaml
#
# 7. Key differences vs the A2A version:
#    - LangGraph-specific Chain node structure
#    - Simplified AGENT name (LangGraph uses "agent")
#    - AutoGen invoke_agent pattern
#    - Dynamic handling of LangGraph batched tools execution
#    - Dynamic handling of AutoGen LLM/Tool insertion patterns (new)
#    - AutoGen tool prefix: execute_tool (not CrewAI tool names)
#    - Filter AutoGen MCP client/operation SPAN nodes
#    - Triple dynamic matching across LangGraph, CrewAI, and AutoGen
#
# 8. Special filtering rules:
#    - Filter all [SPAN] mcp client/operation and its children (AutoGen noise)
#    - Filter [AGENT] create_agent (AutoGen initialization, not business logic)
#    - Keep [AGENT] invoke_agent (actual AutoGen execution)
#
# 9. Tool-order notes:
#    - LangGraph Topic Analysis: 2 tools can be in any order (2! = 2)
#    - CrewAI Shakespearean Bard: keyword_extractor must be first; the 5 validation tools can be permuted (5! = 120)
#    - AutoGen Post Review: the 5 verification tools can be in any order (5! = 120)
#