fix: resolve consensus tool model_context parameter missing issue

Fixed runtime bug where _prepare_file_content_for_prompt was called
without required model_context parameter, causing RuntimeError when
processing requests with relevant_files.

- Create ModelContext instance with model_name in _consult_model method
- Pass model_context parameter to _prepare_file_content_for_prompt call
- Add comprehensive regression test to prevent future occurrences
- Maintain consensus tool's blinded design with independent model contexts
This commit is contained in:
谢栋梁
2025-09-03 10:55:22 +08:00
parent 12090646ee
commit 9044b63809
2 changed files with 81 additions and 1 deletions

View File

@@ -29,7 +29,6 @@ from mcp.types import TextContent
from config import TEMPERATURE_ANALYTICAL
from systemprompts import CONSENSUS_PROMPT
from tools.shared.base_models import WorkflowRequest
from utils.model_context import ModelContext
from .workflow.base import WorkflowTool
@@ -534,10 +533,18 @@ of the evidence, even when it strongly points in one direction.""",
# Steps 2+ contain summaries/notes that must NEVER be sent to other models
prompt = self.original_proposal if self.original_proposal else self.initial_prompt
if request.relevant_files:
# Create a model context for token allocation
from utils.model_context import ModelContext
model_context = ModelContext(
model_name=model_name,
)
file_content, _ = self._prepare_file_content_for_prompt(
request.relevant_files,
None, # Use None instead of request.continuation_id for blinded consensus
"Context files",
model_context=model_context,
)
if file_content:
prompt = f"{prompt}\n\n=== CONTEXT FILES ===\n{file_content}\n=== END CONTEXT ==="