# 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