File size: 15,419 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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# Full reference trajectory configuration - RecruitmentAssistant-H_A2A
#
# Version: ported from RecruitmentAssistant-A2A and adapted to the A2A_mix hybrid architecture
# Principle: keep business logic unchanged while adapting to the hybrid framework hierarchy
# (LangGraph + AutoGen + CrewAI).
#
# A2A_mix hybrid architecture notes:
# - Stage 1 (Job Analysis): LangGraph
#   * Use [Chain] LangGraph rather than CrewAI's Crew***.kickoff
#   * The AGENT name is simplified to "agent" rather than the full role name
#   * Tool calls appear under the [Chain] tools node and may run in batched mode
#   * LangGraph-specific Chain nodes: _should_continue and format_output
#
# - Stage 2 (Candidate Evaluation): CrewAI
#   * Keep the standard [Chain] Crew***.kickoff structure
#   * Use the full agent role name: "Senior Candidate Evaluator._execute_core"
#   * Tool calls are directly under AGENT (no intermediate Chain)
#
# - Stage 3 (Interview Communication): AutoGen
#   * AGENT pattern: create_agent + invoke_agent
#   * Ignore create_agent (excluded from evaluation)
#   * Focus on invoke_agent execution
#   * Tool call prefix: "execute_tool"
#
# Dynamic reference-trajectory design:
# 1. Choose 3x/4x variants based on the number of unified_web_search calls (consistent with A2A)
# 2. Dynamic matching for LangGraph tools batching:
#    - 3 searches: 1+1+1, 1+2, 2+1, or 3
#    - 4 searches: 1+1+1+1, 2+1+1, 1+2+1, 1+1+2, 3+1, 1+3, or 4
# 3. Dynamic matching for AutoGen Interview LLM/Tool patterns:
#    Rule: must start and end with LLM; between adjacent tools, there can be 0 or 1 LLM
#    - With 2 tools, possible patterns:
#      * LLM → Tool1 → Tool2 → LLM (0 LLM between tools)
#      * LLM → Tool1 → LLM → Tool2 → LLM (1 LLM between tools)
#    - Enumeration: for each adjacent tool pair, independently choose inserting 0 or 1 LLM
#      * 2 tools have 1 gap → 2^1 = 2 patterns
#      * 3 tools have 2 gaps → 2^2 = 4 patterns
# 4. Tool-order permutation optimization for Candidate Evaluation / Interview Communication:
#    - candidate_profile_analyzer ↔ candidate_evaluator_pro (2! = 2)
#    - comprehensive_interview_material_generator ↔ email_template_generator (2! = 2)
#    - Total permutations: 2 × 2 = 4
# During evaluation, all combinations (LangGraph × AutoGen LLM × tool permutations) are enumerated,
# and the variant with the highest score among exact_match / in_order_match / any_order_match is used.

# Project name
project_name: "RecruitmentAssistant-H_A2A"

# Extract types configuration
extract_types:
  - "SPAN" # multi-level SPAN structure
  - "Chain" # Chain nodes for LangGraph / CrewAI
  - "AGENT" # Agent nodes across frameworks (AutoGen extracts invoke_agent only)
  - "LLM" # LLM calls
  - "Tool" # Tool calls

# ============================================================================
# Reference Trajectory (Ground Truth) - A2A_mix Hybrid Architecture
# ============================================================================
#
# Graphical structure (ideal execution path, 3x version example):
# Graphical structure (ideal execution path, 3x version example):
#
# [SPAN] recruitment_orchestrator
# └─ [SPAN] crew_execution
#    ├─ [SPAN] analyze_job (LangGraph)
#    │  └─ [SPAN] a2a_call_job_analysis
#    │     └─ [SPAN] job_analysis_server_execution
#    │        └─ [Chain] LangGraph
#    │           ├─ [AGENT] agent
#    │           │  ├─ [LLM] *
#    │           │  └─ [Chain] _should_continue
#    │           ├─ [Chain] tools (batched execution with 3 searches; possible groupings: 1+1+1, 1+2, 2+1, 3)
#    │           │  ├─ [Tool] unified_web_search (1st)
#    │           │  ├─ [Tool] unified_web_search (2nd)
#    │           │  └─ [Tool] unified_web_search (3rd)
#    │           ├─ [AGENT] agent
#    │           │  ├─ [LLM] *
#    │           │  └─ [Chain] _should_continue
#    │           └─ [Chain] format_output
#    ├─ [SPAN] evaluate_candidates (CrewAI)
#    │  └─ [SPAN] a2a_call_candidate_evaluation
#    │     └─ [SPAN] candidate_evaluation_server_execution
#    │        └─ [Chain] Crew***.kickoff
#    │           └─ [AGENT] Senior Candidate Evaluator
#    │              ├─ [LLM] *
#    │              ├─ [Tool] candidate_profile_analyzer
#    │              ├─ [LLM] *
#    │              ├─ [Tool] candidate_evaluator_pro
#    │              └─ [LLM] *
#    └─ [SPAN] prepare_interviews (AutoGen)
#       └─ [SPAN] a2a_call_interview_communication
#          └─ [SPAN] interview_communication_server_execution
#             └─ [AGENT] invoke_agent interview_coordinator
#                ├─ [LLM] *
#                ├─ [Tool] execute_tool comprehensive_interview_material_generator
#                ├─ [Tool] execute_tool email_template_generator
#                └─ [LLM] *
#
# Notes:
# - Under LangGraph's [Chain] tools node, there may be multiple batched calls.
#   For example, 4 searches may be split into two batches: 2 + 2.
#   The evaluation script dynamically generates all possible grouping variants.
# - AutoGen's create_agent nodes are excluded from the reference trajectory.
# ============================================================================

# Default reference trajectory (compatibility; kept as the 3x version)
reference_trajectory:
  # ===== Top-level SPAN =====
  - "SPAN: recruitment_orchestrator"

  # ===== Second-level SPAN (includes 3 stages) =====
  - "SPAN: crew_execution"

  # ===== Stage 1: Job Analysis (LangGraph, 3 searches) =====
  - "SPAN: analyze_job"
  - "SPAN: a2a_call_job_analysis"
  - "SPAN: job_analysis_server_execution"
  - "Chain: LangGraph"
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  - "Chain: tools"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  - "Chain: format_output"

  # ===== Stage 2: Candidate Evaluation (CrewAI) =====
  - "SPAN: evaluate_candidates"
  - "SPAN: a2a_call_candidate_evaluation"
  - "SPAN: candidate_evaluation_server_execution"
  - "Chain: Crew***.kickoff"
  - "AGENT: Senior Candidate Evaluator"
  - "LLM: *"
  - "Tool: candidate_profile_analyzer"
  - "LLM: *"
  - "Tool: candidate_evaluator_pro"
  - "LLM: *"

  # ===== Stage 3: Interview Communication (AutoGen) =====
  - "SPAN: prepare_interviews"
  - "SPAN: a2a_call_interview_communication"
  - "SPAN: interview_communication_server_execution"
  - "AGENT: invoke_agent interview_coordinator"
  - "LLM: *"
  - "Tool: execute_tool comprehensive_interview_material_generator"
  - "Tool: execute_tool email_template_generator"
  - "LLM: *"

# ============================================================================
# Dynamic reference trajectory - Version 1: 3 unified_web_search calls
# ============================================================================
# This version serves as the base template for LangGraph tools batching.
# During evaluation, variants are generated dynamically based on the sample's tools grouping pattern.
reference_trajectory_3x:
  # ===== Top-level SPAN =====
  - "SPAN: recruitment_orchestrator"

  # ===== Second-level SPAN (includes 3 stages) =====
  - "SPAN: crew_execution"

  # ===== Stage 1: Job Analysis (LangGraph, 3-search base template) =====
  - "SPAN: analyze_job"
  - "SPAN: a2a_call_job_analysis"
  - "SPAN: job_analysis_server_execution"
  - "Chain: LangGraph"
  # First pass: agent decision
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  # Tool groups (3 calls; may be split into 1-3 Chain: tools blocks)
  - "Chain: tools"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  # Second pass: agent summary
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  - "Chain: format_output"

  # ===== Stage 2: Candidate Evaluation (CrewAI) =====
  - "SPAN: evaluate_candidates"
  - "SPAN: a2a_call_candidate_evaluation"
  - "SPAN: candidate_evaluation_server_execution"
  - "Chain: Crew***.kickoff"
  - "AGENT: Senior Candidate Evaluator"
  - "LLM: *"
  - "Tool: candidate_profile_analyzer"
  - "LLM: *"
  - "Tool: candidate_evaluator_pro"
  - "LLM: *"

  # ===== Stage 3: Interview Communication (AutoGen) =====
  - "SPAN: prepare_interviews"
  - "SPAN: a2a_call_interview_communication"
  - "SPAN: interview_communication_server_execution"
  - "AGENT: invoke_agent interview_coordinator"
  - "LLM: *"
  - "Tool: execute_tool comprehensive_interview_material_generator"
  - "Tool: execute_tool email_template_generator"
  - "LLM: *"

# ============================================================================
# Dynamic reference trajectory - Version 2: 4 unified_web_search calls
# ============================================================================
reference_trajectory_4x:
  # ===== Top-level SPAN =====
  - "SPAN: recruitment_orchestrator"

  # ===== Second-level SPAN (includes 3 stages) =====
  - "SPAN: crew_execution"

  # ===== Stage 1: Job Analysis (LangGraph, 4-search base template) =====
  - "SPAN: analyze_job"
  - "SPAN: a2a_call_job_analysis"
  - "SPAN: job_analysis_server_execution"
  - "Chain: LangGraph"
  # First pass: agent decision
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  # Tool groups (4 calls; may be split into 1-4 Chain: tools blocks)
  - "Chain: tools"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  - "Tool: unified_web_search"
  # Second pass: agent summary
  - "AGENT: agent"
  - "LLM: *"
  - "Chain: _should_continue"
  - "Chain: format_output"

  # ===== Stage 2: Candidate Evaluation (CrewAI) =====
  - "SPAN: evaluate_candidates"
  - "SPAN: a2a_call_candidate_evaluation"
  - "SPAN: candidate_evaluation_server_execution"
  - "Chain: Crew***.kickoff"
  - "AGENT: Senior Candidate Evaluator"
  - "LLM: *"
  - "Tool: candidate_profile_analyzer"
  - "LLM: *"
  - "Tool: candidate_evaluator_pro"
  - "LLM: *"

  # ===== Stage 3: Interview Communication (AutoGen) =====
  - "SPAN: prepare_interviews"
  - "SPAN: a2a_call_interview_communication"
  - "SPAN: interview_communication_server_execution"
  - "AGENT: invoke_agent interview_coordinator"
  - "LLM: *"
  - "Tool: execute_tool comprehensive_interview_material_generator"
  - "Tool: execute_tool email_template_generator"
  - "LLM: *"

# Target tool list (for the single-tool use metric)
target_tools:
  - "Tool: unified_web_search"
  - "Tool: candidate_profile_analyzer"
  - "Tool: candidate_evaluator_pro"
  - "Tool: execute_tool comprehensive_interview_material_generator"
  - "Tool: execute_tool email_template_generator"

# Model list 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 groups (for dynamic tool-order optimization)
permutable_tool_groups:
  # Candidate Evaluation stage tools can be in any order
  candidate_evaluation_tools:
    - "Tool: candidate_profile_analyzer"
    - "Tool: candidate_evaluator_pro"

  # Interview Communication stage tools can be in any order
  interview_communication_tools:
    - "Tool: execute_tool comprehensive_interview_material_generator"
    - "Tool: execute_tool email_template_generator"
# ============================================================================
# Usage notes - A2A_mix hybrid architecture version
# ============================================================================
#
# 1. Hybrid framework notes:
#    - Stage 1 (Job Analysis): LangGraph
#      * Chain name: LangGraph (not Crew***.kickoff)
#      * Simplified agent name: agent (not the full role name)
#      * Batched tool execution: [Chain] tools may contain multiple Tool nodes
#      * Special chain nodes: _should_continue and format_output
#
#    - Stage 2 (Candidate Evaluation): CrewAI
#      * Standard CrewAI structure: Crew***.kickoff → AGENT → LLM/Tool
#      * Full agent name: Senior Candidate Evaluator
#
#    - Stage 3 (Interview Communication): AutoGen
#      * Ignore create_agent (excluded from evaluation)
#      * Focus on invoke_agent interview_coordinator
#      * Tool prefix: execute_tool

# 2. LangGraph tools batching dynamic mode:
#    The evaluation script detects the tools grouping pattern in the sample and
#    dynamically generates corresponding reference variants for matching.
#
#    Possible groupings for 3 searches:
#    - [1,1,1]: 3 Chain: tools blocks, each with 1 Tool
#    - [1,2]:   2 blocks: first has 1 Tool, second has 2 Tools
#    - [2,1]:   2 blocks: first has 2 Tools, second has 1 Tool
#    - [3]:     1 block with 3 Tools
#
#    Possible groupings for 4 searches:
#    - [1,1,1,1]: 4 blocks, each with 1 Tool
#    - [2,1,1]:   3 blocks with 2,1,1 Tools
#    - [1,2,1]:   3 blocks with 1,2,1 Tools
#    - [1,1,2]:   3 blocks with 1,1,2 Tools
#    - [3,1]:     2 blocks with 3,1 Tools
#    - [1,3]:     2 blocks with 1,3 Tools
#    - [4]:       1 block with 4 Tools

# 3. AutoGen Interview LLM/Tool dynamic mode:
#    The evaluation script detects the LLM/Tool call pattern in the AutoGen part and
#    dynamically generates corresponding reference variants for matching.
#
#    Supported patterns:
#    - Compact: LLM → Tool1 → Tool2 → LLM (no LLM between tools)
#    - Interleaved: LLM → Tool1 → LLM → Tool2 → LLM (insert one LLM between tools)
#
#    Validation rules:
#    - Must start and end with LLM
#    - Must include the 2 target tools in the middle (fixed order)
#    - At most one LLM between tools

# 4. Dynamic reference selection strategy (enhanced):
#    For each sample:
#    a) Choose the 3x/4x base template by unified_web_search total count
#    b) Detect the LangGraph tools actual grouping pattern
#    c) Detect the AutoGen Interview actual LLM/Tool pattern
#    d) Enumerate all combinations (LangGraph pattern × AutoGen pattern)
#       - Example: 3 searches have 4 LangGraph patterns and 2 AutoGen patterns
#       - Total: 4 × 2 = 8 reference variants
#    e) Compute exact_match, in_order_match, and any_order_match for each variant
#    f) Select the variant with the best score as the final reference for the sample

# 5. Metric definitions (consistent with A2A):
#    - Exact Match: prediction equals reference
#    - In-order Match: reference is a subsequence of prediction
#    - Any-order Match: contains all required steps (order ignored)
#    - Precision: fraction of correct steps in prediction
#    - Recall: fraction of reference steps covered
#    - Single-tool Use: average usage rate of target tools
#    - unique_path_ratio: path diversity
#    - path_entropy: path entropy

# 6. Command:
#    cd /Users/wzr/TOSEM-2025/RESULTS/RQ-Failure_Breakdown/RecruitmentAssistant-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 tools batching
#    - Dynamic handling of AutoGen LLM/Tool patterns (new)
#    - AutoGen tool prefix: execute_tool (instead of CrewAI's ._use)
#    - Dual dynamic matching: supports LangGraph and AutoGen pattern combinations