# Complete Reference Trajectory Configuration - MarkdownValidator-MCP Project # # Version: Ideal trajectory based on code design (applicable to all models) # Principle: Only includes steps explicitly required by code design, not based on test statistics # # Code Design Analysis: # 1. Single Agent executing single Task: # - Requirements Manager: Uses markdown_validation_tool (MCP tool) to analyze Markdown file and generate JSON report # # 2. Tool Usage Analysis: # - markdown_validation_tool provided through MCP server # - Tool connects to MCP server via MCPServerAdapter # - tasks.yaml requires calling this tool to validate file # - Tool invocation is necessary step to complete task # # 3. Execution Flow: # - Process.sequential: Sequential execution (though only one Task) # - Agent executes Task, uses LLM to decide tool invocation, then uses LLM to generate final JSON # # 4. MCP Version Characteristics: # - Tools obtained from MCP server via MCPServerAdapter # - main.py has two nested langfuse spans (code duplication), resulting in two SPAN: markdown_validation layers # - This is the actual execution structure, needs to be reflected in reference trajectory # Project name project_name: "MarkdownValidator-MCP" # Trajectory extraction type configuration # Per user requirements, focus on: SPAN, Chain, AGENT, LLM, Tool # Ignore: Task Created, Crew Created and other non-core content extract_types: - "SPAN" # Level 1 and 2: Two nested markdown_validation SPANs - "Chain" # Level 3: Crew execution chain - "AGENT" # Level 4: Agent execution - "LLM" # Level 5: LLM invocation - "Tool" # Level 5: Tool invocation # ============================================================================ # Reference Trajectory (Ground Truth) - Based on Code Design # ============================================================================ # # Graphical Structure (Ideal Execution Path): # # [SPAN] markdown_validation # └─ [Chain] Crew***.kickoff # └─ [AGENT] Requirements Manager ← Task: syntax_review_task # ├─ [LLM] * ← Decide to use tool for validation # ├─ [Tool] markdown_validation_tool ← Call MCP tool to validate file # └─ [LLM] * ← Process validation results and generate JSON output # # Design Rationale: # - crew.py: Defines 1 Agent (Requirements_Manager) and 1 Task (syntax_review_task) # - crew.py: Agent uses self.mcp_adapter.tools to get MCP tools # - tasks.yaml: Explicitly requires using markdown_validation_tool and outputting JSON format report # - main.py line 280-281: Two nested `start_as_current_span(name="markdown_validation")` # - agents.yaml: Agent role is "Requirements Manager" # - MCP tools obtained from server via MCPServerAdapter # # Ideal Trajectory Explanation: # - Single markdown_validation SPAN (nested second layer filtered by evaluation script) # - Requirements Manager: 2 LLM calls + 1 tool call # 1. First LLM: Analyze task, decide to use MCP tool # 2. Tool call: markdown_validation_tool validates file (via MCP) # 3. Second LLM: Process tool results, generate JSON format report # - This trajectory represents ideal, no-retry, no-redundancy execution path # - Note: Actual execution may have nested SPANs, evaluation script auto-filters for consistency # # Notes: # - "LLM: *" means any LLM model (wildcard match) # - Agent name is "Requirements Manager" (role field, with space) # - Tool name is "markdown_validation_tool" (MCP tool function name) # - Actual execution may include more LLM calls (thinking, planning, etc.), which is normal # ============================================================================ reference_trajectory: # ===== Level 1: SPAN ===== - "SPAN: markdown_validation" # ===== Level 2: Chain (wildcard handles UUID) ===== - "Chain: Crew***.kickoff" # ===== Task: syntax_review_task ===== # Requirements Manager validates Markdown file and generates report - "Agent: Requirements Manager" - "LLM: *" # First call: decide to use MCP tool - "Tool: markdown_validation_tool" # Call MCP validation tool - "LLM: *" # Second call: generate JSON report # Target tools list (for single-tool use metric) # Only includes actual tool calls, used to detect tool usage target_tools: - "Tool: markdown_validation_tool" # 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 Instructions # ============================================================================ # # 1. Trajectory Hierarchy: # - Level 1: SPAN (markdown_validation) # - Level 2: Chain (Crew***.kickoff, wildcard handles UUID) # - Level 3: AGENT (Requirements Manager, exact match) # - Level 4: LLM (wildcard matches any model) # - Level 4: Tool (markdown_validation_tool, exact match) # # 2. Wildcard Handling: # - Crew_.kickoff -> Crew***.kickoff (evaluate_trajectory.py auto-handles) # - LLM: * -> Matches any model name (e.g. gpt-4o-mini, deepseek-r1, etc.) # # 3. Exact Match Requirements: # - SPAN name: "markdown_validation" (exact match) # Note: Evaluation script auto-filters nested second-level markdown_validation SPAN # - Chain name: "Crew***.kickoff" (wildcard match) # - AGENT name: "Requirements Manager" (exact match to role in agent.yaml) # - LLM name: "LLM: *" (wildcard matches any model) # - Tool name: "markdown_validation_tool" (exact match to MCP tool function name) # # 4. Evaluation Metrics Meaning: # - Exact Match: Requires trajectory to be exactly the same (including LLM call count) # - In-order Match: Allows extra calls, but core steps must appear in order # - Any-order Match: Just needs to contain all necessary steps (ignores order) # - Precision: Proportion of correct steps in predicted trajectory # - Recall: Proportion of reference trajectory covered # - Single-tool Use: Detects markdown_validation_tool usage # - unique_path_ratio: Path diversity (unique complete trajectories / samples) # - path_entropy: Path entropy (Shannon entropy based on trajectory frequency, normalized 0-1) # # 5. Run Command: # cd /Users/wzr/TOSEM-2025/RESULTS/RQ-Failure_Breakdown/MarkdownValidator-MCP # python3 evaluate_trajectory.py --config reference_trajectory.yaml # # 6. Design Notes: # - This reference trajectory represents ideal execution path # - Single markdown_validation SPAN (nested ones auto-filtered) # - Requirements Manager: 2 LLM + 1 tool # * First LLM: Analyze task and decide to use tool # * Tool call: Validate Markdown file via MCP # * Second LLM: Process results and generate JSON output # - Total: 1 SPAN + 1 Chain + 1 Agent + 2 LLM + 1 tool # - In-order Match and Any-order Match metrics better for evaluating actual performance # # 7. Differences from Actual Trajectories: # - Actual trajectories may include more LLM calls (thinking, planning, execution, summary, etc.) # - Some models may call validation tool multiple times (retry or extra checks) # - These differences don't represent errors, but different model execution strategies # - Exact Match score may be low, focus on In-order Match and Recall # # 8. MCP Version Characteristics: # - Tools provided through MCP server, using SSE protocol communication # - Tools obtained from server via MCPServerAdapter # - Actual execution may have nested markdown_validation SPANs (main.py lines 280-281) # - Evaluation script auto-filters nested SPANs to ensure evaluation consistency # - Tool name is function name (markdown_validation_tool) # - Main difference from non-MCP version: tool provision method (reference trajectory structure same)