Code
app.agents.agent_factories
¶
Agent factory functions for creating PydanticAI agents.
This module provides factory functions for creating different types of agents with appropriate models, tools, and configurations. It separates agent creation logic from model creation and orchestration.
Classes¶
AgentFactory
¶
Factory class for creating different types of agents.
Source code in src/app/agents/agent_factories.py
Functions¶
__init__(endpoint_config=None)
¶
Initialize agent factory with model configuration.
create_analyst_agent(system_prompt=None)
¶
Create an analyst agent for data analysis.
Source code in src/app/agents/agent_factories.py
create_manager_agent(system_prompt=None)
¶
Create a manager agent with delegation capabilities.
Source code in src/app/agents/agent_factories.py
create_researcher_agent(system_prompt=None)
¶
Create a researcher agent for information gathering.
Source code in src/app/agents/agent_factories.py
create_synthesiser_agent(system_prompt=None)
¶
Create a synthesiser agent for combining results.
Source code in src/app/agents/agent_factories.py
get_models(include_researcher=False, include_analyst=False, include_synthesiser=False)
¶
Get or create models for agents.
Source code in src/app/agents/agent_factories.py
Functions¶
create_evaluation_agent(provider, model_name, assessment_type, api_key=None, system_prompt=None, prompts=None)
¶
Create an agent specifically for evaluation tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
LLM provider (e.g., “openai”, “github”) |
required |
model_name
|
str
|
Model name (e.g., “gpt-4o-mini”) |
required |
assessment_type
|
str
|
Type of assessment (e.g., “technical_accuracy”) |
required |
api_key
|
str | None
|
API key (optional) |
None
|
system_prompt
|
str | None
|
Custom system prompt (optional) |
None
|
prompts
|
dict[str, str] | None
|
Prompt configuration dictionary (optional) |
None
|
Returns:
| Type | Description |
|---|---|
Agent
|
Agent configured for evaluation tasks |
Source code in src/app/agents/agent_factories.py
create_simple_agent(model, system_prompt)
¶
Create a simple agent with provided model and prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
PydanticAI model instance |
required |
system_prompt
|
str
|
System prompt for the agent |
required |
Returns:
| Type | Description |
|---|---|
Agent
|
Configured Agent instance |
Source code in src/app/agents/agent_factories.py
app.agents.agent_system
¶
Agent system utilities for orchestrating multi-agent workflows.
This module provides functions and helpers to create, configure, and run agent systems using Pydantic AI. It supports delegation of tasks to research, analysis, and synthesis agents, and manages agent configuration, environment setup, and execution. Args: provider (str): The name of the provider. provider_config (ProviderConfig): Configuration settings for the provider. api_key (str): API key for authentication with the provider. prompts (dict[str, str]): Configuration for prompts. include_researcher (bool): Flag to include the researcher agent. include_analyst (bool): Flag to include the analyst agent. include_synthesiser (bool): Flag to include the synthesiser agent. query (str | list[dict[str, str]]): The query or messages for the agent. chat_config (ChatConfig): The configuration object for agents and providers. usage_limits (UsageLimits): Usage limits for agent execution.
Functions:
| Name | Description |
|---|---|
get_manager |
Initializes and returns a manager agent with the specified configuration. |
run_manager |
Asynchronously runs the manager agent with the given query and provider. |
setup_agent_env |
Sets up the environment for an agent by configuring provider settings, prompts, API key, and usage limits. |
Classes¶
Functions¶
get_manager(provider, provider_config, api_key, prompts, include_researcher=False, include_analyst=False, include_synthesiser=False, enable_review_tools=False)
¶
Initializes and returns a Agent manager with the specified configuration. Args: provider (str): The name of the provider. provider_config (ProviderConfig): Configuration settings for the provider. api_key (str): API key for authentication with the provider. prompts (PromptsConfig): Configuration for prompts. include_researcher (bool, optional): Flag to include analyst model. Defaults to False. include_analyst (bool, optional): Flag to include analyst model. Defaults to False. include_synthesiser (bool, optional): Flag to include synthesiser model. Defaults to False. Returns: Agent: The initialized Agent manager.
Source code in src/app/agents/agent_system.py
initialize_logfire_instrumentation_from_settings(settings=None)
¶
Initialize Logfire instrumentation from JudgeSettings.
Uses logfire.instrument_pydantic_ai() for automatic tracing. No manual decorators needed - all PydanticAI agents auto-instrumented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings | None
|
JudgeSettings instance. If None, uses default JudgeSettings(). |
None
|
Source code in src/app/agents/agent_system.py
resilient_tool_wrapper(tool)
¶
Wrap a PydanticAI Tool so HTTP and network errors return error strings.
Search tools are supplementary — when they fail, the agent should receive a descriptive error message and continue generating output from paper content and model knowledge. This prevents a search outage from crashing the run.
Catches
- httpx.HTTPStatusError (403 Forbidden, 429 Too Many Requests, etc.)
- httpx.HTTPError (broader httpx network errors)
- Exception (any other network or library failure)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
Tool[Any]
|
The original PydanticAI Tool to wrap. |
required |
Returns:
| Type | Description |
|---|---|
Tool[Any]
|
A new Tool with the same name and description, but with a resilient |
Tool[Any]
|
function that catches search errors and returns a descriptive string. |
Source code in src/app/agents/agent_system.py
run_manager(manager, query, provider, usage_limits, execution_id=None)
async
¶
Asynchronously run the manager with the given query and provider.
Auto-instrumented by logfire.instrument_pydantic_ai() - no manual decorators needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manager
|
Agent[None, BaseModel]
|
The system agent responsible for running the query. |
required |
query
|
UserPromptType
|
The query to be processed by the manager. |
required |
provider
|
str
|
The provider to be used for the query. |
required |
usage_limits
|
UsageLimits | None
|
The usage limits to be applied during the query execution. |
required |
execution_id
|
str | None
|
Optional pre-generated execution ID. When provided, used
as-is; otherwise a new |
None
|
Returns:
| Type | Description |
|---|---|
tuple[str, Any]
|
Tuple of (execution_id, manager_output) for trace retrieval and evaluation. |
Source code in src/app/agents/agent_system.py
setup_agent_env(provider, query, chat_config, chat_env_config, token_limit=None)
¶
Sets up the environment for an agent by configuring provider settings, prompts, API key, and usage limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
The name of the provider. |
required |
query
|
UserPromptType
|
The messages or queries to be sent to the agent. |
required |
chat_config
|
ChatConfig | BaseModel
|
The configuration object containing provider and prompt settings. |
required |
chat_env_config
|
AppEnv
|
The application environment configuration containing API keys. |
required |
token_limit
|
int | None
|
Optional token limit override (CLI/GUI param). Priority: CLI/GUI > env var > config. Valid range: 1000-1000000. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
EndpointConfig |
EndpointConfig
|
The configuration object for the agent. |
Source code in src/app/agents/agent_system.py
app.agents.logfire_instrumentation
¶
Logfire tracing instrumentation for PydanticAI agents.
Uses Logfire’s native PydanticAI auto-instrumentation via logfire.instrument_pydantic_ai(). No manual decorators or wrappers needed.
Classes¶
LogfireInstrumentationManager
¶
Manages Logfire tracing instrumentation for PydanticAI agents.
Uses logfire.instrument_pydantic_ai() for automatic instrumentation of all PydanticAI agent execution. No manual decorators required.
Source code in src/app/agents/logfire_instrumentation.py
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 | |
Functions¶
get_instrumentation_manager()
¶
Get current instrumentation manager.
Returns:
| Type | Description |
|---|---|
LogfireInstrumentationManager | None
|
Current LogfireInstrumentationManager instance or None if not initialized. |
Source code in src/app/agents/logfire_instrumentation.py
initialize_logfire_instrumentation(config)
¶
Initialize Logfire instrumentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LogfireConfig
|
LogfireConfig instance with tracing settings. |
required |
Source code in src/app/agents/logfire_instrumentation.py
app.app
¶
Main entry point for the Agents-eval application.
This module initializes the agentic system, loads configuration files, handles user input, and orchestrates the multi-agent workflow using asynchronous execution. It integrates logging, tracing, and authentication, and supports both CLI and programmatic execution.
Evaluation orchestration is delegated to app.judge.evaluation_runner.
Classes¶
Functions¶
main(chat_provider=CHAT_DEFAULT_PROVIDER, query='', include_researcher=False, include_analyst=False, include_synthesiser=False, chat_config_file=None, enable_review_tools=False, paper_id=None, skip_eval=False, download_peerread_full_only=False, download_peerread_samples_only=False, peerread_max_papers_per_sample_download=5, cc_solo_dir=None, cc_teams_dir=None, cc_teams_tasks_dir=None, token_limit=None, judge_settings=None, engine='mas', cc_result=None, cc_teams=False, cc_model=None)
async
¶
Main entry point for the application.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dictionary with ‘composite_result’ (CompositeResult) and ‘graph’ (nx.DiGraph) |
dict[str, Any] | None
|
if evaluation runs successfully, None otherwise (CLI mode or download-only). |
Source code in src/app/app.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
app.benchmark.sweep_analysis
¶
Statistical analysis for MAS composition sweep results.
This module provides functions to calculate statistics (mean, stddev, min, max) across multiple sweep runs and generate summary reports in machine-readable (JSON) and human-readable (Markdown) formats.
Classes¶
CompositionStats
¶
Bases: BaseModel
Statistical summary for a single agent composition.
Aggregates metrics across all repetitions for one composition.
Source code in src/app/benchmark/sweep_analysis.py
SweepAnalyzer
¶
Analyzer for sweep results.
Groups results by composition and calculates per-composition statistics.
Source code in src/app/benchmark/sweep_analysis.py
Functions¶
__init__(results)
¶
Initialize analyzer with sweep results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list[tuple[AgentComposition, CompositeResult]]
|
List of (composition, result) tuples from sweep run. |
required |
analyze()
¶
Analyze sweep results and calculate per-composition statistics.
Groups results by composition and calculates mean/stddev for all metrics.
Returns:
| Type | Description |
|---|---|
list[CompositionStats]
|
list[CompositionStats]: Statistics for each unique composition. |
Example
analyzer = SweepAnalyzer(results) stats = analyzer.analyze() len(stats) # Number of unique compositions 8
Source code in src/app/benchmark/sweep_analysis.py
Functions¶
calculate_statistics(scores)
¶
Calculate mean, stddev, min, max for a list of scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
list[float]
|
List of numerical scores to analyze. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
dict[str, float]: Dictionary with keys ‘mean’, ‘stddev’, ‘min’, ‘max’. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If scores list is empty. |
Example
calculate_statistics([0.75, 0.80, 0.70])
Source code in src/app/benchmark/sweep_analysis.py
generate_markdown_summary(stats)
¶
Generate human-readable Markdown summary table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stats
|
list[CompositionStats]
|
List of composition statistics to summarize. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Markdown-formatted table with mean ± stddev for all metrics. |
Example
markdown = generate_markdown_summary(stats) “| Composition” in markdown True “Overall Score” in markdown True
Source code in src/app/benchmark/sweep_analysis.py
app.benchmark.sweep_config
¶
Configuration models for MAS composition sweep.
This module defines Pydantic models for sweep configuration including agent composition definitions and convenience functions for generating standard composition sets.
Classes¶
AgentComposition
¶
Bases: BaseModel
Configuration for a specific agent composition.
Defines which agents are included in a multi-agent system composition. Each toggle determines whether the corresponding agent is instantiated.
Source code in src/app/benchmark/sweep_config.py
Functions¶
get_name()
¶
Generate a readable name for this composition.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A human-readable name describing the active agents. |
Example
comp = AgentComposition(include_researcher=True, include_analyst=False) comp.get_name() ‘researcher’
Source code in src/app/benchmark/sweep_config.py
SweepConfig
¶
Bases: BaseModel
Configuration for a composition sweep run.
Defines the sweep parameters including which compositions to test, how many repetitions per composition, which papers to evaluate, and which execution engine to use (MAS pipeline or Claude Code headless).
Source code in src/app/benchmark/sweep_config.py
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 | |
Functions¶
validate_compositions_not_empty(v)
classmethod
¶
Validate that compositions list is not empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
list[AgentComposition]
|
The compositions list to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[AgentComposition]
|
The validated compositions list. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If compositions list is empty. |
Source code in src/app/benchmark/sweep_config.py
validate_paper_ids_not_empty(v)
classmethod
¶
Validate that paper_ids list is not empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
list[str]
|
The paper_ids list to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The validated paper_ids list. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If paper_ids list is empty. |
Source code in src/app/benchmark/sweep_config.py
validate_repetitions_positive(v)
classmethod
¶
Validate that repetitions is positive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
int
|
The repetitions value to validate. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The validated repetitions value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If repetitions is zero or negative. |
Source code in src/app/benchmark/sweep_config.py
Functions¶
generate_all_compositions()
¶
Generate all 2^3 = 8 possible agent compositions.
This convenience function generates the full Cartesian product of all agent toggle combinations.
Returns:
| Type | Description |
|---|---|
list[AgentComposition]
|
list[AgentComposition]: List of 8 unique agent compositions. |
Example
compositions = generate_all_compositions() len(compositions) 8 any(c.include_researcher and c.include_analyst for c in compositions) True
Source code in src/app/benchmark/sweep_config.py
app.benchmark.sweep_runner
¶
Sweep runner for MAS composition benchmarking.
This module orchestrates multiple evaluation runs across different agent compositions and optionally invokes Claude Code in headless mode for baseline comparison.
Classes¶
SweepRunner
¶
Runner for composition sweep experiments.
Executes the MAS evaluation pipeline across multiple compositions with repetitions for statistical significance.
Source code in src/app/benchmark/sweep_runner.py
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 | |
Functions¶
__init__(config)
¶
Initialize sweep runner with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SweepConfig
|
Sweep configuration defining compositions, repetitions, papers. |
required |
Source code in src/app/benchmark/sweep_runner.py
run()
async
¶
Execute the full sweep across all compositions and repetitions.
Partial results are always saved via finally block, even if an evaluation crashes mid-sweep (e.g. token limit exceeded).
Returns:
| Type | Description |
|---|---|
list[tuple[AgentComposition, CompositeResult]]
|
list[tuple[AgentComposition, CompositeResult]]: All evaluation results. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If engine=cc but claude CLI not found. |
Source code in src/app/benchmark/sweep_runner.py
Functions¶
run_sweep(config)
async
¶
Convenience function to run a sweep with given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SweepConfig
|
Sweep configuration. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[AgentComposition, CompositeResult]]
|
list[tuple[AgentComposition, CompositeResult]]: All evaluation results. |
Source code in src/app/benchmark/sweep_runner.py
app.common.error_messages
¶
Error message utilities for the Agents-eval application.
This module provides concise helper functions for generating standardized error messages related to configuration loading and validation.
Functions¶
api_connection_error(error)
¶
Generate an error message for API connection error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
The error message or exception string |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
Source code in src/app/common/error_messages.py
failed_to_load_config(error)
¶
Generate an error message for configuration loading failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
The error message or exception string |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
Source code in src/app/common/error_messages.py
file_not_found(file_path)
¶
Generate an error message for a missing configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
Path to the missing file |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
Source code in src/app/common/error_messages.py
generic_exception(error)
¶
Generate a generic error message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
The error message or exception string |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
get_key_error(error)
¶
Generate a key error message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
The key error message |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
invalid_data_model_format(error)
¶
Generate an error message for invalid pydantic data model format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
The validation error message |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
Source code in src/app/common/error_messages.py
invalid_json(error)
¶
Generate an error message for invalid JSON in a configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
str
|
The JSON parsing error message |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
Source code in src/app/common/error_messages.py
invalid_type(expected_type, actual_type)
¶
Generate an error message for invalid Type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected_type
|
str
|
The expected type as a string |
required |
actual_type
|
str
|
The actual type received as a string |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted error message string |
Source code in src/app/common/error_messages.py
app.common.log
¶
Logging configuration for the Agents-eval application.
Sets up the logger with custom settings including file rotation, retention, and compression. Logs are written to a file with automatic rotation.
Functions¶
app.common.models
¶
Common data models for the Agents-eval application.
This module provides shared Pydantic base models and common data structures used across the application.
Classes¶
CommonBaseModel
¶
Bases: BaseModel
Common base model with shared configuration for all Pydantic models.
Provides consistent configuration across all data models in the application including validation behavior and serialization settings.
Source code in src/app/common/models.py
app.config.app_env
¶
Application environment settings loaded from environment variables or .env file.
This module uses Pydantic’s BaseSettings to manage API keys and configuration for various inference endpoints, tools, and logging/monitoring services.
Classes¶
AppEnv
¶
Bases: BaseSettings
Application environment settings loaded from environment variables or .env file.
This class uses Pydantic’s BaseSettings to manage API keys and configuration for various inference endpoints, tools, and logging/monitoring services. Environment variables are loaded from a .env file by default.
Source code in src/app/config/app_env.py
app.config.common_settings
¶
Common settings module using pydantic-settings.
This module implements configuration following 12-Factor #3 (Config) principles: - Defaults in code (version-controlled) - Environment variable overrides via EVAL_ prefix - .env file support for local development
Classes¶
CommonSettings
¶
Bases: BaseSettings
Common settings for the Agents-eval application.
Configuration follows 12-Factor #3 principles with typed defaults in code and environment variable overrides using the EVAL_ prefix.
Attributes:
| Name | Type | Description |
|---|---|---|
log_level |
str
|
Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
enable_logfire |
bool
|
Enable Logfire tracing integration |
max_content_length |
int
|
Maximum content length for paper content (characters) |
Source code in src/app/config/common_settings.py
app.config.config_app
¶
Configuration constants for the application.
app.config.judge_settings
¶
Judge settings module using pydantic-settings.
This module implements evaluation configuration following 12-Factor #3 (Config) principles: - Defaults in code (version-controlled) - Environment variable overrides via JUDGE_ prefix - .env file support for local development
Classes¶
JudgeSettings
¶
Bases: BaseSettings
Judge settings for the evaluation pipeline.
Configuration follows 12-Factor #3 principles with typed defaults in code and environment variable overrides using the JUDGE_ prefix. Uses pydantic-settings for typed, environment-driven configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
tiers_enabled |
list[int]
|
List of enabled evaluation tiers (1=Traditional, 2=LLM, 3=Graph) |
tier1_max_seconds |
float
|
Tier 1 timeout (Traditional Metrics) |
tier2_max_seconds |
float
|
Tier 2 timeout (LLM-as-Judge) |
tier3_max_seconds |
float
|
Tier 3 timeout (Graph Analysis) |
total_max_seconds |
float
|
Total pipeline timeout |
tier1_similarity_metrics |
list[str]
|
Similarity metrics for Tier 1 |
tier1_confidence_threshold |
float
|
Confidence threshold for Tier 1 |
tier1_bertscore_model |
str
|
BERTScore model name |
tier1_tfidf_max_features |
int
|
Max features for TF-IDF |
tier2_provider |
str
|
LLM provider for Tier 2 evaluation |
tier2_model |
str
|
LLM model for Tier 2 evaluation |
tier2_fallback_provider |
str
|
Fallback LLM provider |
tier2_fallback_model |
str
|
Fallback LLM model |
tier2_max_retries |
int
|
Max retry attempts for LLM calls |
tier2_timeout_seconds |
float
|
Request timeout for LLM calls |
tier2_cost_budget_usd |
float
|
Cost budget for LLM evaluation |
tier2_paper_excerpt_length |
int
|
Paper excerpt length for LLM context |
tier3_min_nodes |
int
|
Minimum nodes for graph analysis |
tier3_centrality_measures |
list[str]
|
Centrality measures for graph analysis |
tier3_max_nodes |
int
|
Maximum nodes for graph analysis |
tier3_max_edges |
int
|
Maximum edges for graph analysis |
tier3_operation_timeout |
float
|
Operation timeout for graph operations |
fallback_strategy |
str
|
Fallback strategy when tiers fail |
composite_accept_threshold |
float
|
Score threshold for “accept” recommendation |
composite_weak_accept_threshold |
float
|
Score threshold for “weak_accept” |
composite_weak_reject_threshold |
float
|
Score threshold for “weak_reject” |
trace_collection |
bool
|
Enable trace collection |
trace_storage_path |
str
|
Directory for trace file storage |
logfire_enabled |
bool
|
Enable Logfire tracing |
logfire_send_to_cloud |
bool
|
Send traces to Logfire cloud (requires LOGFIRE_TOKEN) |
phoenix_endpoint |
str
|
Phoenix local trace viewer endpoint |
logfire_service_name |
str
|
Service name for tracing |
performance_logging |
bool
|
Enable performance logging |
Source code in src/app/config/judge_settings.py
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 | |
Functions¶
get_enabled_tiers()
¶
Get enabled tiers as a set.
Returns:
| Type | Description |
|---|---|
set[int]
|
Set of enabled tier numbers for backward compatibility |
get_performance_targets()
¶
Get performance targets as dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary of performance targets for backward compatibility |
Source code in src/app/config/judge_settings.py
is_tier_enabled(tier)
¶
Check if a specific tier is enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tier
|
int
|
Tier number to check (1, 2, or 3) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if tier is enabled |
app.config.logfire_config
¶
Logfire + Phoenix tracing configuration model.
Classes¶
LogfireConfig
¶
Bases: BaseModel
Configuration for Logfire + Phoenix tracing integration.
Constructed from JudgeSettings via from_settings(). All values are controlled by JUDGE_LOGFIRE_ and JUDGE_PHOENIX_ env vars through pydantic-settings.
Source code in src/app/config/logfire_config.py
Functions¶
from_settings(settings)
classmethod
¶
Create LogfireConfig from JudgeSettings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings
|
JudgeSettings instance with logfire fields. |
required |
Returns:
| Type | Description |
|---|---|
LogfireConfig
|
LogfireConfig populated from pydantic-settings. |
Source code in src/app/config/logfire_config.py
app.config.peerread_config
¶
PeerRead dataset configuration model.
Classes¶
PeerReadConfig
¶
Bases: BaseModel
Configuration for PeerRead dataset management.
Source code in src/app/config/peerread_config.py
app.data_models.app_models
¶
Data models for agent system configuration and results.
This module defines Pydantic models for representing research and analysis results, summaries, provider and agent configurations, and model dictionaries used throughout the application. These models ensure type safety and validation for data exchanged between agents and system components.
Classes¶
AgentConfig
¶
Bases: BaseModel
Configuration for an agent
Source code in src/app/data_models/app_models.py
AnalysisResult
¶
ChatConfig
¶
Bases: BaseModel
Configuration settings for agents and model providers
Source code in src/app/data_models/app_models.py
EndpointConfig
¶
Bases: BaseModel
Configuration for an agent
Source code in src/app/data_models/app_models.py
ModelDict
¶
Bases: BaseModel
Dictionary of models used to create agent systems
Source code in src/app/data_models/app_models.py
ProviderConfig
¶
ProviderMetadata
¶
Bases: BaseModel
Metadata for an LLM provider.
This model defines the core configuration for each supported provider, serving as a single source of truth for provider settings.
Source code in src/app/data_models/app_models.py
ResearchResult
¶
Bases: BaseModel
Research results from the research agent with flexible structure.
Source code in src/app/data_models/app_models.py
ResearchResultSimple
¶
ResearchSummary
¶
Bases: BaseModel
Expected model response of research on a topic
Source code in src/app/data_models/app_models.py
app.data_models.evaluation_models
¶
Data models for three-tiered evaluation system.
This module provides Pydantic models for the comprehensive evaluation framework that assesses multi-agent systems on PeerRead scientific paper review generation.
Classes¶
AgentMetrics
¶
Bases: BaseModel
Simple agent-level metrics for evaluation enhancement.
Source code in src/app/data_models/evaluation_models.py
Functions¶
get_agent_composite_score()
¶
Calculate simple weighted composite score for agent metrics.
Source code in src/app/data_models/evaluation_models.py
BaselineComparison
¶
Bases: BaseModel
Pairwise comparison of two CompositeResult instances.
Captures metric-level and tier-level deltas between two evaluation results, with human-readable summary for interpretation.
Source code in src/app/data_models/evaluation_models.py
CompositeEvaluationResult
¶
Bases: BaseModel
Complete three-tier evaluation result.
Aggregates all evaluation tiers into a single comprehensive assessment with composite scoring and recommendation generation.
Source code in src/app/data_models/evaluation_models.py
CompositeResult
¶
Bases: BaseModel
Result of composite scoring across all three evaluation tiers.
Integrates Traditional Metrics, LLM-as-Judge, and Graph Analysis into unified scoring system with recommendation mapping.
Source code in src/app/data_models/evaluation_models.py
ConstructivenessAssessment
¶
Bases: BaseModel
LLM assessment of constructiveness.
Source code in src/app/data_models/evaluation_models.py
EvaluationResults
¶
Bases: BaseModel
Container for all three evaluation tier results.
Source code in src/app/data_models/evaluation_models.py
GraphTraceData
¶
Bases: BaseModel
Trace data structure for graph-based analysis.
Captures execution traces from agent interactions, tool usage, and coordination patterns for NetworkX graph construction.
Source code in src/app/data_models/evaluation_models.py
Functions¶
from_trace_dict(trace, fallback_id='minimal')
classmethod
¶
Create GraphTraceData from an execution trace dict, with safe defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
dict[str, Any] | None
|
Raw execution trace dict, or None for a minimal empty instance. |
required |
fallback_id
|
str
|
Execution ID to use when trace is None. |
'minimal'
|
Returns:
| Type | Description |
|---|---|
GraphTraceData
|
GraphTraceData populated from dict or with empty defaults. |
Source code in src/app/data_models/evaluation_models.py
PeerReadEvalResult
¶
Bases: BaseModel
Result of evaluating agent review against PeerRead ground truth.
Source code in src/app/data_models/evaluation_models.py
PlanningRationalityAssessment
¶
Bases: BaseModel
LLM assessment of planning rationality.
Source code in src/app/data_models/evaluation_models.py
TechnicalAccuracyAssessment
¶
Bases: BaseModel
LLM assessment of technical accuracy.
Source code in src/app/data_models/evaluation_models.py
Tier1Result
¶
Bases: BaseModel
Traditional metrics evaluation result.
Contains text similarity metrics, execution performance, and task success indicators using lightweight computational approaches.
Source code in src/app/data_models/evaluation_models.py
Tier2Result
¶
Bases: BaseModel
LLM-as-Judge evaluation result.
Contains quality assessments from large language model evaluation including technical accuracy, constructiveness, and planning rationality.
Source code in src/app/data_models/evaluation_models.py
Tier3Result
¶
Bases: BaseModel
Graph-based analysis result.
Contains metrics derived from analyzing agent coordination patterns, tool usage efficiency using NetworkX.
Source code in src/app/data_models/evaluation_models.py
app.data_models.peerread_models
¶
PeerRead dataset data models.
This module defines Pydantic models for representing PeerRead scientific paper review data structures. These models ensure type safety and validation for papers, reviews, and evaluation results used in the multi-agent system evaluation.
The models are based on the actual PeerRead dataset structure validated from: https://raw.githubusercontent.com/allenai/PeerRead/master/data/acl_2017/train/reviews/104.json
This module also includes structured data models for LLM-generated reviews, ensuring consistency and validation against the PeerRead format.
Classes¶
DownloadResult
¶
Bases: BaseModel
Result of dataset download operation.
Source code in src/app/data_models/peerread_models.py
GeneratedReview
¶
Bases: BaseModel
Structured data model for LLM-generated reviews.
This model enforces the PeerRead review format and ensures all required fields are present with proper validation.
Source code in src/app/data_models/peerread_models.py
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 | |
Functions¶
to_peerread_format()
¶
Convert to PeerRead dataset format for compatibility.
Source code in src/app/data_models/peerread_models.py
validate_comments_structure(v)
¶
Ensure comments contain key review sections.
Source code in src/app/data_models/peerread_models.py
PeerReadPaper
¶
Bases: BaseModel
Scientific paper from PeerRead dataset.
Source code in src/app/data_models/peerread_models.py
PeerReadReview
¶
Bases: BaseModel
Individual peer review from PeerRead dataset.
Note: Some PeerRead papers (e.g., 304-308, 330) lack optional fields. Defaults to “UNKNOWN” for missing review criteria fields.
Accepts both PeerRead uppercase keys (IMPACT) and model lowercase keys (impact) via populate_by_name with aliases. Numeric score fields are coerced to str to handle raw PeerRead JSON integer values.
Source code in src/app/data_models/peerread_models.py
Functions¶
is_compliant()
¶
Check if all score fields are populated (not UNKNOWN).
A review is compliant when every field that defaults to UNKNOWN has been populated with an actual value from the raw JSON.
Returns:
| Type | Description |
|---|---|
bool
|
True if all score fields have non-UNKNOWN values. |
Source code in src/app/data_models/peerread_models.py
ReviewGenerationResult
¶
Bases: BaseModel
Complete result from the review generation process.
Contains the structured review along with metadata.
Source code in src/app/data_models/peerread_models.py
app.data_models.report_models
¶
Data models for evaluation report generation.
This module provides Pydantic models for structured report output including suggestion severity levels and individual suggestion records.
Classes¶
Suggestion
¶
Bases: BaseModel
A single actionable suggestion derived from evaluation results.
Each suggestion is grounded in a specific metric and tier, with a severity level indicating urgency. The action field provides concrete guidance.
Example
s = Suggestion( … metric=”cosine_score”, … tier=1, … severity=SuggestionSeverity.CRITICAL, … message=”Tier 1 cosine score very low (0.08) — vocabulary overlap minimal.”, … action=”Incorporate domain-specific terminology from the paper abstract.”, … )
Source code in src/app/data_models/report_models.py
SuggestionSeverity
¶
Bases: StrEnum
Severity level for evaluation suggestions.
Attributes:
| Name | Type | Description |
|---|---|---|
CRITICAL |
Score below critical threshold (< 0.2); immediate action required. |
|
WARNING |
Score below average (< 0.5); improvement recommended. |
|
INFO |
Improvement opportunity; score acceptable but can be enhanced. |
Source code in src/app/data_models/report_models.py
app.data_utils.datasets_peerread
¶
PeerRead dataset core utilities for download and loading.
This module provides pure dataset functionality for downloading, caching, and loading the PeerRead scientific paper review dataset. It contains no evaluation logic - only data access and management.
Classes¶
DataTypeSpec
dataclass
¶
Specification for a PeerRead data type.
Attributes:
| Name | Type | Description |
|---|---|---|
extension |
str
|
File extension including leading dot(s), e.g. ‘.json’. |
is_json |
bool
|
True if the file content is JSON, False for binary (PDF). |
Source code in src/app/data_utils/datasets_peerread.py
PeerReadDownloader
¶
Downloads PeerRead dataset files with caching and validation.
Handles direct download from GitHub repository with progress tracking, error recovery, and integrity verification.
Source code in src/app/data_utils/datasets_peerread.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
Functions¶
__init__(config)
¶
Initialize downloader with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PeerReadConfig
|
PeerRead dataset configuration. |
required |
Source code in src/app/data_utils/datasets_peerread.py
download_file(venue, split, data_type, paper_id)
¶
Download a single file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venue
|
str
|
Conference venue. |
required |
split
|
str
|
Data split. |
required |
data_type
|
str
|
Type of data (‘reviews’, ‘parsed_pdfs’, ‘pdfs’). |
required |
paper_id
|
str
|
Paper identifier. |
required |
Returns:
| Type | Description |
|---|---|
bytes | dict[str, Any] | None
|
File content (JSON dict for .json files, bytes for PDFs), |
bytes | dict[str, Any] | None
|
or None if download fails. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If venue/split is invalid. |
Source code in src/app/data_utils/datasets_peerread.py
download_venue_split(venue, split, max_papers=None)
¶
Download all files for a venue/split combination across all data types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venue
|
str
|
Conference venue. |
required |
split
|
str
|
Data split. |
required |
max_papers
|
int | None
|
Maximum number of papers to download. |
None
|
Returns:
| Type | Description |
|---|---|
DownloadResult
|
DownloadResult with download statistics. |
Source code in src/app/data_utils/datasets_peerread.py
PeerReadLoader
¶
Loads and queries PeerRead dataset with structured access.
Source code in src/app/data_utils/datasets_peerread.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | |
Functions¶
__init__(config=None)
¶
Initialize loader with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PeerReadConfig | None
|
PeerRead dataset configuration. Loads from file if None. |
None
|
Source code in src/app/data_utils/datasets_peerread.py
get_paper_by_id(paper_id)
¶
Get a specific paper by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str
|
Paper identifier. |
required |
Returns:
| Type | Description |
|---|---|
PeerReadPaper | None
|
PeerReadPaper if found, None otherwise. |
Source code in src/app/data_utils/datasets_peerread.py
get_raw_pdf_path(paper_id)
¶
Get the absolute path to the raw PDF file for a given paper ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str
|
Unique identifier for the paper. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str | None
|
The absolute path to the PDF file, or None if not found. |
Source code in src/app/data_utils/datasets_peerread.py
load_papers(venue='acl_2017', split='train')
¶
Load papers from cached data or download if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venue
|
str
|
Conference venue. |
'acl_2017'
|
split
|
str
|
Data split. |
'train'
|
Returns:
| Type | Description |
|---|---|
list[PeerReadPaper]
|
List of validated PeerReadPaper models. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If cache directory doesn’t exist and download fails. |
Source code in src/app/data_utils/datasets_peerread.py
load_parsed_pdf_content(paper_id)
¶
Load the text content from the parsed PDF for a given paper ID.
Assumes parsed PDF files are JSON and contain a ‘sections’ key with ‘text’ within. Defaults to the latest revision if multiple exist (by filename).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str
|
Unique identifier for the paper. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str | None
|
The extracted text content, or None if not found/parsed. |
Source code in src/app/data_utils/datasets_peerread.py
query_papers(venue=None, min_reviews=1, limit=None)
¶
Query papers with filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venue
|
str | None
|
Filter by venue (None for all venues). |
None
|
min_reviews
|
int
|
Minimum number of reviews required. |
1
|
limit
|
int | None
|
Maximum number of papers to return. |
None
|
Returns:
| Type | Description |
|---|---|
list[PeerReadPaper]
|
List of filtered PeerReadPaper models. |
Source code in src/app/data_utils/datasets_peerread.py
Functions¶
download_peerread_dataset(peerread_max_papers_per_sample_download=None)
¶
Download PeerRead dataset and verify the download.
This function handles the setup phase separately from MAS execution, following Separation of Concerns principle. It downloads the dataset to the configured path and verifies the download was successful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peerread_max_papers_per_sample_download
|
int | None
|
The maximum number of papers to download. If None, downloads all papers it can find. |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If download or verification fails. |
Source code in src/app/data_utils/datasets_peerread.py
load_peerread_config()
¶
Load PeerRead dataset configuration from config file.
Returns:
| Name | Type | Description |
|---|---|---|
PeerReadConfig |
PeerReadConfig
|
Validated configuration object. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config file doesn’t exist. |
ValidationError
|
If config data is invalid. |
Source code in src/app/data_utils/datasets_peerread.py
app.data_utils.review_persistence
¶
Review persistence interface for MAS and evaluation system integration.
Classes¶
ReviewPersistence
¶
Handles saving and loading of MAS-generated reviews.
Source code in src/app/data_utils/review_persistence.py
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 | |
Functions¶
__init__(reviews_dir=_DEFAULT_REVIEWS_DIR)
¶
Initialize with reviews directory path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reviews_dir
|
str
|
Directory to store review files |
_DEFAULT_REVIEWS_DIR
|
Source code in src/app/data_utils/review_persistence.py
get_latest_review(paper_id)
¶
Get the most recent review file for a paper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str
|
Paper identifier |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str | None
|
Path to latest review file, or None if not found |
Source code in src/app/data_utils/review_persistence.py
list_reviews(paper_id=None)
¶
List available review files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str | None
|
Optional filter by paper ID |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[str]
|
Paths to matching review files |
Source code in src/app/data_utils/review_persistence.py
load_review(filepath)
¶
Load a review from file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to the review file |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[str, PeerReadReview]
|
(paper_id, PeerReadReview object) |
Source code in src/app/data_utils/review_persistence.py
save_review(paper_id, review, timestamp=None, run_dir=None, structured_review=None, model_info=None)
¶
Save a review to the run directory or legacy reviews directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str
|
Unique identifier for the paper |
required |
review
|
PeerReadReview
|
The generated review object |
required |
timestamp
|
str | None
|
Optional timestamp, defaults to current UTC time |
None
|
run_dir
|
Path | None
|
Optional per-run directory; writes review.json there if provided. |
None
|
structured_review
|
dict[str, object] | None
|
Optional GeneratedReview dict with validated scores. |
None
|
model_info
|
str | None
|
Optional model identifier string. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Path to the saved review file |
Source code in src/app/data_utils/review_persistence.py
Functions¶
app.engines.cc_engine
¶
Consolidated Claude Code (CC) engine for solo and teams execution.
Replaces duplicated subprocess logic scattered across run_cli.py, sweep_runner.py, and shell scripts with a single, well-tested Python module.
Critical constraint (from AGENT_LEARNINGS.md): CC teams artifacts are ephemeral in
claude -p print mode. This module uses --output-format stream-json with
Popen to parse team events from the live stream instead of filesystem artifacts.
Classes¶
CCResult
¶
Bases: BaseModel
Result of a Claude Code execution (solo or teams mode).
Attributes:
| Name | Type | Description |
|---|---|---|
execution_id |
str
|
Session or team identifier extracted from stream. |
output_data |
dict[str, Any]
|
Parsed JSON output (solo) or aggregated result data (teams). |
session_dir |
str | None
|
Solo session directory path (from JSON output), if present. |
team_artifacts |
list[dict[str, Any]]
|
Team-related events parsed from stream-json (teams mode). |
Source code in src/app/engines/cc_engine.py
Functions¶
build_cc_query(query, paper_id=None, cc_teams=False)
¶
Build a non-empty query for CC engine execution.
When no explicit query is provided but a paper_id is available, generates a default review prompt using DEFAULT_REVIEW_PROMPT_TEMPLATE. In teams mode, prepends a team instruction to increase likelihood of CC spawning teammates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
User-provided query string (may be empty). |
required |
paper_id
|
str | None
|
Optional PeerRead paper ID for auto-generating a prompt. |
None
|
cc_teams
|
bool
|
Whether CC teams mode is enabled. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Non-empty query string for CC subprocess. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When both query and paper_id are empty/None. |
Example
build_cc_query(“”, paper_id=”1105.1072”) “Generate a structured peer review for paper ‘1105.1072’.” build_cc_query(“”, paper_id=”1105.1072”, cc_teams=True) “Use a team of agents. Generate a structured peer review for paper ‘1105.1072’.”
Source code in src/app/engines/cc_engine.py
cc_result_to_graph_trace(cc_result)
¶
Build GraphTraceData from a CCResult for graph-based analysis.
Solo mode: returns minimal GraphTraceData with empty lists (the composite scorer detects single_agent_mode and redistributes weights).
Teams mode: maps Task events to agent_interactions and TeamCreate events to coordination_events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cc_result
|
CCResult
|
CCResult from solo or teams execution. |
required |
Returns:
| Type | Description |
|---|---|
GraphTraceData
|
GraphTraceData populated from CC artifacts. |
Example
result = CCResult(execution_id=”solo-1”, output_data={}) trace = cc_result_to_graph_trace(result) trace.execution_id ‘solo-1’
Source code in src/app/engines/cc_engine.py
check_cc_available()
¶
Check whether the Claude Code CLI is installed and on PATH.
Returns:
| Type | Description |
|---|---|
bool
|
True if ‘claude’ binary is found on PATH, False otherwise. |
Example
if not check_cc_available(): … raise RuntimeError(“claude CLI required for –engine=cc”)
Source code in src/app/engines/cc_engine.py
extract_cc_review_text(cc_result)
¶
Extract review text from a CC execution result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cc_result
|
CCResult
|
CCResult from solo or teams execution. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Review text string, or empty string if not present. |
Example
result = CCResult(execution_id=”x”, output_data={“result”: “Good paper.”}) extract_cc_review_text(result) ‘Good paper.’
Source code in src/app/engines/cc_engine.py
parse_stream_json(stream)
¶
Parse a JSONL stream from CC --output-format stream-json into CCResult.
Extracts:
- type=system, subtype=init → session_id becomes execution_id
- type=result → duration_ms, total_cost_usd, num_turns → output_data
- type=system, subtype in _TEAM_SUBTYPES → appended to team_artifacts
Skips blank lines and malformed JSON without raising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
Iterator[str]
|
Iterator of raw JSONL lines (strings) from CC stdout. |
required |
Returns:
| Type | Description |
|---|---|
CCResult
|
CCResult populated from parsed events. |
Example
lines = [‘{“type”: “result”, “num_turns”: 3}’] result = parse_stream_json(iter(lines)) result.output_data[“num_turns”] 3
Source code in src/app/engines/cc_engine.py
run_cc_solo(query, timeout=600, run_context=None)
¶
Run Claude Code in solo (headless print) mode.
Uses blocking subprocess.run with --output-format json. The full JSON
response is returned as a single object after the process exits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Prompt string passed to |
required |
timeout
|
int
|
Maximum seconds to wait for the process. Defaults to 600. |
600
|
run_context
|
RunContext | None
|
Optional RunContext for per-run output directory. |
None
|
Returns:
| Type | Description |
|---|---|
CCResult
|
CCResult with output_data from parsed JSON stdout and session_dir if present. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If query fails sanitization (empty, dash-prefixed, over-length) or if stdout cannot be parsed as JSON. |
RuntimeError
|
If the subprocess exits with non-zero code or times out. |
Example
result = run_cc_solo(“Summarise this paper”, timeout=300) print(result.execution_id)
Source code in src/app/engines/cc_engine.py
run_cc_teams(query, timeout=600, run_context=None)
¶
Run Claude Code in teams (agent orchestration) mode.
Uses subprocess.Popen with --output-format stream-json and the
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 environment variable. Team events
(TeamCreate, Task) are parsed from the live JSONL stream, since teams
artifacts are ephemeral in print mode and not available on the filesystem after
the process exits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Prompt string passed to |
required |
timeout
|
int
|
Maximum seconds to allow the process to run. Defaults to 600. |
600
|
run_context
|
RunContext | None
|
Optional RunContext for per-run output directory. |
None
|
Returns:
| Type | Description |
|---|---|
CCResult
|
CCResult with team_artifacts populated from stream events. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If query is empty, whitespace-only, or exceeds max length. |
RuntimeError
|
If the subprocess exits with non-zero code or times out. |
Example
result = run_cc_teams(“Review paper 1234 using a team”, timeout=600) print(len(result.team_artifacts))
Source code in src/app/engines/cc_engine.py
app.judge.baseline_comparison
¶
Baseline comparison engine for CompositeResult diffing.
Provides pairwise comparison of CompositeResult instances across three systems: - PydanticAI MAS (multi-agent system) - Claude Code solo (Claude Code without orchestration) - Claude Code teams (Claude Code with Agent Teams orchestration)
Reuses existing CompositeResult model and CompositeScorer.extract_metric_values().
Classes¶
Functions¶
compare(result_a, result_b, label_a, label_b)
¶
Compare two CompositeResult instances and return pairwise diff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result_a
|
CompositeResult
|
First CompositeResult instance |
required |
result_b
|
CompositeResult
|
Second CompositeResult instance |
required |
label_a
|
str
|
Label for first result (e.g., “PydanticAI”) |
required |
label_b
|
str
|
Label for second result (e.g., “Claude Code solo”) |
required |
Returns:
| Type | Description |
|---|---|
BaselineComparison
|
BaselineComparison with metric deltas, tier deltas, and summary |
Note
All deltas are calculated as (result_a - result_b). Positive delta means result_a scored higher.
Source code in src/app/judge/baseline_comparison.py
compare_all(pydantic_result, cc_solo_result, cc_teams_result)
¶
Generate all three pairwise comparisons across the three systems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pydantic_result
|
CompositeResult | None
|
PydanticAI MAS evaluation result (or None) |
required |
cc_solo_result
|
CompositeResult | None
|
Claude Code solo evaluation result (or None) |
required |
cc_teams_result
|
CompositeResult | None
|
Claude Code teams evaluation result (or None) |
required |
Returns:
| Type | Description |
|---|---|
list[BaselineComparison]
|
List of BaselineComparison instances for all valid pairwise comparisons. |
list[BaselineComparison]
|
Empty list if fewer than 2 results provided. |
Note
Skips comparisons involving None results. Order: (PydanticAI vs Claude Code solo, PydanticAI vs Claude Code teams, Claude Code solo vs Claude Code teams)
Source code in src/app/judge/baseline_comparison.py
app.judge.cc_trace_adapter
¶
Claude Code trace adapter for evaluation pipeline integration.
Parses Claude Code artifacts (solo and teams mode) into GraphTraceData format for three-tier evaluation pipeline, enabling side-by-side comparison with PydanticAI MAS runs.
Classes¶
CCTraceAdapter
¶
Adapter for parsing Claude Code execution artifacts into GraphTraceData.
Supports two modes: - Teams mode: Parses CC Agent Teams artifacts (config.json, inboxes/, tasks/) - Solo mode: Parses single CC session exports (metadata.json, tool_calls.jsonl)
Auto-detects mode from directory structure.
Attributes:
| Name | Type | Description |
|---|---|---|
artifacts_dir |
Path to CC artifacts directory |
|
mode |
Literal['teams', 'solo']
|
Detected mode (‘teams’ or ‘solo’) |
Source code in src/app/judge/cc_trace_adapter.py
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 | |
Functions¶
__init__(artifacts_dir, *, tasks_dir=None)
¶
Initialize adapter with artifacts directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifacts_dir
|
Path
|
Path to directory containing CC artifacts (teams mode) or session exports (solo mode) |
required |
tasks_dir
|
Path | None
|
Optional explicit path to tasks directory. If None, will auto-discover for teams mode by checking sibling and child layouts. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If directory does not exist |
Source code in src/app/judge/cc_trace_adapter.py
parse()
¶
Parse CC artifacts into GraphTraceData format.
Returns:
| Type | Description |
|---|---|
GraphTraceData
|
GraphTraceData instance ready for Tier 3 evaluation |
Raises:
| Type | Description |
|---|---|
ValueError
|
If artifacts are missing or malformed |
Source code in src/app/judge/cc_trace_adapter.py
app.judge.composite_scorer
¶
Composite scoring system for three-tiered evaluation framework.
Integrates Traditional Metrics (Tier 1), LLM-as-Judge (Tier 2), and Graph Analysis (Tier 3) into unified scoring system with recommendation mapping.
Classes¶
CompositeScorer
¶
Composite scoring system that integrates all three evaluation tiers.
Implements the six-metric equal-weight formula: - time_taken (0.167) - task_success (0.167) - coordination_quality (0.167) - tool_efficiency (0.167) - planning_rationality (0.167) - output_similarity (0.167)
Maps scores to recommendation categories with thresholds.
Source code in src/app/judge/composite_scorer.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | |
Functions¶
__init__(settings=None)
¶
Initialize composite scorer with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings | None
|
JudgeSettings instance. If None, uses default JudgeSettings(). |
None
|
Source code in src/app/judge/composite_scorer.py
assess_agent_performance(execution_time, tools_used, delegation_count=0, error_occurred=False, output_length=0)
¶
Assess agent performance with simple rule-based metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_time
|
float
|
Time taken for agent execution in seconds |
required |
tools_used
|
list[str]
|
List of tools used during execution |
required |
delegation_count
|
int
|
Number of delegations made (for manager agents) |
0
|
error_occurred
|
bool
|
Whether an error occurred during execution |
False
|
output_length
|
int
|
Length of output result in characters |
0
|
Returns:
| Type | Description |
|---|---|
AgentMetrics
|
AgentMetrics with evaluated scores |
Source code in src/app/judge/composite_scorer.py
calculate_composite_score(results)
¶
Calculate weighted composite score from all evaluation tiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvaluationResults
|
Container with tier1, tier2, tier3 evaluation results |
required |
Returns:
| Type | Description |
|---|---|
float
|
Composite score (0.0 to 1.0) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required tier results are missing |
Source code in src/app/judge/composite_scorer.py
evaluate_composite(results)
¶
Complete composite evaluation with score and recommendation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvaluationResults
|
Container with tier1, tier2, tier3 evaluation results |
required |
Returns:
| Type | Description |
|---|---|
CompositeResult
|
CompositeResult with score, recommendation, and detailed metrics |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required tier results are missing |
Source code in src/app/judge/composite_scorer.py
evaluate_composite_with_optional_tier2(results)
¶
Evaluate composite score with optional Tier 2 (handles missing Tier 2).
When Tier 2 is None, redistributes weights to Tier 1 and Tier 3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvaluationResults
|
Container with tier1, tier3, and optional tier2 results |
required |
Returns:
| Type | Description |
|---|---|
CompositeResult
|
CompositeResult with adjusted weights when Tier 2 is missing |
Source code in src/app/judge/composite_scorer.py
evaluate_composite_with_trace(results, trace_data)
¶
Evaluate composite score with single-agent mode detection and weight redistribution.
Detects single-agent runs from trace data and redistributes coordination_quality weight to remaining metrics. Also handles Tier 2 skip for compound redistribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvaluationResults
|
Container with tier1, tier2, tier3 evaluation results |
required |
trace_data
|
GraphTraceData
|
Graph trace data for single-agent detection |
required |
Returns:
| Type | Description |
|---|---|
CompositeResult
|
CompositeResult with adjusted weights for single-agent mode |
Source code in src/app/judge/composite_scorer.py
extract_metric_values(results)
¶
Extract the six composite metrics from tier results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
EvaluationResults
|
Container with tier1, tier2, tier3 evaluation results |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary with normalized metric values (0.0 to 1.0) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required tier results are missing |
Source code in src/app/judge/composite_scorer.py
get_recommendation_weight(recommendation)
¶
Get numerical weight for recommendation category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recommendation
|
str
|
Recommendation category |
required |
Returns:
| Type | Description |
|---|---|
float
|
Numerical weight (-1.0 to 1.0) |
Source code in src/app/judge/composite_scorer.py
get_scoring_summary()
¶
Get summary of scoring configuration for validation.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with configuration summary |
Source code in src/app/judge/composite_scorer.py
map_to_recommendation(composite_score)
¶
Map composite score to recommendation category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
composite_score
|
float
|
Composite score (0.0 to 1.0) |
required |
Returns:
| Type | Description |
|---|---|
str
|
Recommendation category: “accept”, “weak_accept”, “weak_reject”, or “reject” |
Source code in src/app/judge/composite_scorer.py
app.judge.evaluation_pipeline
¶
Streamlined three-tier evaluation pipeline orchestrator.
Coordinates Traditional Metrics (Tier 1), LLM-as-Judge (Tier 2), and Graph Analysis (Tier 3) into unified evaluation workflow with graceful degradation. Uses modular components for configuration and monitoring.
Classes¶
EvaluationPipeline
¶
Streamlined evaluation pipeline orchestrator for three-tier assessment.
Coordinates execution of Traditional Metrics → LLM-as-Judge → Graph Analysis with configurable tier enabling and graceful degradation. Uses modular components for configuration management and performance monitoring.
Source code in src/app/judge/evaluation_pipeline.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | |
Attributes¶
config_path
property
¶
Get configuration path (backward compatibility property).
Returns:
| Type | Description |
|---|---|
Path | None
|
Always None (settings-based configuration only) |
enabled_tiers
property
¶
Get enabled tiers (backward compatibility property).
Returns:
| Type | Description |
|---|---|
set[int]
|
Set of enabled tier numbers |
execution_stats
property
¶
Get execution statistics (backward compatibility property).
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with execution statistics |
fallback_strategy
property
¶
Get fallback strategy (backward compatibility property).
Returns:
| Type | Description |
|---|---|
str
|
Fallback strategy name |
performance_targets
property
¶
Get performance targets (backward compatibility property).
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary of performance targets |
Functions¶
__init__(settings=None, chat_provider=None, chat_model=None)
¶
Initialize evaluation pipeline with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings | None
|
JudgeSettings instance. If None, uses default JudgeSettings(). |
None
|
chat_provider
|
str | None
|
Active chat provider from agent system. Passed to LLMJudgeEngine for tier2_provider=auto mode. |
None
|
chat_model
|
str | None
|
Active chat model from agent system. Forwarded to LLMJudgeEngine for model inheritance in auto mode. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If configuration is invalid |
Source code in src/app/judge/evaluation_pipeline.py
evaluate_comprehensive(paper, review, execution_trace=None, reference_reviews=None)
async
¶
Execute comprehensive three-tier evaluation pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper
|
str
|
Paper content text for evaluation |
required |
review
|
str
|
Generated review text to assess |
required |
execution_trace
|
GraphTraceData | dict[str, Any] | None
|
Optional execution trace (GraphTraceData or dict) for graph analysis |
None
|
reference_reviews
|
list[str] | None
|
Optional list of ground truth reviews for similarity |
None
|
Returns:
| Type | Description |
|---|---|
CompositeResult
|
CompositeResult with scores from all applicable tiers |
Raises:
| Type | Description |
|---|---|
ValueError
|
If critical evaluation components fail |
Source code in src/app/judge/evaluation_pipeline.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
get_execution_stats()
¶
Get detailed execution statistics from last pipeline run.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with timing and execution details including performance analysis |
Source code in src/app/judge/evaluation_pipeline.py
get_pipeline_summary()
¶
Get pipeline configuration summary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with pipeline configuration details |
Source code in src/app/judge/evaluation_pipeline.py
app.judge.evaluation_runner
¶
Evaluation orchestration extracted from the main entry point.
Handles post-execution evaluation pipeline, baseline comparisons, and interaction graph construction from trace data.
Classes¶
Functions¶
build_graph_from_trace(execution_id)
¶
Build interaction graph from execution trace data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_id
|
str | None
|
Execution ID for trace retrieval. |
required |
Returns:
| Type | Description |
|---|---|
DiGraph[str] | None
|
NetworkX DiGraph if trace data available, None otherwise. |
Source code in src/app/judge/evaluation_runner.py
run_baseline_comparisons(pipeline, pydantic_result, cc_solo_dir, cc_teams_dir, cc_teams_tasks_dir)
async
¶
Run baseline comparisons against Claude Code solo and teams if directories provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline
|
EvaluationPipeline
|
Evaluation pipeline instance. |
required |
pydantic_result
|
CompositeResult | None
|
PydanticAI evaluation result. |
required |
cc_solo_dir
|
str | None
|
Path to Claude Code solo artifacts directory. |
required |
cc_teams_dir
|
str | None
|
Path to Claude Code teams artifacts directory. |
required |
cc_teams_tasks_dir
|
str | None
|
Path to Claude Code teams tasks directory (optional, auto-discovered if not specified). |
required |
Source code in src/app/judge/evaluation_runner.py
run_evaluation_if_enabled(skip_eval, paper_id, execution_id, cc_solo_dir=None, cc_teams_dir=None, cc_teams_tasks_dir=None, chat_provider=None, chat_model=None, judge_settings=None, manager_output=None, review_text=None, run_dir=None, execution_trace=None, engine_type='mas')
async
¶
Run evaluation pipeline after manager completes if enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skip_eval
|
bool
|
Whether to skip evaluation via CLI flag. |
required |
paper_id
|
str | None
|
Paper ID for PeerRead review (indicates ground truth availability). |
required |
execution_id
|
str | None
|
Execution ID for trace retrieval. |
required |
cc_solo_dir
|
str | None
|
Path to Claude Code solo artifacts directory for baseline comparison. |
None
|
cc_teams_dir
|
str | None
|
Path to Claude Code teams artifacts directory for baseline comparison. |
None
|
cc_teams_tasks_dir
|
str | None
|
Path to Claude Code teams tasks directory (optional, auto-discovered if not specified). |
None
|
chat_provider
|
str | None
|
Active chat provider from agent system. |
None
|
chat_model
|
str | None
|
Active chat model from agent system. Forwarded to LLMJudgeEngine for model inheritance when tier2_provider=auto. |
None
|
judge_settings
|
JudgeSettings | None
|
Optional JudgeSettings override from GUI or programmatic calls. |
None
|
manager_output
|
Any
|
Manager result output containing ReviewGenerationResult (optional). |
None
|
review_text
|
str | None
|
Pre-extracted review text (e.g. from CC engine). When provided, overrides text extraction from manager_output. |
None
|
run_dir
|
Path | None
|
Optional per-run output directory. When provided, evaluation results are persisted to evaluation.json in this directory. |
None
|
execution_trace
|
Any
|
Optional pre-built GraphTraceData (e.g. from CC engine). When provided, skips SQLite trace lookup. When None, falls back to trace_collector.load_trace() (existing MAS behavior). |
None
|
engine_type
|
str
|
Source engine identifier (‘mas’, ‘cc_solo’, or ‘cc_teams’). Set on CompositeResult before persisting to evaluation.json. |
'mas'
|
Returns:
| Type | Description |
|---|---|
CompositeResult | None
|
CompositeResult from PydanticAI evaluation or None if skipped. |
Source code in src/app/judge/evaluation_runner.py
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 | |
app.judge.graph_analysis
¶
Graph-based analysis engine for Tier 3 evaluation.
Provides NetworkX-based analysis of agent coordination patterns, tool usage efficiency, and communication overhead with streamlined implementation focusing on essential multi-agent interaction metrics.
Note: This module contains type: ignore comments for NetworkX operations due to incomplete type hints in the NetworkX library itself.
Classes¶
GraphAnalysisEngine
¶
NetworkX-based graph analysis engine for agent coordination evaluation.
Implements essential graph-based complexity metrics for multi-agent systems with focus on tool usage patterns, communication efficiency, and coordination quality using lightweight NetworkX operations.
Source code in src/app/judge/graph_analysis.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | |
Functions¶
__init__(settings)
¶
Initialize graph analysis engine with settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings
|
JudgeSettings instance with tier3 configuration. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If configuration is invalid |
Source code in src/app/judge/graph_analysis.py
analyze_agent_interactions(trace_data)
¶
Analyze agent-to-agent communication and coordination patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData
|
Processed execution trace data |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary with interaction analysis metrics |
Source code in src/app/judge/graph_analysis.py
analyze_task_distribution(trace_data)
¶
Analyze task distribution balance across agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData
|
Processed execution trace data |
required |
Returns:
| Type | Description |
|---|---|
float
|
Task distribution balance score (0.0-1.0) |
Source code in src/app/judge/graph_analysis.py
analyze_tool_usage_patterns(trace_data)
¶
Analyze tool usage efficiency and selection patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData
|
Processed execution trace data |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Dictionary with tool analysis metrics |
Source code in src/app/judge/graph_analysis.py
evaluate_graph_metrics(trace_data)
¶
Complete graph-based analysis evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData
|
Processed execution trace data |
required |
Returns:
| Type | Description |
|---|---|
Tier3Result
|
Tier3Result with all graph analysis metrics |
Source code in src/app/judge/graph_analysis.py
export_trace_to_networkx(trace_data)
¶
Export trace data to NetworkX graph for Phoenix visualization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData
|
Execution trace data to convert |
required |
Returns:
| Type | Description |
|---|---|
DiGraph[str] | None
|
NetworkX directed graph or None if export fails |
Source code in src/app/judge/graph_analysis.py
Functions¶
evaluate_single_graph_analysis(trace_data, settings=None)
¶
Convenience function for single graph analysis evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData | None
|
Execution trace data for analysis |
required |
settings
|
JudgeSettings | None
|
Optional JudgeSettings override. If None, uses defaults. |
None
|
Returns:
| Type | Description |
|---|---|
Tier3Result
|
Tier3Result with graph analysis metrics |
Example
from app.judge.trace_processors import get_trace_collector collector = get_trace_collector() trace_data = collector.load_trace(“execution_001”) result = evaluate_single_graph_analysis(trace_data) print(f”Overall score: {result.overall_score:.3f}”)
Source code in src/app/judge/graph_analysis.py
app.judge.graph_builder
¶
Utility for building NetworkX graphs from GraphTraceData.
Converts execution trace data into interactive network visualizations showing agent-to-agent interactions and tool usage patterns.
Classes¶
Functions¶
build_interaction_graph(trace_data)
¶
Build NetworkX directed graph from execution trace data.
Creates a visual representation of agent interactions and tool usage: - Agent nodes (blue circles in visualization) - Tool nodes (green squares in visualization) - Edges representing delegations and tool calls
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_data
|
GraphTraceData
|
GraphTraceData containing agent interactions and tool calls |
required |
Returns:
| Type | Description |
|---|---|
DiGraph[str]
|
NetworkX DiGraph with nodes and edges representing the execution flow |
Source code in src/app/judge/graph_builder.py
app.judge.graph_export
¶
Export nx.DiGraph as JSON (node-link format) and PNG (static render).
Persists the agent interaction graph built after each run to the per-run output directory. Both functions register their output with the ArtifactRegistry for end-of-run summary display.
Functions¶
export_graph_json(graph, output_dir)
¶
Serialize an nx.DiGraph to agent_graph.json using node-link format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
DiGraph[str]
|
NetworkX directed graph to export. |
required |
output_dir
|
Path
|
Directory to write the JSON file into. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written agent_graph.json file. |
Source code in src/app/judge/graph_export.py
export_graph_png(graph, output_dir)
¶
Render an nx.DiGraph to agent_graph.png as a static image.
Agent nodes are drawn as circles (#4e79a7 blue), tool nodes as squares (#59a14f green). Layout uses spring_layout with a fixed seed for reproducibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
DiGraph[str]
|
NetworkX directed graph to render. |
required |
output_dir
|
Path
|
Directory to write the PNG file into. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written agent_graph.png file. |
Source code in src/app/judge/graph_export.py
persist_graph(graph, output_dir)
¶
Export graph as JSON and PNG if graph is available.
No-op when graph is None. Convenience wrapper used by app.main() to avoid adding branching complexity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
DiGraph[str] | None
|
NetworkX directed graph, or None if unavailable. |
required |
output_dir
|
Path
|
Per-run output directory. |
required |
Source code in src/app/judge/graph_export.py
app.judge.llm_evaluation_managers
¶
LLM evaluation management and orchestration.
This module provides managers for orchestrating LLM-based evaluations, handling provider selection, fallback mechanisms, and cost optimization for evaluation tasks.
Classes¶
LLMJudgeEngine
¶
Manager for LLM-based evaluation with provider flexibility and fallbacks.
Source code in src/app/judge/llm_evaluation_managers.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
Functions¶
__init__(settings, env_config=None, chat_provider=None, chat_model=None)
¶
Initialize evaluation LLM manager with settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings
|
JudgeSettings instance with tier2 configuration. |
required |
env_config
|
AppEnv | None
|
Application environment configuration. If None, creates default AppEnv(). |
None
|
chat_provider
|
str | None
|
Active chat provider from agent system. Used when tier2_provider=’auto’. |
None
|
chat_model
|
str | None
|
Active chat model from agent system. Inherited when tier2_provider=’auto’ and provider resolves to chat_provider (not fallen back to another provider). |
None
|
Source code in src/app/judge/llm_evaluation_managers.py
assess_constructiveness(review)
async
¶
Assess constructiveness and helpfulness of review.
Source code in src/app/judge/llm_evaluation_managers.py
assess_planning_rationality(execution_trace)
async
¶
Assess quality of agent planning and decision-making.
Source code in src/app/judge/llm_evaluation_managers.py
assess_technical_accuracy(paper, review)
async
¶
Assess technical accuracy of review against paper.
Source code in src/app/judge/llm_evaluation_managers.py
create_judge_agent(assessment_type, use_fallback=False)
async
¶
Create an LLM judge agent for specific assessment type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
assessment_type
|
str
|
Type of assessment (“technical_accuracy”, etc.) |
required |
use_fallback
|
bool
|
Whether to use fallback provider |
False
|
Returns:
| Type | Description |
|---|---|
Agent
|
Configured Agent for evaluation |
Source code in src/app/judge/llm_evaluation_managers.py
evaluate_comprehensive(paper, review, execution_trace)
async
¶
Run comprehensive LLM-based evaluation.
Source code in src/app/judge/llm_evaluation_managers.py
select_available_provider(env_config)
¶
Select available provider with fallback chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_config
|
AppEnv
|
Application environment configuration |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str, str | None] | None
|
Tuple of (provider, model, api_key) if available, None if no providers available. |
Source code in src/app/judge/llm_evaluation_managers.py
Functions¶
app.judge.performance_monitor
¶
Performance monitoring and analytics for evaluation pipeline.
Handles execution statistics, bottleneck detection, performance warnings, and failure tracking for the three-tier evaluation system.
Classes¶
PerformanceMonitor
¶
Performance monitoring and analytics for evaluation pipelines.
Tracks execution times, detects bottlenecks, records failures, and provides performance insights for optimization.
Source code in src/app/judge/performance_monitor.py
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 | |
Functions¶
__init__(performance_targets)
¶
Initialize performance monitor with targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
performance_targets
|
dict[str, float]
|
Dictionary of performance targets (e.g., tier timeouts) |
required |
Source code in src/app/judge/performance_monitor.py
finalize_execution(total_time)
¶
Finalize execution statistics and perform analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
total_time
|
float
|
Total pipeline execution time |
required |
Source code in src/app/judge/performance_monitor.py
get_bottlenecks()
¶
Get detected performance bottlenecks.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of bottleneck information dictionaries |
get_execution_stats()
¶
Get detailed execution statistics from last pipeline run.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with timing and execution details including performance analysis |
Source code in src/app/judge/performance_monitor.py
get_failures()
¶
Get tier failure records.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of tier failure dictionaries |
get_performance_summary()
¶
Get concise performance summary.
Returns:
| Type | Description |
|---|---|
str
|
Performance summary string |
Source code in src/app/judge/performance_monitor.py
get_warnings()
¶
Get performance warnings.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of performance warning dictionaries |
has_performance_issues()
¶
Check if there are any performance issues detected.
Returns:
| Type | Description |
|---|---|
bool
|
True if bottlenecks or warnings were detected |
Source code in src/app/judge/performance_monitor.py
record_fallback_usage(fallback_used)
¶
Record whether fallback strategy was used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fallback_used
|
bool
|
Whether fallback strategy was applied |
required |
Source code in src/app/judge/performance_monitor.py
record_tier_execution(tier, duration)
¶
Record successful tier execution time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tier
|
int
|
Tier number (1, 2, or 3) |
required |
duration
|
float
|
Execution duration in seconds |
required |
Source code in src/app/judge/performance_monitor.py
record_tier_failure(tier, failure_type, execution_time, error_msg)
¶
Record tier failure details for monitoring and analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tier
|
int
|
Tier number that failed (0 for pipeline-level failures) |
required |
failure_type
|
str
|
Type of failure (timeout, error) |
required |
execution_time
|
float
|
Time spent before failure |
required |
error_msg
|
str
|
Error message |
required |
Source code in src/app/judge/performance_monitor.py
app.judge.plugins.base
¶
Base classes for evaluator plugin system.
Defines the EvaluatorPlugin ABC and PluginRegistry for typed, tier-ordered plugin execution with Pydantic models at all boundaries.
Classes¶
EvaluatorPlugin
¶
Bases: ABC
Abstract base class for evaluation plugins.
Each plugin implements a specific evaluation tier (1, 2, or 3) and provides typed input/output using Pydantic models.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique identifier for the plugin |
tier |
int
|
Evaluation tier (1=Traditional, 2=LLM-Judge, 3=Graph) |
Source code in src/app/judge/plugins/base.py
Attributes¶
name
abstractmethod
property
¶
Return unique plugin identifier.
Returns:
| Type | Description |
|---|---|
str
|
Plugin name string |
tier
abstractmethod
property
¶
Return evaluation tier number.
Returns:
| Type | Description |
|---|---|
int
|
Tier number (1, 2, or 3) |
Functions¶
evaluate(input_data, context=None)
abstractmethod
¶
Execute plugin evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BaseModel
|
Typed input data (Pydantic model) |
required |
context
|
dict[str, Any] | None
|
Optional context from previous tier evaluations |
None
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
Evaluation result as Pydantic model (Tier1Result, Tier2Result, or Tier3Result) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input validation fails |
RuntimeError
|
If evaluation execution fails |
Source code in src/app/judge/plugins/base.py
get_context_for_next_tier(result)
abstractmethod
¶
Extract context to pass to next tier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
BaseModel
|
Evaluation result from this tier |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of context data for next tier |
Source code in src/app/judge/plugins/base.py
PluginRegistry
¶
Registry for managing and executing evaluation plugins.
Maintains plugins in tier order and orchestrates sequential execution with context passing between tiers.
Source code in src/app/judge/plugins/base.py
Functions¶
__init__()
¶
execute_all(input_data)
¶
Execute all plugins in tier order with context passing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BaseModel
|
Input data for first plugin |
required |
Returns:
| Type | Description |
|---|---|
list[BaseModel]
|
List of results from each plugin in tier order |
Raises:
| Type | Description |
|---|---|
ValueError
|
If plugin evaluation fails |
RuntimeError
|
If plugin execution fails |
Source code in src/app/judge/plugins/base.py
get_plugin(name)
¶
Retrieve plugin by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Plugin name to retrieve |
required |
Returns:
| Type | Description |
|---|---|
EvaluatorPlugin | None
|
Plugin instance if found, None otherwise |
list_plugins()
¶
List all registered plugins in tier order.
Returns:
| Type | Description |
|---|---|
list[EvaluatorPlugin]
|
List of plugins sorted by tier number |
register(plugin)
¶
Register an evaluation plugin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
EvaluatorPlugin
|
Plugin instance to register |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If plugin with same name already registered |
Source code in src/app/judge/plugins/base.py
app.judge.plugins.graph_metrics
¶
GraphEvaluatorPlugin wrapper for Tier 3 evaluation.
Wraps the existing GraphAnalysisEngine as an EvaluatorPlugin following the adapter pattern with configurable timeout.
Classes¶
GraphEvaluatorPlugin
¶
Bases: EvaluatorPlugin
Adapter wrapping GraphAnalysisEngine as an EvaluatorPlugin.
Provides Tier 3 evaluation using graph-based analysis of agent coordination patterns with configurable timeout from JudgeSettings.
Attributes:
| Name | Type | Description |
|---|---|---|
timeout_seconds |
Maximum execution time for this plugin |
|
_engine |
Underlying GraphAnalysisEngine instance |
|
_settings |
JudgeSettings instance for configuration |
Source code in src/app/judge/plugins/graph_metrics.py
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 | |
Attributes¶
name
property
¶
Return unique plugin identifier.
Returns:
| Type | Description |
|---|---|
str
|
Plugin name string |
tier
property
¶
Return evaluation tier number.
Returns:
| Type | Description |
|---|---|
int
|
Tier 3 (Graph Analysis) |
Functions¶
__init__(timeout_seconds=None)
¶
Initialize plugin with optional timeout override.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_seconds
|
float | None
|
Optional timeout override. If None, uses JudgeSettings default. |
None
|
Source code in src/app/judge/plugins/graph_metrics.py
evaluate(input_data, context=None)
¶
Execute Tier 3 graph-based evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BaseModel
|
Input containing trace_data (GraphTraceData) |
required |
context
|
dict[str, Any] | None
|
Optional context from previous tiers (Tier 1 and Tier 2) |
None
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
Tier3Result with graph analysis metrics |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input validation fails |
RuntimeError
|
If evaluation execution fails |
Source code in src/app/judge/plugins/graph_metrics.py
get_context_for_next_tier(result)
¶
Extract context from Tier 3 results for potential future tiers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
BaseModel
|
Tier3Result from this plugin’s evaluation |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing tier3_overall_score and graph metrics |
Source code in src/app/judge/plugins/graph_metrics.py
app.judge.plugins.llm_judge
¶
LLMJudgePlugin wrapper for Tier 2 evaluation.
Wraps the existing LLMJudgeEngine as an EvaluatorPlugin following the adapter pattern with opt-in Tier 1 context enrichment.
Classes¶
LLMJudgePlugin
¶
Bases: EvaluatorPlugin
Adapter wrapping LLMJudgeEngine as an EvaluatorPlugin.
Provides Tier 2 evaluation using LLM-as-Judge methodology with configurable timeout and optional Tier 1 context enrichment.
Attributes:
| Name | Type | Description |
|---|---|---|
timeout_seconds |
Maximum execution time for this plugin |
|
_engine |
Underlying LLMJudgeEngine instance |
|
_settings |
JudgeSettings instance for configuration |
Source code in src/app/judge/plugins/llm_judge.py
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 | |
Attributes¶
name
property
¶
Return unique plugin identifier.
Returns:
| Type | Description |
|---|---|
str
|
Plugin name string |
tier
property
¶
Return evaluation tier number.
Returns:
| Type | Description |
|---|---|
int
|
Tier 2 (LLM-as-Judge) |
Functions¶
__init__(timeout_seconds=None)
¶
Initialize plugin with optional timeout override.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_seconds
|
float | None
|
Optional timeout override. If None, uses JudgeSettings default. |
None
|
Source code in src/app/judge/plugins/llm_judge.py
evaluate(input_data, context=None)
¶
Execute Tier 2 LLM-as-Judge evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BaseModel
|
Input containing paper, review, execution_trace |
required |
context
|
dict[str, Any] | None
|
Optional context from Tier 1 (for enrichment) |
None
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
Tier2Result with LLM quality assessments |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input validation fails |
RuntimeError
|
If evaluation execution fails |
Source code in src/app/judge/plugins/llm_judge.py
get_context_for_next_tier(result)
¶
Extract context from Tier 2 results for Tier 3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
BaseModel
|
Tier2Result from this plugin’s evaluation |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing tier2_overall_score and quality metrics |
Source code in src/app/judge/plugins/llm_judge.py
app.judge.plugins.traditional
¶
TraditionalMetricsPlugin wrapper for Tier 1 evaluation.
Wraps the existing TraditionalMetricsEngine as an EvaluatorPlugin following the adapter pattern with configurable timeout.
Classes¶
TraditionalMetricsPlugin
¶
Bases: EvaluatorPlugin
Adapter wrapping TraditionalMetricsEngine as an EvaluatorPlugin.
Provides Tier 1 evaluation using lightweight text similarity metrics with configurable timeout from JudgeSettings.
Attributes:
| Name | Type | Description |
|---|---|---|
timeout_seconds |
Maximum execution time for this plugin |
|
_engine |
Underlying TraditionalMetricsEngine instance |
|
_settings |
JudgeSettings instance for configuration |
Source code in src/app/judge/plugins/traditional.py
Attributes¶
name
property
¶
Return unique plugin identifier.
Returns:
| Type | Description |
|---|---|
str
|
Plugin name string |
tier
property
¶
Return evaluation tier number.
Returns:
| Type | Description |
|---|---|
int
|
Tier 1 (Traditional Metrics) |
Functions¶
__init__(timeout_seconds=None)
¶
Initialize plugin with optional timeout override.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_seconds
|
float | None
|
Optional timeout override. If None, uses JudgeSettings default. |
None
|
Source code in src/app/judge/plugins/traditional.py
evaluate(input_data, context=None)
¶
Execute Tier 1 traditional metrics evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BaseModel
|
Input containing agent_output, reference_texts, start_time, end_time |
required |
context
|
dict[str, Any] | None
|
Optional context from previous tiers (unused for Tier 1) |
None
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
Tier1Result with similarity metrics and execution timing |
Raises:
| Type | Description |
|---|---|
ValueError
|
If input validation fails |
RuntimeError
|
If evaluation execution fails |
Source code in src/app/judge/plugins/traditional.py
get_context_for_next_tier(result)
¶
Extract context from Tier 1 results for Tier 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
BaseModel
|
Tier1Result from this plugin’s evaluation |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing tier1_overall_score and similarity metrics |
Source code in src/app/judge/plugins/traditional.py
app.judge.trace_processors
¶
Trace processing infrastructure for local observability.
Provides JSON/JSONL trace storage and processing capabilities for graph-based analysis and agent coordination evaluation.
Classes¶
ProcessedTrace
dataclass
¶
Processed trace with extracted patterns.
Source code in src/app/judge/trace_processors.py
TraceCollector
¶
Collects and stores execution traces for analysis.
Provides local storage capabilities with JSON/JSONL format and SQLite database for structured queries.
Source code in src/app/judge/trace_processors.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | |
Functions¶
__init__(settings)
¶
Initialize trace collector with settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings
|
JudgeSettings instance with observability configuration. |
required |
Source code in src/app/judge/trace_processors.py
end_execution()
¶
End the current execution and process traces.
Returns:
| Type | Description |
|---|---|
ProcessedTrace | None
|
ProcessedTrace object with patterns, or None if no execution active |
Source code in src/app/judge/trace_processors.py
list_executions(limit=50)
¶
List recent execution traces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
Maximum number of executions to return |
50
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of execution metadata dictionaries |
Source code in src/app/judge/trace_processors.py
load_trace(execution_id)
¶
Load a stored trace by execution ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_id
|
str
|
Execution identifier |
required |
Returns:
| Type | Description |
|---|---|
GraphTraceData | None
|
GraphTraceData object or None if not found |
Source code in src/app/judge/trace_processors.py
log_agent_interaction(from_agent, to_agent, interaction_type, data)
¶
Log an agent-to-agent interaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_agent
|
str
|
Source agent identifier |
required |
to_agent
|
str
|
Target agent identifier |
required |
interaction_type
|
str
|
Type of interaction (task_request, result_delivery, etc.) |
required |
data
|
dict[str, Any]
|
Additional interaction data |
required |
Source code in src/app/judge/trace_processors.py
log_coordination_event(manager_agent, event_type, target_agents, data)
¶
Log a coordination event (delegation, synchronization, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manager_agent
|
str
|
Managing agent identifier |
required |
event_type
|
str
|
Type of coordination (delegation, sync, handoff) |
required |
target_agents
|
list[str]
|
List of agents involved |
required |
data
|
dict[str, Any]
|
Additional coordination data |
required |
Source code in src/app/judge/trace_processors.py
log_tool_call(agent_id, tool_name, success, duration, context='')
¶
Log a tool usage event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
Agent making the tool call |
required |
tool_name
|
str
|
Name of the tool used |
required |
success
|
bool
|
Whether the tool call was successful |
required |
duration
|
float
|
Tool execution duration in seconds |
required |
context
|
str
|
Context or purpose of the tool call |
''
|
Source code in src/app/judge/trace_processors.py
start_execution(execution_id)
¶
Start a new execution trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_id
|
str
|
Unique identifier for the execution |
required |
Source code in src/app/judge/trace_processors.py
TraceEvent
dataclass
¶
Individual trace event container.
Source code in src/app/judge/trace_processors.py
TraceProcessor
¶
Processes stored traces for graph-based analysis.
Source code in src/app/judge/trace_processors.py
Functions¶
__init__(collector)
¶
Initialize with a trace collector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collector
|
TraceCollector
|
TraceCollector instance |
required |
process_for_graph_analysis(execution_id)
¶
Process trace data specifically for graph analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_id
|
str
|
Execution to process |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dictionary with graph-ready data structures |
Source code in src/app/judge/trace_processors.py
Functions¶
get_trace_collector(settings=None)
¶
Get or create the global trace collector instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings | None
|
JudgeSettings instance. If None, uses defaults. |
None
|
Returns:
| Type | Description |
|---|---|
TraceCollector
|
TraceCollector instance |
Source code in src/app/judge/trace_processors.py
trace_execution(execution_id)
¶
Decorator for automatic execution tracing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_id
|
str
|
Unique identifier for the execution |
required |
Usage
@trace_execution(“paper_001_evaluation”) def evaluate_paper(): # Execution will be automatically traced pass
Source code in src/app/judge/trace_processors.py
app.judge.traditional_metrics
¶
Traditional metrics implementation for Tier 1 evaluation.
Provides fast, lightweight text similarity and execution metrics using minimal dependencies with <1s performance target.
Classes¶
SimilarityScores
dataclass
¶
Container for similarity metric results.
Source code in src/app/judge/traditional_metrics.py
TraditionalMetricsEngine
¶
Lightweight traditional metrics engine for fast evaluation.
Implements text similarity metrics using minimal computational resources with performance targets under 1 second for typical academic reviews.
Source code in src/app/judge/traditional_metrics.py
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 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
Functions¶
__init__()
¶
Initialize metrics engine with cached components.
Uses lazy loading for computationally expensive components to minimize startup time and memory usage.
Source code in src/app/judge/traditional_metrics.py
assess_task_success(similarity_scores, threshold=0.8)
¶
Assess task completion success with continuous proportional scoring.
Returns a continuous score in [0.0, 1.0] rather than a binary result. When weighted similarity meets or exceeds the threshold, returns 1.0. When below, returns proportional credit (weighted_similarity / threshold). When threshold is 0.0, returns 0.0 to avoid division by zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
similarity_scores
|
SimilarityScores
|
Container with semantic, cosine, jaccard scores |
required |
threshold
|
float
|
Similarity value representing full credit (from config) |
0.8
|
Returns:
| Type | Description |
|---|---|
float
|
Continuous float in [0.0, 1.0]; 1.0 when similarity >= threshold, |
float
|
weighted_similarity / threshold when below, 0.0 when threshold is 0. |
Source code in src/app/judge/traditional_metrics.py
compute_all_similarities(agent_output, reference_text, enhanced=False)
¶
Compute all similarity metrics for a single reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_output
|
str
|
Generated review text |
required |
reference_text
|
str
|
Single ground truth review |
required |
enhanced
|
bool
|
Enable enhanced similarity features (textdistance) |
False
|
Returns:
| Type | Description |
|---|---|
SimilarityScores
|
SimilarityScores container with all computed metrics |
Source code in src/app/judge/traditional_metrics.py
compute_cosine_similarity(text1, text2)
¶
Compute TF-IDF cosine similarity with enhanced error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text1
|
str
|
Agent-generated review text |
required |
text2
|
str
|
Reference review text |
required |
Returns:
| Type | Description |
|---|---|
float
|
Similarity score between 0.0 and 1.0 |
Performance: ~50ms for typical review lengths
Source code in src/app/judge/traditional_metrics.py
compute_jaccard_similarity(text1, text2, enhanced=False)
¶
Compute Jaccard similarity with optional textdistance enhancement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text1
|
str
|
Agent-generated review text |
required |
text2
|
str
|
Reference review text |
required |
enhanced
|
bool
|
Use textdistance library for robust calculation |
False
|
Returns:
| Type | Description |
|---|---|
float
|
Similarity score between 0.0 and 1.0 |
Performance: ~10ms for typical review lengths
Source code in src/app/judge/traditional_metrics.py
compute_levenshtein_similarity(text1, text2)
¶
Compute Levenshtein (edit distance) similarity using textdistance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text1
|
str
|
Agent-generated review text |
required |
text2
|
str
|
Reference review text |
required |
Returns:
| Type | Description |
|---|---|
float
|
Normalized Levenshtein similarity score between 0.0 and 1.0 |
Performance: ~20ms for typical review lengths
Source code in src/app/judge/traditional_metrics.py
compute_semantic_similarity(text1, text2)
¶
Compute semantic similarity using BERTScore with Levenshtein fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text1
|
str
|
Agent-generated review text |
required |
text2
|
str
|
Reference review text |
required |
Returns:
| Type | Description |
|---|---|
float
|
Similarity score between 0.0 and 1.0 |
Performance: ~200ms with BERTScore, ~20ms with Levenshtein fallback
Source code in src/app/judge/traditional_metrics.py
evaluate_enhanced_similarity(agent_output, reference_texts, config_weights=None)
¶
Enhanced multi-metric evaluation with config-driven weighting.
This method provides enhanced similarity evaluation with: - Levenshtein similarity calculation - Config-driven weighting system - Enhanced error fallbacks - Multi-metric weighted combination
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_output
|
str
|
Generated review text |
required |
reference_texts
|
list[str]
|
List of ground truth reviews |
required |
config_weights
|
dict[str, float] | None
|
Optional weight configuration for metrics |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Weighted overall similarity score (0-1) |
Source code in src/app/judge/traditional_metrics.py
evaluate_traditional_metrics(agent_output, reference_texts, start_time, end_time, settings=None)
¶
Complete traditional metrics evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_output
|
str
|
Generated review text |
required |
reference_texts
|
list[str]
|
List of ground truth reviews |
required |
start_time
|
float
|
Execution start timestamp |
required |
end_time
|
float
|
Execution end timestamp |
required |
settings
|
JudgeSettings | None
|
JudgeSettings instance. If None, uses defaults. |
None
|
Returns:
| Type | Description |
|---|---|
Tier1Result
|
Tier1Result with all traditional metrics |
Source code in src/app/judge/traditional_metrics.py
find_best_match(agent_output, reference_texts, enhanced=False)
¶
Find best matching reference and return its similarity scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_output
|
str
|
Generated review text |
required |
reference_texts
|
list[str]
|
List of ground truth reviews |
required |
enhanced
|
bool
|
Enable enhanced similarity features |
False
|
Returns:
| Type | Description |
|---|---|
SimilarityScores
|
Best similarity scores across all reference texts |
Source code in src/app/judge/traditional_metrics.py
measure_execution_time(start_time, end_time)
¶
Calculate execution time with normalization for scoring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
float
|
Start timestamp (from time.perf_counter()) |
required |
end_time
|
float
|
End timestamp (from time.perf_counter()) |
required |
Returns:
| Type | Description |
|---|---|
float
|
Normalized time score for composite scoring (0.0-1.0) |
Source code in src/app/judge/traditional_metrics.py
Functions¶
calculate_cosine_similarity(text1, text2)
¶
Calculate cosine similarity between two texts.
Convenience wrapper for compute_cosine_similarity. Handles empty strings gracefully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text1
|
str
|
First text to compare |
required |
text2
|
str
|
Second text to compare |
required |
Returns:
| Type | Description |
|---|---|
float
|
Cosine similarity score (0-1) |
Source code in src/app/judge/traditional_metrics.py
calculate_jaccard_similarity(text1, text2)
¶
Calculate Jaccard similarity between two texts.
Backward compatibility wrapper for compute_jaccard_similarity with enhanced features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text1
|
str
|
First text to compare |
required |
text2
|
str
|
Second text to compare |
required |
Returns:
| Type | Description |
|---|---|
float
|
Enhanced Jaccard similarity score (0-1) |
Source code in src/app/judge/traditional_metrics.py
create_evaluation_result(paper_id, agent_review, ground_truth_reviews)
¶
Create evaluation result comparing agent review to ground truth.
This function creates comprehensive evaluation results using enhanced similarity evaluation capabilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paper_id
|
str
|
Paper identifier. |
required |
agent_review
|
str
|
Review generated by agent. |
required |
ground_truth_reviews
|
list[PeerReadReview]
|
Original peer reviews. |
required |
Returns:
| Type | Description |
|---|---|
PeerReadEvalResult
|
PeerReadEvalResult with similarity metrics. |
Source code in src/app/judge/traditional_metrics.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
evaluate_review_similarity(agent_review, ground_truth)
¶
Evaluate similarity between agent review and ground truth.
Backward compatibility wrapper for evaluate_enhanced_similarity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_review
|
str
|
Review generated by agent |
required |
ground_truth
|
str
|
Ground truth review text |
required |
Returns:
| Type | Description |
|---|---|
float
|
Weighted similarity score (0-1) |
Source code in src/app/judge/traditional_metrics.py
evaluate_single_enhanced(agent_output, reference_texts, config_weights=None)
¶
Convenience function for enhanced similarity evaluation.
This function provides the PeerRead-style evaluation workflow with Levenshtein similarity, config-driven weights, and enhanced error handling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_output
|
str
|
Generated review text |
required |
reference_texts
|
list[str]
|
List of ground truth reviews |
required |
config_weights
|
dict[str, float] | None
|
Optional weight configuration for similarity metrics |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Weighted overall similarity score (0-1) |
Example
weights = { … “cosine_weight”: 0.6, … “jaccard_weight”: 0.4, … “semantic_weight”: 0.0, … } result = evaluate_single_enhanced( … agent_output=”This paper demonstrates strong methodology…”, … reference_texts=[ … “The work shows solid approach…”, … “Good technical quality…”, … ], … config_weights=weights, … ) print(f”Enhanced similarity: {result:.3f}”)
Source code in src/app/judge/traditional_metrics.py
evaluate_single_traditional(agent_output, reference_texts, settings=None)
¶
Convenience function for single traditional evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_output
|
str
|
Generated review text |
required |
reference_texts
|
list[str]
|
List of ground truth reviews |
required |
settings
|
JudgeSettings | None
|
Optional JudgeSettings override. If None, uses defaults. |
None
|
Returns:
| Type | Description |
|---|---|
Tier1Result
|
Tier1Result with traditional metrics |
Example
result = evaluate_single_traditional( … agent_output=”This paper presents…”, … reference_texts=[“The work demonstrates…”, “Strong contribution…”], … ) print(f”Overall score: {result.overall_score:.3f}”)
Source code in src/app/judge/traditional_metrics.py
app.llms.models
¶
LLM model creation and abstraction.
This module provides pure model creation functionality without business logic. Handles model instantiation for different providers in a unified way.
Classes¶
Functions¶
create_agent_models(endpoint_config, include_researcher=False, include_analyst=False, include_synthesiser=False)
¶
Create models for the system agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint_config
|
EndpointConfig
|
Configuration for the model. |
required |
include_researcher
|
bool
|
Whether to include the researcher model. |
False
|
include_analyst
|
bool
|
Whether to include the analyst model. |
False
|
include_synthesiser
|
bool
|
Whether to include the synthesiser model. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
ModelDict |
ModelDict
|
A dictionary containing compatible models for the system agents. |
Source code in src/app/llms/models.py
create_llm_model(endpoint_config)
¶
Create a model that works with PydanticAI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint_config
|
EndpointConfig
|
Full endpoint configuration including provider, model, key, and URL. |
required |
Returns:
| Type | Description |
|---|---|
Model
|
PydanticAI Model instance. |
Source code in src/app/llms/models.py
create_simple_model(provider, model_name, api_key=None)
¶
Create a simple model for basic usage like evaluation.
Routes to the correct provider backend using the same logic as create_llm_model. Looks up default_base_url from PROVIDER_REGISTRY when no EndpointConfig is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Provider name (e.g., “openai”, “anthropic”, “cerebras”). |
required |
model_name
|
str
|
Model name (e.g., “gpt-4o-mini”, “claude-sonnet-4-20250514”). |
required |
api_key
|
str | None
|
API key (optional, will use environment if not provided). |
None
|
Returns:
| Type | Description |
|---|---|
Model
|
PydanticAI Model instance routed to the correct backend. |
Source code in src/app/llms/models.py
get_llm_model_name(provider, model_name)
¶
Convert provider and model name to required format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Provider name (case-insensitive) |
required |
model_name
|
str
|
Model name to format |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted model name with appropriate provider prefix |
Source code in src/app/llms/models.py
app.llms.providers
¶
LLM provider configuration and API key management.
This module provides pure provider abstraction without business logic. Handles API key retrieval, provider configurations, and environment setup.
Classes¶
Functions¶
get_api_key(provider, chat_env_config)
¶
Retrieve API key from chat env config variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Provider name (case-insensitive) |
required |
chat_env_config
|
AppEnv
|
Application environment configuration |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
Tuple of (success: bool, message: str) where message is either the API key or error message |
Source code in src/app/llms/providers.py
get_provider_config(provider, providers)
¶
Retrieve configuration settings for the specified provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Provider name key used to look up the configuration. |
required |
providers
|
dict[str, ProviderConfig]
|
Mapping of provider name to ProviderConfig instances. |
required |
Returns:
| Type | Description |
|---|---|
ProviderConfig
|
ProviderConfig for the requested provider. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the provider is not found in the providers mapping. |
Exception
|
On unexpected lookup failures. |
Source code in src/app/llms/providers.py
get_supported_providers()
¶
setup_llm_environment(api_keys)
¶
No-op: retained for backward compatibility only.
Previously wrote API keys to os.environ, exposing them to child
processes, crash reporters, and debug dumps (Sprint 5 Finding 10,
Review F1 HIGH). All call sites have been migrated — keys are now
passed directly via provider constructors in models.py.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_keys
|
dict[str, str]
|
Ignored. Dictionary mapping provider names to API keys. |
required |
.. deprecated::
Use provider constructor api_key parameter instead.
This function is scheduled for removal.
Source code in src/app/llms/providers.py
app.reports.report_generator
¶
Report generator for evaluation result summarization.
This module produces structured Markdown reports from CompositeResult objects. Reports include an executive summary, per-tier score breakdown, weakness identification, and actionable suggestions sourced from the SuggestionEngine.
Report structure
- Executive Summary — composite score, recommendation, timestamp
- Tier Score Breakdown — T1/T2/T3 scores with weights
- Weaknesses & Suggestions — severity-ordered list from SuggestionEngine
Example
from app.reports.report_generator import generate_report, save_report md = generate_report(composite_result) save_report(md, Path(“results/reports/latest.md”))
Classes¶
Functions¶
generate_report(result, suggestions=None)
¶
Generate a Markdown report from a CompositeResult.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
CompositeResult
|
Composite evaluation result to report on. |
required |
suggestions
|
list[Suggestion] | None
|
Optional pre-computed suggestion list. When provided, skips the SuggestionEngine and uses these directly. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Markdown-formatted report string. |
Source code in src/app/reports/report_generator.py
save_report(markdown, output_path)
¶
Write a Markdown report string to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
markdown
|
str
|
Report content as a Markdown string. |
required |
output_path
|
Path
|
Destination file path. Parent directories are created automatically if they do not exist. |
required |
Source code in src/app/reports/report_generator.py
app.reports.suggestion_engine
¶
Suggestion engine for generating actionable evaluation improvement suggestions.
This module analyses evaluation results across all three tiers and produces structured, actionable suggestions. It supports a rule-based mode (always available) and an optional LLM-assisted mode for richer recommendations.
Severity mapping
- critical: score < CRITICAL_THRESHOLD (0.2)
- warning: CRITICAL_THRESHOLD <= score < WARNING_THRESHOLD (0.5)
- info: score >= WARNING_THRESHOLD but still worth noting
Example
engine = SuggestionEngine() suggestions = engine.generate(composite_result) for s in suggestions: … print(s.severity, s.metric, s.message)
Classes¶
SuggestionEngine
¶
Generates structured improvement suggestions from evaluation results.
Operates in two modes: - Rule-based (default): Fast, deterministic suggestions from score thresholds. - LLM-assisted (async): Richer suggestions using the judge provider LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
no_llm_suggestions
|
bool
|
When True, disables LLM path even if provider available. |
False
|
Example
engine = SuggestionEngine() suggestions = engine.generate(composite_result) async_suggestions = await engine.generate_async(composite_result)
Source code in src/app/reports/suggestion_engine.py
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 | |
Functions¶
__init__(no_llm_suggestions=False)
¶
Initialize the suggestion engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
no_llm_suggestions
|
bool
|
Disable LLM-assisted suggestions when True. |
False
|
generate(result)
¶
Generate rule-based suggestions from evaluation results.
Analyses metric_scores, tier-level scores, and tiers_enabled to produce actionable suggestions. Tier 2 absence is noted as an info suggestion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
CompositeResult
|
Composite evaluation result to analyse. |
required |
Returns:
| Type | Description |
|---|---|
list[Suggestion]
|
List of Suggestion objects ordered by severity (critical first). |
Source code in src/app/reports/suggestion_engine.py
generate_async(result)
async
¶
Generate suggestions with optional LLM enhancement.
Attempts LLM-assisted suggestions first; falls back to rule-based on error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
CompositeResult
|
Composite evaluation result to analyse. |
required |
Returns:
| Type | Description |
|---|---|
list[Suggestion]
|
List of Suggestion objects, potentially enriched by LLM. |
Source code in src/app/reports/suggestion_engine.py
app.tools.peerread_tools
¶
PeerRead agent tools for multi-agent system integration.
This module provides agent tools that enable the manager agent to interact with the PeerRead dataset for paper retrieval, querying, and review evaluation.
Classes¶
Functions¶
add_peerread_review_tools_to_agent(agent, agent_id='manager', max_content_length=15000)
¶
Add PeerRead review generation and persistence tools to an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent[None, BaseModel]
|
The agent to which review tools will be added. |
required |
agent_id
|
str
|
The agent identifier for tracing (default: “manager”). |
'manager'
|
max_content_length
|
int
|
The maximum number of characters to include in the prompt. |
15000
|
Source code in src/app/tools/peerread_tools.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 | |
add_peerread_review_tools_to_manager(manager_agent, max_content_length=15000)
¶
Backward compatibility wrapper for add_peerread_review_tools_to_agent.
Deprecated: Use add_peerread_review_tools_to_agent instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manager_agent
|
Agent[None, BaseModel]
|
The manager agent to which review tools will be added. |
required |
max_content_length
|
int
|
The maximum number of characters to include in the prompt. |
15000
|
Source code in src/app/tools/peerread_tools.py
add_peerread_tools_to_agent(agent, agent_id='manager')
¶
Add PeerRead dataset tools to an agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent[None, BaseModel]
|
The agent to which PeerRead tools will be added. |
required |
agent_id
|
str
|
The agent identifier for tracing (default: “manager”). |
'manager'
|
Source code in src/app/tools/peerread_tools.py
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 | |
read_paper_pdf(ctx, pdf_path)
¶
Read text content from a PDF file using MarkItDown.
Note: MarkItDown extracts the entire PDF content as a single text block. Page-level extraction is not supported by the underlying library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
RunContext[None] | None
|
RunContext (unused but required for tool compatibility). |
required |
pdf_path
|
str | Path
|
Path to the PDF file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Extracted text content from the entire PDF in Markdown format. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the PDF file doesn’t exist. |
ValueError
|
If the file is not a PDF or conversion fails. |
Source code in src/app/tools/peerread_tools.py
app.utils.artifact_registry
¶
Artifact registry for tracking output paths during CLI runs.
Provides a thread-safe singleton registry where components register file paths they write during execution. At run end, the registry produces a summary block listing all artifacts and their locations.
Example
from app.utils.artifact_registry import get_artifact_registry registry = get_artifact_registry() registry.register(“Log file”, Path(“logs/run.log”)) print(registry.format_summary_block())
Classes¶
ArtifactRegistry
¶
Thread-safe registry for tracking artifact output paths.
Components call register() during execution to record what
files they wrote. At run end, format_summary_block() produces
a human-readable summary for stdout and logging.
Source code in src/app/utils/artifact_registry.py
Functions¶
__init__()
¶
format_summary_block()
¶
Format a human-readable summary block for stdout.
Returns:
| Type | Description |
|---|---|
str
|
Multi-line string with artifact listing, or a |
str
|
“No artifacts written” message if the registry is empty. |
Source code in src/app/utils/artifact_registry.py
register(label, path)
¶
Register an artifact path with a descriptive label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Human-readable category (e.g., “Log file”, “Report”). |
required |
path
|
Path
|
Path to the artifact file or directory. |
required |
Source code in src/app/utils/artifact_registry.py
reset()
¶
summary()
¶
Return all registered artifacts as (label, absolute_path) tuples.
Returns:
| Type | Description |
|---|---|
list[tuple[str, Path]]
|
List of (label, path) tuples in registration order. |
Functions¶
get_artifact_registry()
¶
Get or create the global ArtifactRegistry singleton.
Returns:
| Type | Description |
|---|---|
ArtifactRegistry
|
The global ArtifactRegistry instance. |
Source code in src/app/utils/artifact_registry.py
app.utils.error_messages
¶
Error message utilities for the Agents-eval application.
This module provides concise helper functions for generating standardized error messages related to configuration loading and validation.
Functions¶
api_connection_error(error)
¶
failed_to_load_config(error)
¶
file_not_found(file_path)
¶
generic_exception(error)
¶
get_key_error(error)
¶
invalid_data_model_format(error)
¶
Generate an error message for invalid pydantic data model format.
invalid_json(error)
¶
invalid_type(expected_type, actual_type)
¶
app.utils.load_configs
¶
Configuration loading utilities.
Provides a generic function for loading and validating JSON configuration files against Pydantic models, with error handling and logging support.
Classes¶
LogfireConfig
¶
Bases: BaseModel
Configuration for Logfire + Phoenix tracing integration.
Constructed from JudgeSettings via from_settings(). All values are controlled by JUDGE_LOGFIRE_ and JUDGE_PHOENIX_ env vars through pydantic-settings.
Source code in src/app/config/logfire_config.py
Functions¶
from_settings(settings)
classmethod
¶
Create LogfireConfig from JudgeSettings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
JudgeSettings
|
JudgeSettings instance with logfire fields. |
required |
Returns:
| Type | Description |
|---|---|
LogfireConfig
|
LogfireConfig populated from pydantic-settings. |
Source code in src/app/config/logfire_config.py
Functions¶
load_config(config_path, data_model)
¶
Generic configuration loader that validates against any Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str | Path
|
Path to the JSON configuration file |
required |
data_model
|
type[T]
|
Pydantic model class for validation |
required |
Returns:
| Type | Description |
|---|---|
T
|
Validated configuration instance |
Source code in src/app/utils/load_configs.py
app.utils.load_settings
¶
Utility functions for loading application settings and configuration.
This module provides functions to load and validate application configuration from a JSON file. For environment variables, use AppEnv from app.data_models.app_models.
Classes¶
Functions¶
load_config(config_path)
¶
Load and validate application configuration from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str
|
Path to the JSON configuration file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ChatConfig |
ChatConfig
|
An instance of ChatConfig with validated configuration data. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the configuration file does not exist. |
JSONDecodeError
|
If the file contains invalid JSON. |
Exception
|
For any other unexpected errors during loading or validation. |
Source code in src/app/utils/load_settings.py
app.utils.log
¶
Set up the logger with custom settings. Logs are written to a file with automatic rotation.
Functions¶
app.utils.log_scrubbing
¶
Log scrubbing patterns and sensitive data filtering.
This module provides scrubbing patterns and filters to redact sensitive data from two independent output channels:
- Loguru (file/console logs): Uses
scrub_log_record()filter with the fullSENSITIVE_PATTERNSset, since Loguru has no built-in scrubbing. - Logfire (OTLP trace export): Has built-in default patterns covering password, secret, credential, api_key, jwt, session, cookie, csrf, ssn, credit_card. We only supply extra patterns Logfire doesn’t cover.
Security features: - Pattern-based redaction for common secret types - Loguru filter function for file sink integration - Logfire extra patterns (additive, not duplicating built-in defaults) - Case-insensitive pattern matching
Functions¶
get_logfire_scrubbing_patterns()
¶
Get extra scrubbing patterns for Logfire trace export.
Returns only patterns NOT already covered by Logfire’s built-in defaults.
These are passed to logfire.ScrubbingOptions(extra_patterns=...).
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: List of regex pattern strings for Logfire extra scrubbing. |
Example
import logfire patterns = get_logfire_scrubbing_patterns() logfire.configure(scrubbing=logfire.ScrubbingOptions(extra_patterns=patterns))
Source code in src/app/utils/log_scrubbing.py
scrub_log_record(record)
¶
Scrub sensitive data from Loguru log record.
This function is intended to be used as a Loguru filter. It modifies the log record in-place by replacing sensitive patterns with [REDACTED]. Uses the full SENSITIVE_PATTERNS set since Loguru has no built-in scrubbing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
dict[str, Any]
|
Loguru log record dict with ‘message’ key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Always True to allow the (scrubbed) record to pass through. |
Example
logger.add(“file.log”, filter=scrub_log_record)
Source code in src/app/utils/log_scrubbing.py
app.utils.login
¶
This module provides utility functions for managing login state and initializing the environment for a given project. It includes functionality to load and save login state, perform a one-time login, and check if the user is logged in.
Classes¶
Functions¶
login(project_name, chat_env_config)
¶
Logs in to the workspace and initializes the environment for the given project. Args: project_name (str): The name of the project to initialize. chat_env_config (AppEnv): The application environment configuration containing the API keys. Returns: None
Source code in src/app/utils/login.py
app.utils.paths
¶
Centralized path resolution utilities for the application.
Functions¶
get_app_root()
¶
Get the application root directory (src/app).
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the src/app directory. |
get_config_dir()
¶
Get the application config directory (src/app/config).
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the src/app/config directory. |
get_project_root()
¶
Get the project root directory.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the project root directory. |
get_review_template_path()
¶
Get the path to the review template file.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the REVIEW_PROMPT_TEMPLATE file. |
resolve_app_path(relative_path)
¶
Resolve a path relative to the application root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str
|
Path relative to src/app directory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path resolved from the application root. |
Example
resolve_app_path(“datasets/peerread”) -> /full/path/to/src/app/datasets/peerread
Source code in src/app/utils/paths.py
resolve_config_path(filename)
¶
Resolve a config file path within the config directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Name of the config file (e.g., “config_chat.json”). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the config file. |
Example
resolve_config_path(“config_chat.json”) -> /full/path/to/src/app/config/config_chat.json
Source code in src/app/utils/paths.py
resolve_project_path(relative_path)
¶
Resolve a path relative to the project root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_path
|
str
|
Path relative to the project root directory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path resolved from the project root. |
Source code in src/app/utils/paths.py
app.utils.prompt_sanitization
¶
Prompt input sanitization with length limits and XML delimiter wrapping.
This module provides functions to sanitize user-controlled content before interpolation into LLM prompts. It prevents prompt injection attacks by: 1. Truncating content to configurable length limits 2. Wrapping content in XML delimiters to separate data from instructions 3. Preserving content integrity (no escaping needed for LLM consumption)
Security features: - Length-limited inputs prevent token-based DoS - XML delimiters provide clear instruction/data separation - No format string interpolation vulnerabilities
Functions¶
sanitize_for_prompt(content, max_length, delimiter='content')
¶
Sanitize content for inclusion in LLM prompts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
User-controlled content to sanitize. |
required |
max_length
|
int
|
Maximum content length before truncation. |
required |
delimiter
|
str
|
XML tag name for wrapping (default: “content”). |
'content'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Sanitized content wrapped in XML delimiters, truncated if needed. |
Example
sanitize_for_prompt(“user input”, max_length=100) ‘
user input ‘
Source code in src/app/utils/prompt_sanitization.py
sanitize_paper_abstract(abstract)
¶
Sanitize paper abstract with 5000 character limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
abstract
|
str
|
Paper abstract from PeerRead dataset. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Sanitized abstract wrapped in |
Source code in src/app/utils/prompt_sanitization.py
sanitize_paper_content(content, max_length=50000)
¶
Sanitize paper body content with format string injection protection.
Unlike other sanitize functions, this also escapes curly braces to prevent Python str.format() injection when the content is interpolated into templates. Paper body content is adversary-controlled (raw PDF text) and may contain format string placeholders like {tone} or {0.class}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Paper body content from PDF extraction. |
required |
max_length
|
int
|
Maximum length of the escaped content before truncation (default: 50000). Applied after brace escaping, so the original content may be shorter than max_length when braces are present. |
50000
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Content with braces escaped, wrapped in |
Source code in src/app/utils/prompt_sanitization.py
sanitize_paper_title(title)
¶
Sanitize paper title with 500 character limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Paper title from PeerRead dataset or user input. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Sanitized title wrapped in |
Source code in src/app/utils/prompt_sanitization.py
sanitize_review_text(review)
¶
Sanitize review text with 50000 character limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
review
|
str
|
Generated review text or user input. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Sanitized review wrapped in |
Source code in src/app/utils/prompt_sanitization.py
app.utils.run_context
¶
Per-run output directory management for the application.
Provides RunContext dataclass that owns the per-run output directory structure. Each run creates a timestamped directory under output/runs/ and writes metadata.json.
Classes¶
RunContext
dataclass
¶
Per-run context owning the output directory for a single application run.
Created at the start of each main() invocation after the execution_id is known. Exposes path helpers for standard output files.
Attributes:
| Name | Type | Description |
|---|---|---|
engine_type |
str
|
Engine that produced this run (‘mas’, ‘cc_solo’, ‘cc_teams’). |
paper_id |
str
|
PeerRead paper identifier. |
execution_id |
str
|
Unique execution trace ID. |
start_time |
datetime
|
Datetime when the run started. |
run_dir |
Path
|
Path to the per-run output directory. |
Source code in src/app/utils/run_context.py
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 | |
Attributes¶
evaluation_path
property
¶
Path to the evaluation output file.
Returns:
| Type | Description |
|---|---|
Path
|
evaluation.json in run_dir. |
graph_json_path
property
¶
Path to the agent graph JSON export file.
Returns:
| Type | Description |
|---|---|
Path
|
agent_graph.json in run_dir. |
graph_png_path
property
¶
Path to the agent graph PNG export file.
Returns:
| Type | Description |
|---|---|
Path
|
agent_graph.png in run_dir. |
report_path
property
¶
Path to the report output file.
Returns:
| Type | Description |
|---|---|
Path
|
report.md in run_dir. |
review_path
property
¶
Path to the review output file.
Returns:
| Type | Description |
|---|---|
Path
|
review.json in run_dir. |
stream_path
property
¶
Path to the stream output file.
Returns:
| Type | Description |
|---|---|
Path
|
stream.jsonl for CC engines, stream.json for MAS engine. |
trace_path
property
¶
Path to the trace output file.
Returns:
| Type | Description |
|---|---|
Path
|
trace.json in run_dir. |
Functions¶
create(engine_type, paper_id, execution_id, cli_args=None)
classmethod
¶
Create a RunContext and its output directory.
Creates output/runs/{category}/{ts}{engine}/
and writes metadata.json. Category is }_{exec_id_8mas or cc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_type
|
str
|
Engine identifier (‘mas’, ‘cc_solo’, ‘cc_teams’). |
required |
paper_id
|
str
|
PeerRead paper identifier. |
required |
execution_id
|
str
|
Unique execution trace ID. |
required |
cli_args
|
dict[str, Any] | None
|
Optional CLI arguments dict to persist in metadata. |
None
|
Returns:
| Type | Description |
|---|---|
RunContext
|
RunContext with run_dir created and metadata.json written. |
Source code in src/app/utils/run_context.py
Functions¶
get_active_run_context()
¶
Get the active per-run context, if any.
Returns:
| Type | Description |
|---|---|
RunContext | None
|
The active RunContext, or None if no run is in progress. |
set_active_run_context(ctx)
¶
Set or clear the active per-run context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
RunContext | None
|
RunContext to activate, or None to clear. |
required |
app.utils.url_validation
¶
URL validation and SSRF prevention utilities.
This module provides URL validation functionality to prevent SSRF (Server-Side Request Forgery) attacks by enforcing HTTPS-only and domain allowlisting for all external requests.
CVE Context: - CVE-2026-25580: PydanticAI SSRF vulnerability allowing information disclosure via malicious URLs in message history. This module mitigates the vulnerability by validating all URLs before HTTP requests.
Functions¶
validate_url(url)
¶
Validate URL for SSRF protection.
Enforces HTTPS-only and domain allowlisting to prevent SSRF attacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to validate. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The validated URL if it passes all checks. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If URL fails validation (non-HTTPS, blocked domain, malformed). |
Examples:
>>> validate_url("https://raw.githubusercontent.com/data.json")
'https://raw.githubusercontent.com/data.json'
>>> validate_url("http://evil.com/secrets")
Traceback (most recent call last):
...
ValueError: Only HTTPS URLs allowed
>>> validate_url("https://169.254.169.254/metadata")
Traceback (most recent call last):
...
ValueError: URL domain not allowed: 169.254.169.254
Source code in src/app/utils/url_validation.py
app.utils.utils
¶
This module provides utility functions and context managers for handling configurations, error handling, and setting up agent environments.
Functions:
| Name | Description |
|---|---|
load_config |
str) -> Config: Load and validate configuration from a JSON file. |
print_research_result |
Dict, usage: Usage) -> None: Output structured summary of the research topic. |
error_handling_context |
str, console: Console = None): Context manager for handling errors during operations. |
setup_agent_env |
Config, console: Console = None) -> AgentConfig: Set up the agent environment based on the provided configuration. |
Classes¶
Functions¶
log_research_result(summary, usage)
¶
Prints the research summary and usage details in a formatted manner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary
|
Dict
|
A dictionary containing the research summary with keys ‘topic’, ‘key_points’, ‘key_points_explanation’, and ‘conclusion’. |
required |
usage
|
RunUsage
|
An object containing usage details to be printed. |
required |
Source code in src/app/utils/utils.py
examples._helpers
¶
Shared utilities for example scripts.
Functions¶
print_mas_result(output)
¶
Print MAS example result summary to stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
dict[str, Any] | None
|
Result dict from app.main() with optional ‘composite_result’ key, or None if the run failed. |
required |
Source code in src/examples/_helpers.py
examples.basic_evaluation
¶
Basic evaluation example using the three-tier EvaluationPipeline.
Purpose
Demonstrates the plugin-based evaluation system with realistic paper/review data. Shows how to construct a GraphTraceData trace, configure a pipeline, and interpret the resulting CompositeResult.
Prerequisites
- API key for the Tier 2 LLM provider set in .env (e.g. OPENAI_API_KEY) or run with tiers_enabled=[1, 3] to skip LLM calls entirely.
- No dataset download required: uses synthetic data.
Expected output
Composite score in [0.0, 1.0] and a recommendation string such as “accept”, “weak_accept”, “weak_reject”, or “reject”.
Usage
uv run python src/examples/basic_evaluation.py
Classes¶
Functions¶
run_example()
async
¶
Run a complete three-tier evaluation with synthetic data.
Tier 1 (Traditional Metrics) and Tier 3 (Graph Analysis) run locally. Tier 2 (LLM-as-Judge) requires an API key; set tiers_enabled=[1, 3] in JudgeSettings to skip it without an API key.
Returns:
| Type | Description |
|---|---|
CompositeResult
|
CompositeResult with composite_score and recommendation. |
Source code in src/examples/basic_evaluation.py
examples.cc_solo
¶
CC solo example: run Claude Code in headless solo mode.
Purpose
Demonstrates how to invoke the Claude Code CLI in solo (single-agent) headless mode using run_cc_solo(). Includes a check_cc_available() guard that prints a helpful message if the ‘claude’ CLI is not installed.
Prerequisites
- Claude Code CLI installed and available on PATH (check with
claude --version). - Authenticated Claude Code session (run
claudeinteractively once to log in). - No LLM API keys required: CC uses its own authenticated session.
Expected output
A CCResult with execution_id and output_data from the CC JSON response. The review text extracted from the result is printed to stdout. If ‘claude’ is not on PATH, a helpful installation message is printed and the example exits without error.
Usage
uv run python src/examples/cc_solo.py
Classes¶
Functions¶
run_example()
async
¶
Run Claude Code in solo headless mode for paper review.
Checks CC availability first. If ‘claude’ CLI is missing, prints an installation hint and returns None. Otherwise builds a non-empty query using build_cc_query() and invokes run_cc_solo() with a timeout.
Returns:
| Type | Description |
|---|---|
CCResult | None
|
CCResult with execution_id and output_data, or None if CC unavailable. |
Source code in src/examples/cc_solo.py
examples.cc_teams
¶
CC teams example: run Claude Code in agent-teams orchestration mode.
Purpose
Demonstrates how to invoke Claude Code in teams mode using run_cc_teams(). Teams mode sets CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 so CC can spawn teammate agents for parallel task execution. Includes a check_cc_available() guard that prints a helpful message if ‘claude’ is not on PATH.
Prerequisites
- Claude Code CLI installed and available on PATH (check with
claude --version). - Authenticated Claude Code session (run
claudeinteractively once to log in). - No LLM API keys required: CC uses its own authenticated session.
Expected output
A CCResult with team_artifacts populated from the JSONL stream events. The number of TeamCreate and Task events is printed to stdout. If ‘claude’ is not on PATH, a helpful installation message is printed and the example exits without error.
Usage
uv run python src/examples/cc_teams.py
Classes¶
Functions¶
run_example()
async
¶
Run Claude Code in agent-teams orchestration mode for paper review.
Checks CC availability first. If ‘claude’ CLI is missing, prints an installation hint and returns None. Otherwise builds a teams-mode query using build_cc_query(cc_teams=True) and invokes run_cc_teams() which sets the CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 environment variable.
Returns:
| Type | Description |
|---|---|
CCResult | None
|
CCResult with team_artifacts from stream events, or None if CC unavailable. |
Source code in src/examples/cc_teams.py
examples.engine_comparison
¶
Engine comparison example: MAS vs Claude Code evaluation.
Purpose
Demonstrates how to compare evaluation scores between: - Multi-LLM MAS (PydanticAI agents) - Single-LLM MAS (baseline) - Claude Code headless (optional, requires CC artifacts)
Uses CCTraceAdapter to load CC execution artifacts and feed them into the EvaluationPipeline for apples-to-apples comparison.
Prerequisites
For MAS evaluation: API key in .env (or use tiers_enabled=[1, 3]). For CC comparison: Collect CC artifacts first using the scripts: scripts/collect-cc-traces/collect-cc-solo.sh # solo mode scripts/collect-cc-traces/collect-cc-teams.sh # teams mode Artifacts are stored in ~/.claude/teams/ and ~/.claude/tasks/ during interactive sessions, or parsed from raw_stream.jsonl in headless mode.
Usage
uv run python src/examples/engine_comparison.py
Classes¶
Functions¶
evaluate_mas(trace, label)
async
¶
Run Tier 1 + Tier 3 evaluation for a given execution trace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace
|
GraphTraceData
|
GraphTraceData from MAS execution. |
required |
label
|
str
|
Human-readable label for logging. |
required |
Returns:
| Type | Description |
|---|---|
CompositeResult
|
CompositeResult with composite_score and recommendation. |
Source code in src/examples/engine_comparison.py
load_cc_trace(artifacts_dir)
¶
Load CC execution artifacts into GraphTraceData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artifacts_dir
|
Path
|
Path to CC artifact directory (teams or solo mode). Teams mode: contains config.json with ‘members’ array. Solo mode: contains metadata.json + tool_calls.jsonl. |
required |
Returns:
| Type | Description |
|---|---|
GraphTraceData | None
|
GraphTraceData parsed from artifacts, or None if directory missing. |
Source code in src/examples/engine_comparison.py
run_example()
async
¶
Compare MAS multi-agent, MAS single-agent, and optionally CC evaluation scores.
Returns:
| Type | Description |
|---|---|
dict[str, CompositeResult]
|
Dict mapping engine label to CompositeResult. |
Source code in src/examples/engine_comparison.py
examples.judge_settings_customization
¶
JudgeSettings customization example.
Purpose
Demonstrates how to configure the evaluation pipeline via JudgeSettings: - Environment variable overrides (JUDGE_ prefix) - Programmatic settings modification - Timeout adjustment, tier selection, provider configuration
Prerequisites
None — JudgeSettings is pure Python/Pydantic, no API keys required.
Environment variable override pattern
All settings can be overridden via JUDGE_
JUDGE_TIER2_PROVIDER=anthropic
JUDGE_TIER1_MAX_SECONDS=2.0
JUDGE_TIERS_ENABLED=[1,3]
Pydantic-settings reads these automatically when JudgeSettings() is created.
Usage
uv run python src/examples/judge_settings_customization.py
Classes¶
Functions¶
example_composite_thresholds()
¶
Adjust composite score thresholds for stricter evaluation.
Returns:
| Type | Description |
|---|---|
JudgeSettings
|
JudgeSettings with raised acceptance thresholds. |
Source code in src/examples/judge_settings_customization.py
example_provider_selection()
¶
Switch the Tier 2 LLM judge to a specific provider.
Returns:
| Type | Description |
|---|---|
JudgeSettings
|
JudgeSettings configured for Anthropic as Tier 2 provider. |
Source code in src/examples/judge_settings_customization.py
example_tier_selection()
¶
Enable only Tier 1 and Tier 3 (no LLM calls, no API key needed).
Returns:
| Type | Description |
|---|---|
JudgeSettings
|
JudgeSettings with Tier 2 disabled. |
Source code in src/examples/judge_settings_customization.py
example_timeout_adjustment()
¶
Adjust tier timeouts for slower or faster environments.
Returns:
| Type | Description |
|---|---|
JudgeSettings
|
JudgeSettings with increased timeouts suitable for larger models. |
Source code in src/examples/judge_settings_customization.py
examples.mas_multi_agent
¶
MAS multi-agent example: full 4-agent delegation via app.main().
Purpose
Demonstrates the full MAS execution mode where the manager agent delegates tasks to all three sub-agents: researcher, analyst, and synthesiser. All include_* flags are True, enabling the complete multi-agent review workflow.
Prerequisites
- API key for the default LLM provider set in .env (e.g. OPENAI_API_KEY)
- PeerRead sample dataset downloaded (run
make app_quickstartormake setup_datasetto fetch samples).
Expected output
A ReviewGenerationResult from the full 4-agent pipeline (manager + researcher + analyst + synthesiser) for paper ‘1105.1072’. The composite evaluation score and recommendation are printed to stdout.
Usage
uv run python src/examples/mas_multi_agent.py
Functions¶
run_example()
async
¶
Run the MAS pipeline in full multi-agent mode (4 agents).
Uses app.main() with all include_* flags set to True so that the manager delegates research, analysis, and synthesis to specialist sub-agents. The researcher agent is equipped with DuckDuckGo search and PeerRead tools.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dictionary with ‘composite_result’ and ‘graph’ keys, or None if the |
dict[str, Any] | None
|
run fails (e.g. missing dataset, API key not set). |
Source code in src/examples/mas_multi_agent.py
examples.mas_single_agent
¶
MAS single-agent example: manager-only mode via app.main().
Purpose
Demonstrates the minimal MAS execution mode where the manager agent handles the entire review workflow without delegating to sub-agents (researcher, analyst, synthesiser). All include_* flags are False.
Prerequisites
- API key for the default LLM provider set in .env (e.g. OPENAI_API_KEY)
- PeerRead sample dataset downloaded (run
make app_quickstartormake setup_datasetto fetch samples).
Expected output
A ReviewGenerationResult or ResearchResult from the manager agent with a structured peer review for paper ‘1105.1072’. The result is printed to stdout after the evaluation pipeline completes.
Usage
uv run python src/examples/mas_single_agent.py
Functions¶
run_example()
async
¶
Run the MAS pipeline in manager-only (single-agent) mode.
Uses app.main() with all include_* flags set to False so that the manager agent processes the full review workflow without delegation to sub-agents. Tier 2 (LLM judge) is skipped to avoid requiring a second API key.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Dictionary with ‘composite_result’ and ‘graph’ keys, or None if the |
dict[str, Any] | None
|
run fails (e.g. missing dataset, API key not set). |
Source code in src/examples/mas_single_agent.py
examples.sweep_benchmark
¶
Sweep benchmark example: SweepRunner with SweepConfig.
Purpose
Demonstrates how to configure and run a composition sweep using SweepRunner and SweepConfig. A sweep evaluates multiple agent compositions across one or more papers and repetitions for statistical comparison of results.
Prerequisites
- API key for the default LLM provider set in .env (e.g. OPENAI_API_KEY)
- PeerRead sample dataset downloaded (run
make app_quickstartormake setup_datasetto fetch samples).
Expected output
SweepRunner executes each composition (manager-only, researcher-only, full 3-agent) on paper ‘1105.1072’ for 1 repetition and prints a summary table of composite scores per composition. Output is written to a temporary directory that is removed after the example completes.
Usage
uv run python src/examples/sweep_benchmark.py
Classes¶
Functions¶
run_example()
async
¶
Run the sweep benchmark with 3 compositions, 1 paper, 1 repetition.
Results are written to a temporary directory that is cleaned up after the example completes.
Returns:
| Type | Description |
|---|---|
list[tuple[AgentComposition, CompositeResult]]
|
List of (AgentComposition, CompositeResult) tuples from the sweep. |
Source code in src/examples/sweep_benchmark.py
gui.components.footer
¶
gui.components.header
¶
gui.components.output
¶
Output rendering component with type-aware dispatch.
Renders results using appropriate Streamlit widgets based on the result type: st.json() for dicts and Pydantic models, st.markdown() for strings, and st.write() as a fallback.
Functions¶
render_output(result=None, info_str=None, output_type=None)
¶
Renders output using type-appropriate Streamlit widgets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
The content to be displayed. Dispatches to st.json() for dicts/Pydantic models, st.markdown() for strings, st.write() for other types. |
None
|
info_str
|
str
|
Info message displayed when result is None/falsy. |
None
|
output_type
|
str
|
The type hint for the result content. |
None
|
Source code in src/gui/components/output.py
gui.components.prompts
¶
Functions¶
render_prompt_editor(prompt_name, prompt_value, height=150)
¶
Render a read-only prompt text area for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_name
|
str
|
Snake_case prompt key used to generate the label. |
required |
prompt_value
|
str
|
Current prompt text content. |
required |
height
|
int
|
Text area height in pixels. |
150
|
Returns:
| Type | Description |
|---|---|
str | None
|
The displayed prompt value (always unchanged since field is read-only). |
Source code in src/gui/components/prompts.py
gui.components.sidebar
¶
Functions¶
render_sidebar(sidebar_title, execution_state='idle')
¶
Render sidebar with page navigation, Phoenix trace link, and execution indicator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sidebar_title
|
str
|
Title to display in the sidebar. |
required |
execution_state
|
str
|
Current execution state — ‘idle’, ‘running’, ‘completed’, or ‘error’. When ‘running’, an in-progress indicator is shown at the top of the sidebar. |
'idle'
|
Returns:
| Type | Description |
|---|---|
str
|
Selected page name from the radio button selection. |
Source code in src/gui/components/sidebar.py
gui.config.config
¶
GUI configuration constants and environment-aware URL resolution.
Functions¶
resolve_service_url(port)
¶
Resolve a service URL for the given port based on the current environment.
Detection chain (first match wins):
1. PHOENIX_ENDPOINT env var — explicit user override
2. GitHub Codespaces — CODESPACE_NAME + GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN
3. Gitpod — GITPOD_WORKSPACE_URL
4. Fallback — http://localhost:{port}
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
int
|
The port number the service listens on. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A fully-qualified URL for the service appropriate to the environment. |
Example
url = resolve_service_url(6006) url.startswith(“http”) True
Source code in src/gui/config/config.py
gui.config.styling
¶
GUI theming utilities.
Provides helper functions that read the active Streamlit theme (light or dark) and return colors for custom elements such as the Pyvis agent graph.
Theme colors are defined in .streamlit/config.toml via the native
[theme.dark] and [theme.light] sections. Users switch themes through
Streamlit’s built-in Settings menu (hamburger icon → Settings → Theme).
The THEMES dict below mirrors those config values so that non-Streamlit
components (Pyvis, custom HTML) can access the palette at runtime.
Functions¶
add_custom_styling(page_title)
¶
Configure the Streamlit page layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_title
|
str
|
Title shown in the browser tab. |
required |
Source code in src/gui/config/styling.py
get_active_theme()
¶
Get the active theme dict based on Streamlit’s current mode.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
dict[str, str]: Theme color mapping with keys like |
Source code in src/gui/config/styling.py
get_active_theme_name()
¶
Get the name of the currently active theme.
Detects Streamlit’s active theme (light or dark) and returns the
corresponding theme name from :data:THEMES.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Theme name string ( |
Source code in src/gui/config/styling.py
get_graph_font_color()
¶
Get the font color for Pyvis graph labels based on active theme.
Returns "#000000" for light themes (>= 4.5:1 contrast on light bg)
and "#ECEFF4" for dark themes (>= 4.5:1 contrast on dark bg).
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Hex color string for graph label text. |
Source code in src/gui/config/styling.py
get_graph_node_colors()
¶
Get node colors for agent graph from the active theme.
Alias for :func:get_theme_node_colors used by agent_graph.py.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: |
Source code in src/gui/config/styling.py
get_theme_bgcolor()
¶
Get the background color from the active theme dict.
Reads backgroundColor from the active theme in :data:THEMES.
Falls back to Streamlit’s theme.backgroundColor option, then
to "#ffffff" as a last resort.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Hex color string for the theme background. |
Source code in src/gui/config/styling.py
get_theme_node_colors()
¶
Get node colors for agent graph from the active theme.
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: |
Source code in src/gui/config/styling.py
is_light_theme(theme_name)
¶
Check whether a theme name refers to a light theme.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme_name
|
str
|
Name of the theme to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the theme is a light theme, False otherwise. |
Source code in src/gui/config/styling.py
gui.config.text
¶
gui.pages.agent_graph
¶
Streamlit page for Agent Graph visualization.
Renders NetworkX agent interaction graphs as interactive Pyvis visualizations. Displays agent-to-agent delegations and tool usage patterns with visual distinction between agent nodes and tool nodes.
Functions¶
render_agent_graph(graph=None, composite_result=None)
¶
Render agent interaction graph as interactive Pyvis visualization.
Displays: - Agent nodes (distinguished visually from tool nodes) - Tool nodes - Interaction edges (delegations, tool calls) - Interactive pan/zoom/hover features
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
DiGraph[str] | None
|
NetworkX DiGraph with agent and tool nodes, or None for empty state. |
None
|
composite_result
|
Any | None
|
Optional CompositeResult for mode-specific empty messages. |
None
|
Source code in src/gui/pages/agent_graph.py
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 | |
gui.pages.evaluation
¶
Streamlit page for Evaluation Results visualization.
Displays three-tier evaluation results including traditional metrics (Tier 1), LLM-as-Judge scores (Tier 2), and graph analysis metrics (Tier 3). Provides comparative visualization of graph-based vs text-based metrics.
Classes¶
Functions¶
format_metric_label(metric_key)
¶
Return a human-readable label for a metric key.
Falls back to title-casing the key when no explicit mapping exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric_key
|
str
|
Snake-case metric name (e.g. “cosine_score”). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Human-readable label string (e.g. “Cosine Similarity”). |
Source code in src/gui/pages/evaluation.py
render_baseline_comparison(comparisons)
¶
Render baseline comparison section for Claude Code solo and teams.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comparisons
|
list[BaselineComparison] | None
|
List of BaselineComparison instances or None. |
required |
Source code in src/gui/pages/evaluation.py
render_evaluation(result=None)
¶
Render evaluation results page with tier scores and metric comparisons.
Displays: - Overall composite score and recommendation - Individual tier scores (Tier 1, 2, 3) - Bar chart comparing graph metrics vs text metrics - Detailed metric breakdowns - Baseline comparisons (if available in session state)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
CompositeResult | None
|
CompositeResult containing evaluation data, or None for empty state. |
None
|
Source code in src/gui/pages/evaluation.py
gui.pages.home
¶
gui.pages.prompts
¶
Streamlit component for displaying agent system prompts.
This module provides a function to display prompt configurations for agent roles using a Streamlit-based UI. Loads prompts directly from ChatConfig without hardcoded fallbacks (DRY principle).
Classes¶
Functions¶
render_prompts(chat_config)
¶
Render and edit the prompt configuration for agent roles in the Streamlit UI.
Loads prompts directly from ChatConfig.prompts without hardcoded fallbacks. Follows DRY principle with config_chat.json as single source of truth.
Source code in src/gui/pages/prompts.py
gui.pages.run_app
¶
Streamlit interface for running the agentic system interactively.
This module defines the render_app function, which provides a Streamlit-based UI for users to select a provider, enter a query, and execute the main agent workflow. Results and errors are displayed in real time, supporting asynchronous execution.
Provider and sub-agent configuration are read from session state, allowing users to configure these settings on the Settings page before running queries.
Background execution support allows queries to continue running even when users navigate to other tabs, with results persisted in session state.
Input mode supports both free-form text queries and paper selection from downloaded PeerRead papers via a dropdown with abstract preview.
Classes¶
Functions¶
render_app(provider=None, chat_config_file=None)
async
¶
Render the main app interface for running agentic queries via Streamlit.
Displays input fields for provider and query, a button to trigger execution, and an area for output or error messages. Handles async invocation of the main agent workflow and logs any exceptions.
Provider and sub-agent configuration are read from session state (configured on the Settings page). Execution runs in background with results persisted to session state, allowing navigation across tabs without losing progress.
Engine selection (MAS or Claude Code) is per-run via a radio widget and stored in session state. When CC is selected, MAS-specific controls are disabled and CC availability is checked.
Source code in src/gui/pages/run_app.py
gui.pages.settings
¶
Streamlit settings UI for displaying and editing application settings.
This module provides a function to display and edit settings from pydantic-settings classes (CommonSettings and JudgeSettings). Settings are editable via the GUI and applied to the current session via st.session_state.
Also provides UI controls for chat provider selection and sub-agent configuration with session state persistence.
Classes¶
Functions¶
render_settings(common_settings, judge_settings)
¶
Render application settings in the Streamlit UI.
Displays actual default values from CommonSettings and JudgeSettings pydantic-settings classes. Read-only display using Streamlit expanders to organize settings by category.
Also provides UI controls for chat provider selection and sub-agent configuration with session state persistence across page navigation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
common_settings
|
CommonSettings
|
CommonSettings instance with application-level configuration |
required |
judge_settings
|
JudgeSettings
|
JudgeSettings instance with evaluation pipeline configuration |
required |
Source code in src/gui/pages/settings.py
gui.pages.trace_viewer
¶
Streamlit page for browsing trace execution data.
Reads traces.db (SQLite) directly via the built-in sqlite3 module. Displays an executions overview table with drill-down to individual trace events for a selected execution.
Functions¶
render_trace_viewer()
¶
Render the Trace Viewer page.
Displays: - Executions overview table from traces.db - Drill-down event table when an execution is selected
Source code in src/gui/pages/trace_viewer.py
gui.utils.log_capture
¶
Log capture utility for GUI debug panel.
This module provides a loguru sink that captures log entries from app.* modules during execution and stores them in memory for display in the Streamlit debug panel. Supports thread-safe incremental polling via get_new_logs_since() for real-time streaming.
Classes¶
LogCapture
¶
Captures and formats log entries for the debug panel.
This class acts as a loguru sink that filters and stores log entries from app.* modules. It provides methods to retrieve, clear, and format logs for display in the Streamlit UI.
Thread safety: _buffer and _lock allow safe concurrent access from a worker thread (writes via add_log_entry) and the Streamlit render thread (reads via get_new_logs_since / get_logs).
Source code in src/gui/utils/log_capture.py
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 | |
Functions¶
__init__()
¶
add_log_entry(timestamp, level, module, message)
¶
Add a log entry to the buffer if it’s from an app.* module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp
|
str
|
ISO format timestamp string |
required |
level
|
str
|
Log level (INFO, WARNING, ERROR, etc.) |
required |
module
|
str
|
Module name that generated the log |
required |
message
|
str
|
Log message content |
required |
Source code in src/gui/utils/log_capture.py
attach_to_logger()
¶
Attach this capture instance as a loguru sink.
Returns:
| Type | Description |
|---|---|
int
|
Handler ID for later removal |
clear()
¶
detach_from_logger(handler_id)
¶
Detach this capture instance from loguru.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler_id
|
int
|
Handler ID returned by attach_to_logger |
required |
format_html()
¶
Format log entries as HTML with color-coded levels.
Returns:
| Type | Description |
|---|---|
str
|
HTML string with styled log entries |
format_logs_as_html(logs)
staticmethod
¶
Format a list of log entries as HTML with color-coded levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs
|
list[dict[str, str]]
|
List of log entry dictionaries |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML string with styled log entries |
Source code in src/gui/utils/log_capture.py
get_logs()
¶
Retrieve all captured log entries.
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
List of log entry dictionaries |
get_new_logs_since(index)
¶
Return log entries added since the given index (for incremental polling).
The caller tracks the last-seen index and passes it on each poll. Only entries at positions >= index are returned, allowing a Streamlit fragment or polling loop to render only new content on each re-run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Number of entries already seen (0 = return all entries) |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
List of new log entry dictionaries since index |
Source code in src/gui/utils/log_capture.py
log_count()
¶
Return the current number of buffered log entries.
Returns:
| Type | Description |
|---|---|
int
|
Number of entries in the buffer |
run_cli
¶
Lightweight CLI wrapper for the Agents-eval application.
This wrapper handles help and basic argument parsing quickly without loading heavy dependencies. It only imports the main application when actual processing is needed.
Functions¶
cli_main()
¶
Run the CLI application entry point.
Parses arguments, selects the execution engine, runs the pipeline, and logs the artifact summary.
Source code in src/run_cli.py
parse_args(argv)
¶
Parse command line arguments into a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
argv
|
list[str]
|
List of CLI argument strings (without the program name). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of explicitly-provided arguments (plus engine default). |
Example
parse_args([“–chat-provider”, “ollama”, “–include-researcher”])
Source code in src/run_cli.py
run_gui
¶
This module sets up and runs a Streamlit application for a Multi-Agent System.
The application uses a sidebar tab layout with five navigation sections: - Run Research App: execution controls (provider, engine, paper, query, run button) - Settings: configuration options for provider and sub-agents - Evaluation Results: evaluation results and baseline comparison - Agent Graph: visual representation of agent interactions - Trace Viewer: SQLite browser for traces.db execution data
The main function loads the configuration, renders the UI components, and handles the execution of the Multi-Agent System based on user input.
Functions: - main(): Main function to set up and run the Streamlit application.
Classes¶
Functions¶
get_session_state_defaults()
¶
Get default values for session state.
Returns:
| Type | Description |
|---|---|
dict[str, str | bool]
|
Dict with default provider and sub-agent configuration flags |
Source code in src/run_gui.py
initialize_session_state()
¶
Initialize session state with default values if not already set.
Uses st.session_state to persist user selections across page navigation.
Source code in src/run_gui.py
run_sweep
¶
CLI entry point for MAS composition sweep.
Run automated benchmarking across multiple agent compositions with statistical analysis of results.
Classes¶
Functions¶
main()
¶
Synchronous main entry point.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Exit code (0 for success, 1 for error). |
main_async()
async
¶
Async main entry point.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Exit code (0 for success, 1 for error). |
Source code in src/run_sweep.py
parse_args()
¶
Parse command line arguments.
Returns:
| Type | Description |
|---|---|
Namespace
|
argparse.Namespace: Parsed arguments. |