AINativeBench / data /processed /RQ1 /BookWriter-A2A /reference_trajectory.yaml
王子睿
restructure + add files
8c10cf2
Raw
History Blame Contribute Delete
16.5 kB
# Full reference trajectory configuration - BookWriter-A2A
#
# Version: ideal trajectory derived from the code design (applies to all models)
# Principle: include only steps explicitly required by the code design; do not rely on test statistics
#
# Code-design analysis:
# 1. Three main stages are executed sequentially (orchestrator.py):
# - OutlineGenerator: generate the book outline (2 agents: Researcher + Outliner)
# - WriteBookChapterCrew: concurrently write multiple chapters (2 agents per chapter: Researcher + Writer)
# - ReviewBookCrew: review the complete book (1 agent: Editor)
#
# 2. A2A-specific characteristics:
# - The orchestrator calls three independent A2A servers via HTTP/JSON-RPC
# - Each server runs a Crew and uses MCP tools
# - Extra SPAN layers are added: a2a_call_* and *_server_execution
# - Chapter writing is executed in concurrent batches (batch_size=4)
#
# 3. Tool usage analysis:
# - OutlineGenerator:
# - Researcher: bocha_websearch_tool, extract_keywords
# - Outliner: no tools (pure reasoning)
# - WriteBookChapterCrew (per chapter):
# - Researcher: bocha_websearch_tool, extract_keywords
# - Writer: count_words, analyze_chapter_quality, validate_markdown_structure
# - ReviewBookCrew:
# - Editor: count_book_words, analyze_book_quality, validate_book_markdown, extract_book_keywords
#
# 4. SPAN hierarchy (A2A version):
# - book_writing_orchestrator (top-level, orchestrator.py line 691)
# └─ crew_execution (includes retry logic, orchestrator.py line 724)
# ├─ generate_outline (orchestrator.py line 285)
# │ └─ a2a_call_outline_generator (orchestrator.py line 184)
# │ └─ outline_crew_server_execution (A2A server side)
# ├─ write_chapters (orchestrator.py line 416)
# │ └─ [repeat the following pattern per chapter 3-5 times]
# │ └─ a2a_call_chapter_writer_* (per chapter, orchestrator.py line 184)
# │ └─ chapter_writer_server_execution (A2A server side)
# └─ review_book (orchestrator.py line 472)
# └─ a2a_call_book_reviewer (orchestrator.py line 184)
# └─ book_reviewer_server_execution (A2A server side)
# Project name
project_name: "BookWriter-A2A"
# Trajectory extraction types
extract_types:
- "SPAN" # Multi-layer SPAN structure (including the A2A call layer)
- "Chain" # kickoff chain for each Crew
- "Agent" # agent nodes within each Crew
- "LLM" # LLM calls
- "Tool" # MCP tool calls
# Repeatable pattern configuration (for handling varying chapter counts)
# Format: {"start": start-step index (0-based), "end": end-step index, "min": min repeats, "max": max repeats}
# Reference indices: 0-14 Outline+write_chapters, 15-31 single-chapter pattern (full), 32+ Review
repeatable_patterns:
- start: 15 # SPAN: a2a_call_chapter_writer_* (step 1 of the single-chapter pattern, including SPAN layers)
end: 31 # LLM: * (last step of the single-chapter pattern, after validate_markdown_structure)
min: 3 # At least 3 chapters (business requirement)
max: 5 # At most 5 chapters
name: "chapter_writing_pattern" # Pattern name (for debugging)
# ============================================================================
# Reference Trajectory (Ground Truth) - Based on Code Design
# ============================================================================
#
# Graph view (ideal execution path; the single-chapter pattern repeats 3-5 times):
#
# [SPAN] book_writing_orchestrator
# └─ [SPAN] crew_execution
# ├─ [SPAN] generate_outline
# │ └─ [SPAN] a2a_call_outline_generator
# │ └─ [SPAN] outline_crew_server_execution
# │ └─ [Chain] Crew***.kickoff
# │ ├─ [Agent] Expert Research Agent for Book Outline Planning
# │ │ ├─ [LLM] *
# │ │ ├─ [Tool] bocha_websearch_tool
# │ │ ├─ [LLM] *
# │ │ ├─ [Tool] extract_keywords
# │ │ └─ [LLM] *
# │ └─ [Agent] Strategic Book Structure Architect
# │ └─ [LLM] *
# ├─ [SPAN] write_chapters
# │ └─ [repeat the following pattern per chapter 3-5 times]
# │ └─ [SPAN] a2a_call_chapter_writer_*
# │ └─ [SPAN] chapter_writer_server_execution
# │ └─ [Chain] Crew***.kickoff
# │ ├─ [Agent] Specialized Chapter Research Agent
# │ │ ├─ [LLM] *
# │ │ ├─ [Tool] bocha_websearch_tool
# │ │ ├─ [LLM] *
# │ │ ├─ [Tool] extract_keywords
# │ │ └─ [LLM] *
# │ └─ [Agent] Professional Chapter Content Writer
# │ ├─ [LLM] *
# │ ├─ [Tool] count_words
# │ ├─ [LLM] *
# │ ├─ [Tool] analyze_chapter_quality
# │ ├─ [LLM] *
# │ ├─ [Tool] validate_markdown_structure
# │ └─ [LLM] *
# └─ [SPAN] review_book
# └─ [SPAN] a2a_call_book_reviewer
# └─ [SPAN] book_reviewer_server_execution
# └─ [Chain] Crew***.kickoff
# └─ [Agent] Senior Book Editor and Quality Assurance Specialist
# ├─ [LLM] *
# ├─ [Tool] count_book_words
# ├─ [LLM] *
# ├─ [Tool] analyze_book_quality
# ├─ [LLM] *
# ├─ [Tool] validate_book_markdown
# ├─ [LLM] *
# ├─ [Tool] extract_book_keywords
# └─ [LLM] *
# Design rationale:
# - orchestrator.py: executes three main stages sequentially and calls servers via the A2A protocol
# - OutlineGenerator has 2 agents (Researcher + Outliner)
# - WriteBookChapterCrew has 2 agents per chapter (Researcher + Writer)
# - ReviewBookCrew has 1 agent (Editor)
# - Agent roles are defined in each crew's config/agents.yaml
# - Tools are provided via MCPServerAdapter
# - The number of chapters is generated from the outline (typically 3-5)
# Ideal-trajectory notes:
# - Top-level SPAN: book_writing_orchestrator
# - Second-level SPAN: crew_execution (contains retry logic)
# - Three child SPANs execute in order: generate_outline → write_chapters → review_book
# - Each stage includes an A2A call layer (a2a_call_*) and a server execution layer (*_server_execution)
# - Outline stage: Researcher uses 2 tools; Outliner uses pure reasoning
# - Chapter stage: per chapter, Researcher uses 2 tools; Writer uses 3 tools
# - Review stage: Editor uses 4 tools for whole-book quality checks
# - This reference represents an ideal path (no retries, no redundant steps), using 4 chapters as the baseline
# Notes:
# - "LLM: *" means any LLM model (wildcard)
# - Agent names must match the role field in agents.yaml exactly
# - Tool names must match the tool names exposed by the MCP server
# - The actual chapter count may be 3-5, which affects exact_match but not in_order_match
# - Some tool calls may be skipped or repeated depending on agent decisions
# ============================================================================
reference_trajectory:
# ===== Top-level SPAN =====
- "SPAN: book_writing_orchestrator"
# ===== Second-level SPAN (includes retry logic) =====
- "SPAN: crew_execution"
# ===== Stage 1: Generate Outline =====
- "SPAN: generate_outline"
- "SPAN: a2a_call_outline_generator"
- "SPAN: outline_crew_server_execution"
- "Chain: Crew***.kickoff"
# Agent 1: Researcher
- "Agent: Expert Research Agent for Book Outline Planning"
- "LLM: *" # Decide the research strategy
- "Tool: bocha_websearch_tool" # Web search for topics
- "LLM: *" # Process search results
- "Tool: extract_keywords" # Extract keywords
- "LLM: *" # Summarize research findings
# Agent 2: Outliner
- "Agent: Strategic Book Structure Architect"
- "LLM: *" # Generate the book outline
# ===== Stage 2: Write Chapters (at least 1 chapter; typically 3-5) =====
- "SPAN: write_chapters"
# Standard per-chapter pattern (appears at least once; repeats 3-5 times)
- "SPAN: a2a_call_chapter_writer_*"
- "SPAN: chapter_writer_server_execution"
- "Chain: Crew***.kickoff"
- "Agent: Specialized Chapter Research Agent"
- "LLM: *"
- "Tool: bocha_websearch_tool"
- "LLM: *"
- "Tool: extract_keywords"
- "LLM: *"
- "Agent: Professional Chapter Content Writer"
- "LLM: *"
- "Tool: count_words"
- "LLM: *"
- "Tool: analyze_chapter_quality"
- "LLM: *"
- "Tool: validate_markdown_structure"
- "LLM: *"
# ===== Stage 3: Review Book =====
- "SPAN: review_book"
- "SPAN: a2a_call_book_reviewer"
- "SPAN: book_reviewer_server_execution"
- "Chain: Crew***.kickoff"
- "Agent: Senior Book Editor and Quality Assurance Specialist"
- "LLM: *" # Start reviewing
- "Tool: count_book_words" # Count words
- "LLM: *" # Analyze word count
- "Tool: analyze_book_quality" # Quality analysis
- "LLM: *" # Assess quality
- "Tool: validate_book_markdown" # Format validation
- "LLM: *" # Check formatting
- "Tool: extract_book_keywords" # Extract keywords
- "LLM: *" # Generate review report
# Target tool list (for the single-tool use metric)
# This list includes all required tools
target_tools:
# Outline generation stage
- "Tool: bocha_websearch_tool"
- "Tool: extract_keywords"
# Chapter Writing stage (used per chapter)
- "Tool: count_words"
- "Tool: analyze_chapter_quality"
- "Tool: validate_markdown_structure"
# Book Review stage
- "Tool: count_book_words"
- "Tool: analyze_book_quality"
- "Tool: validate_book_markdown"
- "Tool: extract_book_keywords"
# ============================================================================
# Dynamic tool arrangement configuration
# ============================================================================
# Define permutable tool groups for certain agents to generate different reference trajectories
# The evaluation will try all possible permutations and choose the one with the highest match score
#
# Rationale:
# - Chapter Writer's 3 validation tools (count_words, analyze_chapter_quality, validate_markdown_structure)
# depend only on the chapter draft and have no inter-dependencies, so they can run in any order.
# - Book Editor's 4 analysis tools (count_book_words, analyze_book_quality, validate_book_markdown, extract_book_keywords)
# depend only on book files and are independent, so they can run in any order.
#
# Number of permutations:
# - Chapter Writer: 3! = 6 permutations
# - Book Editor: 4! = 24 permutations
#
# Evaluation strategy:
# - For each sample, generate all permuted reference trajectories
# - Compute a match score (exact_match * 3 + in_order_match * 2 + any_order_match * 1)
# - Choose the highest-scoring permutation as the sample's reference trajectory
# - This fairly evaluates models that use different tool invocation orders
permutable_tool_groups:
# Chapter Writer validation tools can be in any order
# These 3 tools are used under "Agent: Professional Chapter Content Writer"
chapter_writer_validation_tools:
- "Tool: count_words"
- "Tool: analyze_chapter_quality"
- "Tool: validate_markdown_structure"
# Book Editor analysis tools can be in any order
# These 4 tools are used under "Agent: Senior Book Editor and Quality Assurance Specialist"
book_editor_analysis_tools:
- "Tool: count_book_words"
- "Tool: analyze_book_quality"
- "Tool: validate_book_markdown"
- "Tool: extract_book_keywords"
# 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
# ============================================================================
#
# 1. Trajectory hierarchy (A2A version):
# - Level 1: SPAN (book_writing_orchestrator)
# - Level 2: SPAN (crew_execution)
# - Level 3: SPAN (generate_outline, write_chapters, review_book)
# - Level 4: SPAN (a2a_call_*: A2A call layer for each stage)
# - Level 5: SPAN (*_server_execution: server-side execution layer)
# - Level 6: Chain (Crew***.kickoff; UUID is wildcarded)
# - Level 7: AGENT (agent role must match exactly)
# - Level 8: LLM (wildcard match any model)
# - Level 8: Tool (tool name must match exactly)
#
# 2. Differences between the A2A version and the MCP version:
# - The A2A version adds two extra SPAN layers: a2a_call_* and *_server_execution
# - These SPANs represent the HTTP communication between the orchestrator and A2A servers
# - Tool invocation is the same, but wrapped inside the server execution layer
# - In execution_path.md, SPAN names may include chapter titles (e.g., a2a_call_chapter_writer_(chapter_title))
#
# 3. Wildcard handling:
# - Crew_<UUID>.kickoff -> Crew***.kickoff (handled automatically by evaluate_trajectory.py)
# - a2a_call_chapter_writer_* -> matches any chapter title
# - LLM: * -> matches any model name (e.g., gpt-5-chat-latest, deepseek-reasoner)
# - Agent names must match fully (including prefixes/suffixes)
#
# 4. Exact match requirements:
# - Orchestrator-layer SPANs: "book_writing_orchestrator", "crew_execution", "generate_outline", "write_chapters", "review_book"
# - A2A call-layer SPANs: "a2a_call_outline_generator", "a2a_call_chapter_writer_*", "a2a_call_book_reviewer" (chapter writer uses wildcard)
# - Server-layer SPANs: "outline_crew_server_execution", "chapter_writer_server_execution", "book_reviewer_server_execution"
# - Chain: "Crew***.kickoff" (wildcard)
# - Agents: names must match the role fields in agents.yaml exactly (including full names and formatting)
# - LLM: "LLM: *" (wildcard match any model)
# - Tools: must match MCP server tool names exactly
# - Actual chapter count may be 3-5; this affects exact_match but not in_order_match
# - Some tool calls may be skipped or repeated depending on agent decisions
#
# 5. Metric meanings:
# - Exact Match: trajectories must be identical (including LLM call counts; single-chapter pattern is repeatable)
# - In-order Match: extra calls are allowed, but core steps must appear in order
# - Any-order Match: all required steps must be present (order ignored)
# - Precision: fraction of predicted steps that are correct
# - Recall: fraction of reference steps that are covered
# - Single-tool Use: checks whether all required tools are used
# - unique_path_ratio: path diversity (unique complete trajectories / sample count)
# - path_entropy: Shannon entropy of trajectory frequencies, normalized to 0-1
#
# 6. Example command:
# python3 evaluate_trajectory.py --config reference_trajectory.yaml
#
# 7. Design notes:
# - This reference represents an ideal execution path (single-chapter pattern matches 3-5 chapters)
# - Three main stages execute in order: Outline → Chapters → Review
# - In-order Match and Recall are often more informative for real-world behavior
#
# 8. Differences from real trajectories:
# - The reference defines a single-chapter pattern; real runs repeat it 3-5 times (depending on outline chapter count)
# - Real trajectories may contain extra LLM calls (planning, reasoning, summarization)
# - Some models may call tools multiple times (retries or extra checks)
# - Some models may skip certain tool calls and still produce results
# - These differences reflect strategy choices and do not necessarily indicate errors
#
# 9. A2A-specific notes:
# - The orchestrator calls three independent A2A servers via HTTP/JSON-RPC
# - Each A2A server runs a Crew and uses MCP tools internally
# - Extra SPAN layers are added to trace A2A communication and server-side execution
# - Tool categories: search (bocha_websearch_tool), analysis (extract_keywords),
# quality checks (count_words, analyze_*_quality), and format validation (validate_*)
# - Chapter writing is executed in concurrent batches; each chapter has an independent trajectory
# - Compared to the MCP version, the A2A version has deeper span nesting but the same core logic