Merge pull request #260 from DragonFSKY/fix/consensus-model-context-issue

fix: resolve consensus tool model_context parameter missing issue
This commit is contained in:
Beehive Innovations
2025-10-01 19:27:47 +04:00
committed by GitHub
2 changed files with 80 additions and 4 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
@@ -521,10 +520,16 @@ of the evidence, even when it strongly points in one direction.""",
async def _consult_model(self, model_config: dict, request) -> dict:
"""Consult a single model and return its response."""
try:
# Import and create ModelContext once at the beginning
from utils.model_context import ModelContext
# Get the provider for this model
model_name = model_config["model"]
provider = self.get_model_provider(model_name)
# Create model context once and reuse for both file processing and temperature validation
model_context = ModelContext(model_name=model_name)
# Prepare the prompt with any relevant files
# Use continuation_id=None for blinded consensus - each model should only see
# original prompt + files, not conversation history or other model responses
@@ -536,6 +541,7 @@ of the evidence, even when it strongly points in one direction.""",
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 ==="
@@ -545,9 +551,6 @@ of the evidence, even when it strongly points in one direction.""",
stance_prompt = model_config.get("stance_prompt")
system_prompt = self._get_stance_enhanced_prompt(stance, stance_prompt)
# Get model context for temperature validation
model_context = ModelContext(model_name=model_name)
# Validate temperature against model constraints (respects supports_temperature)
validated_temperature, temp_warnings = self.validate_and_correct_temperature(
self.get_default_temperature(), model_context