feat: refactored and tweaked model descriptions / schema to use fewer tokens at launch (average reduction per field description: 60-80%) without sacrificing tool effectiveness

Disabled secondary tools by default (for new installations), updated README.md with instructions on how to enable these in .env
run-server.sh now displays disabled / enabled tools (when DISABLED_TOOLS is set)
This commit is contained in:
Fahad
2025-08-22 09:23:59 +04:00
parent 6921616db3
commit 4b202f5d1d
31 changed files with 409 additions and 609 deletions

View File

@@ -34,68 +34,47 @@ class ThinkDeepWorkflowRequest(WorkflowRequest):
"""Request model for thinkdeep workflow tool with comprehensive investigation capabilities"""
# Core workflow parameters
step: str = Field(description="Current work step content and findings from your overall work")
step_number: int = Field(description="Current step number in the work sequence (starts at 1)", ge=1)
total_steps: int = Field(description="Estimated total steps needed to complete the work", ge=1)
next_step_required: bool = Field(description="Whether another work step is needed after this one")
step: str = Field(description="Current work step content and findings")
step_number: int = Field(description="Current step number (starts at 1)", ge=1)
total_steps: int = Field(description="Estimated total steps needed", ge=1)
next_step_required: bool = Field(description="Whether another step is needed")
findings: str = Field(
description="Summarize everything discovered in this step about the problem/goal. Include new insights, "
"connections made, implications considered, alternative approaches, potential issues identified, "
"and evidence from thinking. Be specific and avoid vague language—document what you now know "
"and how it affects your hypothesis or understanding. IMPORTANT: If you find compelling evidence "
"that contradicts earlier assumptions, document this clearly. In later steps, confirm or update "
"past findings with additional reasoning."
description="Discoveries: insights, connections, implications, evidence. "
"Document contradictions to earlier assumptions. Update past findings."
)
# Investigation tracking
files_checked: list[str] = Field(
default_factory=list,
description="List all files (as absolute paths) examined during the investigation so far. "
"Include even files ruled out or found unrelated, as this tracks your exploration path.",
description="All files examined (absolute paths). Include ruled-out files.",
)
relevant_files: list[str] = Field(
default_factory=list,
description="Subset of files_checked (as full absolute paths) that contain information directly "
"relevant to the problem or goal. Only list those directly tied to the root cause, "
"solution, or key insights. This could include the source of the issue, documentation "
"that explains the expected behavior, configuration files that affect the outcome, or "
"examples that illustrate the concept being analyzed.",
description="Files relevant to problem/goal (absolute paths). Include root cause, solution, key insights.",
)
relevant_context: list[str] = Field(
default_factory=list,
description="Key concepts, methods, or principles that are central to the thinking analysis, "
"in the format 'concept_name' or 'ClassName.methodName'. Focus on those that drive "
"the core insights, represent critical decision points, or define the scope of the analysis.",
description="Key concepts/methods: 'concept_name' or 'ClassName.methodName'. Focus on core insights, decision points.",
)
hypothesis: Optional[str] = Field(
default=None,
description="Current theory or understanding about the problem/goal based on evidence gathered. "
"This should be a concrete theory that can be validated or refined through further analysis. "
"You are encouraged to revise or abandon hypotheses in later steps based on new evidence.",
description="Current theory based on evidence. Revise in later steps.",
)
# Analysis metadata
issues_found: list[dict] = Field(
default_factory=list,
description="Issues identified during work with severity levels - each as a dict with "
"'severity' (critical, high, medium, low) and 'description' fields.",
description="Issues with dict: 'severity' (critical/high/medium/low), 'description'.",
)
confidence: str = Field(
default="low",
description="Indicate your current confidence in the analysis. Use: 'exploring' (starting analysis), "
"'low' (early thinking), 'medium' (some insights gained), 'high' (strong understanding), "
"'very_high' (very strong understanding), 'almost_certain' (nearly complete analysis), "
"'certain' (100% confidence - analysis is complete and conclusions are definitive with no need for external model validation). "
"Do NOT use 'certain' unless the thinking is comprehensively complete, use 'very_high' or 'almost_certain' instead when in doubt. "
"Using 'certain' means you have complete confidence locally and prevents external model validation.",
description="exploring/low/medium/high/very_high/almost_certain/certain. CRITICAL: 'certain' PREVENTS external validation.",
)
# Advanced workflow features
backtrack_from_step: Optional[int] = Field(
default=None,
description="If an earlier finding or hypothesis needs to be revised or discarded, "
"specify the step number from which to start over. Use this to acknowledge analytical "
"dead ends and correct the course.",
description="Step number to backtrack from if revision needed.",
ge=1,
)
@@ -103,30 +82,27 @@ class ThinkDeepWorkflowRequest(WorkflowRequest):
# in expert analysis (commented out exclude=True)
temperature: Optional[float] = Field(
default=None,
description="Temperature for creative thinking (0-1, default 0.7)",
description="Creative thinking temp (0-1, default 0.7)",
ge=0.0,
le=1.0,
# exclude=True # Excluded from MCP schema but available for internal use
)
thinking_mode: Optional[str] = Field(
default=None,
description="Thinking depth: minimal (0.5% of model max), low (8%), medium (33%), high (67%), max (100% of model max). Defaults to 'high' if not specified.",
# exclude=True # Excluded from MCP schema but available for internal use
description="Depth: minimal/low/medium/high/max. Default 'high'.",
)
use_websearch: Optional[bool] = Field(
default=None,
description="Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
# exclude=True # Excluded from MCP schema but available for internal use
description="Enable web search for docs, brainstorming, architecture, solutions.",
)
# Context files and investigation scope
problem_context: Optional[str] = Field(
default=None,
description="Provide additional context about the problem or goal. Be as expressive as possible. More information will be very helpful for the analysis.",
description="Additional context about problem/goal. Be expressive.",
)
focus_areas: Optional[list[str]] = Field(
default=None,
description="Specific aspects to focus on (architecture, performance, security, etc.)",
description="Focus aspects (architecture, performance, security, etc.)",
)
@@ -177,12 +153,12 @@ class ThinkDeepTool(WorkflowTool):
thinkdeep_field_overrides = {
"problem_context": {
"type": "string",
"description": "Provide additional context about the problem or goal. Be as expressive as possible. More information will be very helpful for the analysis.",
"description": "Additional context about problem/goal. Be expressive.",
},
"focus_areas": {
"type": "array",
"items": {"type": "string"},
"description": "Specific aspects to focus on (architecture, performance, security, etc.)",
"description": "Focus aspects (architecture, performance, security, etc.)",
},
}