From 64f10f861044affac2ce750b9c1b90cd97ed4245 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 30 Oct 2025 21:53:05 +0000 Subject: [PATCH] Refactor: Allow MCP config path to be passed to AgentRolloutProcessor Co-authored-by: dhuang --- .../pytest/default_agent_rollout_processor.py | 13 ++++++++++++- tests/pytest/test_pytest_mcp_url.py | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/eval_protocol/pytest/default_agent_rollout_processor.py b/eval_protocol/pytest/default_agent_rollout_processor.py index 997d229a..c17d3b12 100644 --- a/eval_protocol/pytest/default_agent_rollout_processor.py +++ b/eval_protocol/pytest/default_agent_rollout_processor.py @@ -234,10 +234,21 @@ def _format_tool_message_content( class AgentRolloutProcessor(RolloutProcessor): """Agent rollout processor for tool-calling agents.""" + def __init__(self, mcp_config_path: Optional[str] = None): + """Initialize the agent rollout processor. + + Args: + mcp_config_path: Path to MCP configuration file. If provided, this takes + precedence over config.mcp_config_path in __call__. + """ + self.mcp_config_path = mcp_config_path + def __call__(self, rows: List[EvaluationRow], config: RolloutProcessorConfig) -> List[asyncio.Task[EvaluationRow]]: """Create agent rollout tasks and return them for external handling.""" semaphore = config.semaphore + # Use instance mcp_config_path if provided, otherwise fall back to config + mcp_config_path = self.mcp_config_path if self.mcp_config_path is not None else config.mcp_config_path async def process_row(row: EvaluationRow) -> EvaluationRow: """Process a single row with agent rollout.""" @@ -246,7 +257,7 @@ async def process_row(row: EvaluationRow) -> EvaluationRow: agent = Agent( model=row.input_metadata.completion_params["model"], row=row, - config_path=config.mcp_config_path, + config_path=mcp_config_path, logger=config.logger, ) try: diff --git a/tests/pytest/test_pytest_mcp_url.py b/tests/pytest/test_pytest_mcp_url.py index c8063492..80548190 100644 --- a/tests/pytest/test_pytest_mcp_url.py +++ b/tests/pytest/test_pytest_mcp_url.py @@ -20,10 +20,9 @@ ] ] ], - rollout_processor=AgentRolloutProcessor(), + rollout_processor=AgentRolloutProcessor(mcp_config_path="tests/pytest/mcp_configurations/docs_mcp_config.json"), completion_params=[{"model": "fireworks_ai/accounts/fireworks/models/kimi-k2-instruct"}], mode="pointwise", - mcp_config_path="tests/pytest/mcp_configurations/docs_mcp_config.json", ) def test_pytest_mcp_url(row: EvaluationRow) -> EvaluationRow: """Run math evaluation on sample dataset using pytest interface."""