fix: reduced token usage, removed parameters from schema that CLIs never seem to use

This commit is contained in:
Fahad
2025-10-22 13:31:08 +04:00
parent 3efff6056e
commit 3e27319e60
31 changed files with 86 additions and 235 deletions

View File

@@ -68,7 +68,6 @@ ANALYZE_WORKFLOW_FIELD_DESCRIPTIONS = {
"List methods/functions central to analysis findings, in 'ClassName.methodName' or 'functionName' format. "
"Prioritize those demonstrating key patterns, architectural decisions, or improvement opportunities."
),
"backtrack_from_step": ("If an earlier finding needs revision, specify the step number to backtrack from."),
"images": (
"Optional absolute paths to architecture diagrams or visual references that help with analysis context."
),
@@ -108,11 +107,6 @@ class AnalyzeWorkflowRequest(WorkflowRequest):
description="Issues or concerns identified during analysis, each with severity level (critical, high, medium, low)",
)
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(
None, description=ANALYZE_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
# Optional images for visual context
images: Optional[list[str]] = Field(default=None, description=ANALYZE_WORKFLOW_FIELD_DESCRIPTIONS["images"])
@@ -223,11 +217,6 @@ class AnalyzeTool(WorkflowTool):
"enum": ["exploring", "low", "medium", "high", "very_high", "almost_certain", "certain"],
"description": ANALYZE_WORKFLOW_FIELD_DESCRIPTIONS["confidence"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": ANALYZE_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"images": {
"type": "array",
"items": {"type": "string"},

View File

@@ -53,7 +53,6 @@ CODEREVIEW_WORKFLOW_FIELD_DESCRIPTIONS = {
"relevant_context": "Functions or methods central to findings (e.g. 'Class.method' or 'function_name').",
"issues_found": "Issues with severity (critical/high/medium/low) and descriptions.",
"review_validation_type": "Set 'external' (default) for expert follow-up or 'internal' for local-only review.",
"backtrack_from_step": "If revising earlier analysis, note the step number to revisit.",
"images": "Optional diagram or screenshot paths that clarify review context.",
"review_type": "Review focus: full, security, performance, or quick.",
"focus_on": "Optional note on areas to emphasise (e.g. 'threading', 'auth flow').",
@@ -91,11 +90,6 @@ class CodeReviewRequest(WorkflowRequest):
"external", description=CODEREVIEW_WORKFLOW_FIELD_DESCRIPTIONS.get("review_validation_type", "")
)
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(
None, description=CODEREVIEW_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
# Optional images for visual context
images: Optional[list[str]] = Field(default=None, description=CODEREVIEW_WORKFLOW_FIELD_DESCRIPTIONS["images"])
@@ -206,11 +200,6 @@ class CodeReviewTool(WorkflowTool):
"default": "external",
"description": CODEREVIEW_WORKFLOW_FIELD_DESCRIPTIONS.get("review_validation_type", ""),
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": CODEREVIEW_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"issues_found": {
"type": "array",
"items": {"type": "object"},

View File

@@ -101,7 +101,6 @@ class ConsensusRequest(WorkflowRequest):
relevant_context: list[str] | None = Field(default_factory=list, exclude=True)
issues_found: list[dict] | None = Field(default_factory=list, exclude=True)
hypothesis: str | None = Field(None, exclude=True)
backtrack_from_step: int | None = Field(None, exclude=True)
@model_validator(mode="after")
def validate_step_one_requirements(self):
@@ -293,7 +292,6 @@ of the evidence, even when it strongly points in one direction.""",
"relevant_context", # Not used in consensus workflow
"issues_found", # Not used in consensus workflow
"hypothesis", # Not used in consensus workflow
"backtrack_from_step", # Not used in consensus workflow
"confidence", # Not used in consensus workflow
]

View File

@@ -3,8 +3,8 @@ Debug tool - Systematic root cause analysis and debugging assistance
This tool provides a structured workflow for investigating complex bugs and issues.
It guides you through systematic investigation steps with forced pauses between each step
to ensure thorough code examination before proceeding. The tool supports backtracking,
hypothesis evolution, and expert analysis integration for comprehensive debugging.
to ensure thorough code examination before proceeding. The tool supports hypothesis evolution
and expert analysis integration for comprehensive debugging.
Key features:
- Step-by-step investigation workflow with progress tracking
@@ -65,7 +65,6 @@ DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS = {
"WARNING: Do NOT use 'certain' unless the issue can be fully resolved with a fix, use 'very_high' or 'almost_certain' instead when not 100% sure. "
"Using 'certain' means you have ABSOLUTE confidence locally and PREVENTS external model validation."
),
"backtrack_from_step": "Step number to backtrack from if revision needed.",
"images": "Optional screenshots/visuals clarifying issue (absolute paths).",
}
@@ -93,11 +92,6 @@ class DebugInvestigationRequest(WorkflowRequest):
hypothesis: Optional[str] = Field(None, description=DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["hypothesis"])
confidence: Optional[str] = Field("low", description=DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["confidence"])
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(
None, description=DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
# Optional images for visual debugging
images: Optional[list[str]] = Field(default=None, description=DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["images"])
@@ -193,11 +187,6 @@ class DebugIssueTool(WorkflowTool):
"type": "string",
"description": DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["hypothesis"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": DEBUG_INVESTIGATION_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"images": {
"type": "array",
"items": {"type": "string"},

View File

@@ -197,7 +197,6 @@ class DocgenTool(WorkflowTool):
excluded_workflow_fields = [
"confidence", # Documentation doesn't use confidence levels
"hypothesis", # Documentation doesn't use hypothesis
"backtrack_from_step", # Documentation uses simpler error recovery
"files_checked", # Documentation uses doc_files and doc_methods instead for better tracking
]

View File

@@ -83,7 +83,6 @@ class PlannerRequest(WorkflowRequest):
issues_found: list[dict] = Field(default_factory=list, exclude=True, description="Planning doesn't find issues")
confidence: str = Field(default="planning", exclude=True, description="Planning uses different confidence model")
hypothesis: str | None = Field(default=None, exclude=True, description="Planning doesn't use hypothesis")
backtrack_from_step: int | None = Field(default=None, exclude=True, description="Planning uses revision instead")
# Exclude other non-planning fields
temperature: float | None = Field(default=None, exclude=True)
@@ -211,7 +210,6 @@ class PlannerTool(WorkflowTool):
"issues_found", # Planning doesn't find issues
"confidence", # Planning uses different confidence model
"hypothesis", # Planning doesn't use hypothesis
"backtrack_from_step", # Planning uses revision instead
]
excluded_common_fields = [

View File

@@ -4,7 +4,7 @@ Precommit Workflow tool - Step-by-step pre-commit validation with expert analysi
This tool provides a structured workflow for comprehensive pre-commit validation.
It guides the CLI agent through systematic investigation steps with forced pauses between each step
to ensure thorough code examination, git change analysis, and issue detection before proceeding.
The tool supports backtracking, finding updates, and expert analysis integration.
The tool supports finding updates and expert analysis integration.
Key features:
- Step-by-step pre-commit investigation workflow with progress tracking
@@ -51,7 +51,6 @@ PRECOMMIT_WORKFLOW_FIELD_DESCRIPTIONS = {
"relevant_context": "Key functions/methods touched by the change (e.g. 'Class.method', 'function_name').",
"issues_found": "List issues with severity (critical/high/medium/low) plus descriptions (bugs, security, performance, coverage).",
"precommit_type": "'external' (default, triggers expert model) or 'internal' (local-only validation).",
"backtrack_from_step": "Step number to revisit when revising earlier analysis.",
"images": "Optional absolute paths to screenshots or diagrams that aid validation.",
"path": "Absolute path to the repository root. Required in step 1.",
"compare_to": "Optional git ref (branch/tag/commit) to diff against; falls back to staged/unstaged changes.",
@@ -89,11 +88,6 @@ class PrecommitRequest(WorkflowRequest):
"external", description=PRECOMMIT_WORKFLOW_FIELD_DESCRIPTIONS["precommit_type"]
)
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(
None, description=PRECOMMIT_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
# Optional images for visual validation
images: Optional[list[str]] = Field(default=None, description=PRECOMMIT_WORKFLOW_FIELD_DESCRIPTIONS["images"])
@@ -207,11 +201,6 @@ class PrecommitTool(WorkflowTool):
"default": "external",
"description": PRECOMMIT_WORKFLOW_FIELD_DESCRIPTIONS["precommit_type"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": PRECOMMIT_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"issues_found": {
"type": "array",
"items": {"type": "object"},

View File

@@ -78,7 +78,6 @@ REFACTOR_FIELD_DESCRIPTIONS = {
"WARNING: Use 'complete' ONLY when fully analyzed and can provide recommendations without expert help. "
"'complete' PREVENTS expert validation. Use 'partial' for large files or uncertain analysis."
),
"backtrack_from_step": ("If an earlier finding needs revision, specify the step number to backtrack from."),
"images": (
"Optional list of absolute paths to architecture diagrams, UI mockups, design documents, or visual references "
"that help with refactoring context. Only include if they materially assist understanding or assessment."
@@ -113,9 +112,6 @@ class RefactorRequest(WorkflowRequest):
"incomplete", description=REFACTOR_FIELD_DESCRIPTIONS["confidence"]
)
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(None, description=REFACTOR_FIELD_DESCRIPTIONS["backtrack_from_step"])
# Optional images for visual context
images: Optional[list[str]] = Field(default=None, description=REFACTOR_FIELD_DESCRIPTIONS["images"])
@@ -228,11 +224,6 @@ class RefactorTool(WorkflowTool):
"default": "incomplete",
"description": REFACTOR_FIELD_DESCRIPTIONS["confidence"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": REFACTOR_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"issues_found": {
"type": "array",
"items": {"type": "object"},

View File

@@ -47,7 +47,6 @@ SECAUDIT_WORKFLOW_FIELD_DESCRIPTIONS = {
"relevant_context": "Security-critical classes/methods (e.g. 'AuthService.login', 'encryption_helper').",
"issues_found": "Security issues with severity (critical/high/medium/low) and descriptions (vulns, auth flaws, injection, crypto, config).",
"confidence": "exploring/low/medium/high/very_high/almost_certain/certain. 'certain' blocks external validation—use only when fully complete.",
"backtrack_from_step": "Step number to revisit when revising earlier audit work.",
"images": "Optional absolute paths to diagrams or threat models that inform the audit.",
"security_scope": "Security context (web, mobile, API, cloud, etc.) including stack, user types, data sensitivity, and threat landscape.",
"threat_level": "Assess the threat level: low (internal/low-risk), medium (customer-facing/business data), high (regulated or sensitive), critical (financial/healthcare/PII).",
@@ -82,11 +81,6 @@ class SecauditRequest(WorkflowRequest):
)
confidence: Optional[str] = Field("low", description=SECAUDIT_WORKFLOW_FIELD_DESCRIPTIONS["confidence"])
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(
None, description=SECAUDIT_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
# Optional images for visual context
images: Optional[list[str]] = Field(default=None, description=SECAUDIT_WORKFLOW_FIELD_DESCRIPTIONS["images"])
@@ -398,11 +392,6 @@ class SecauditTool(WorkflowTool):
"enum": ["exploring", "low", "medium", "high", "very_high", "almost_certain", "certain"],
"description": SECAUDIT_WORKFLOW_FIELD_DESCRIPTIONS["confidence"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": SECAUDIT_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"issues_found": {
"type": "array",
"items": {"type": "object"},

View File

@@ -49,7 +49,6 @@ WORKFLOW_FIELD_DESCRIPTIONS = {
"almost_certain (near complete confidence), certain (100% confidence locally - no external validation needed)"
),
"hypothesis": "Current theory about issue/goal based on work",
"backtrack_from_step": "Step number to backtrack from if work needs revision",
"use_assistant_model": (
"Use assistant model for expert analysis after workflow steps. "
"False skips expert analysis, relies solely on your personal investigation. "
@@ -122,9 +121,6 @@ class WorkflowRequest(BaseWorkflowRequest):
# Optional workflow fields
hypothesis: Optional[str] = Field(None, description=WORKFLOW_FIELD_DESCRIPTIONS["hypothesis"])
backtrack_from_step: Optional[int] = Field(
None, ge=1, description=WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
use_assistant_model: Optional[bool] = Field(True, description=WORKFLOW_FIELD_DESCRIPTIONS["use_assistant_model"])
@field_validator("files_checked", "relevant_files", "relevant_context", mode="before")

View File

@@ -4,8 +4,7 @@ TestGen Workflow tool - Step-by-step test generation with expert validation
This tool provides a structured workflow for comprehensive test generation.
It guides the CLI agent through systematic investigation steps with forced pauses between each step
to ensure thorough code examination, test planning, and pattern identification before proceeding.
The tool supports backtracking, finding updates, and expert analysis integration for
comprehensive test suite generation.
The tool supports finding updates and expert analysis integration for comprehensive test suite generation.
Key features:
- Step-by-step test generation workflow with progress tracking
@@ -52,7 +51,6 @@ TESTGEN_WORKFLOW_FIELD_DESCRIPTIONS = {
"Do NOT use 'certain' unless the test generation analysis is comprehensively complete, use 'very_high' or 'almost_certain' instead if not 100% sure. "
"Using 'certain' means you have complete confidence locally and prevents external model validation."
),
"backtrack_from_step": "Step number to revisit if earlier findings need revision.",
"images": "Optional absolute paths to diagrams or visuals that clarify the system under test.",
}
@@ -79,11 +77,6 @@ class TestGenRequest(WorkflowRequest):
)
confidence: Optional[str] = Field("low", description=TESTGEN_WORKFLOW_FIELD_DESCRIPTIONS["confidence"])
# Optional backtracking field
backtrack_from_step: Optional[int] = Field(
None, description=TESTGEN_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"]
)
# Optional images for visual context
images: Optional[list[str]] = Field(default=None, description=TESTGEN_WORKFLOW_FIELD_DESCRIPTIONS["images"])
@@ -184,11 +177,6 @@ class TestGenTool(WorkflowTool):
"enum": ["exploring", "low", "medium", "high", "very_high", "almost_certain", "certain"],
"description": TESTGEN_WORKFLOW_FIELD_DESCRIPTIONS["confidence"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": TESTGEN_WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"images": {
"type": "array",
"items": {"type": "string"},

View File

@@ -71,13 +71,6 @@ class ThinkDeepWorkflowRequest(WorkflowRequest):
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="Step number to backtrack from if revision needed.",
ge=1,
)
# Expert analysis configuration - keep these fields available for configuring the final assistant model
# in expert analysis (commented out exclude=True)
temperature: Optional[float] = Field(

View File

@@ -115,10 +115,6 @@ class TracerRequest(WorkflowRequest):
# Exclude fields not relevant to tracing workflow
issues_found: list[dict] = Field(default_factory=list, exclude=True, description="Tracing doesn't track issues")
hypothesis: Optional[str] = Field(default=None, exclude=True, description="Tracing doesn't use hypothesis")
backtrack_from_step: Optional[int] = Field(
default=None, exclude=True, description="Tracing doesn't use backtracking"
)
# Exclude other non-tracing fields
temperature: Optional[float] = Field(default=None, exclude=True)
thinking_mode: Optional[str] = Field(default=None, exclude=True)
@@ -220,7 +216,6 @@ class TracerTool(WorkflowTool):
excluded_workflow_fields = [
"issues_found", # Tracing doesn't track issues
"hypothesis", # Tracing doesn't use hypothesis
"backtrack_from_step", # Tracing doesn't use backtracking
]
# Exclude common fields that tracing doesn't need

View File

@@ -76,7 +76,7 @@ class WorkflowTool(BaseTool, BaseWorkflowMixin):
Workflow tools automatically get all standard workflow fields:
- step, step_number, total_steps, next_step_required
- findings, files_checked, relevant_files, relevant_context
- issues_found, confidence, hypothesis, backtrack_from_step
- issues_found, confidence, hypothesis
- plus common fields (model, temperature, etc.)
Override this method to add additional tool-specific fields.

View File

@@ -72,11 +72,6 @@ class WorkflowSchemaBuilder:
"type": "string",
"description": WORKFLOW_FIELD_DESCRIPTIONS["hypothesis"],
},
"backtrack_from_step": {
"type": "integer",
"minimum": 1,
"description": WORKFLOW_FIELD_DESCRIPTIONS["backtrack_from_step"],
},
"use_assistant_model": {
"type": "boolean",
"default": True,

View File

@@ -701,11 +701,6 @@ class BaseWorkflowMixin(ABC):
# Allow tools to store initial description for expert analysis
self.store_initial_issue(request.step)
# Handle backtracking if requested
backtrack_step = self.get_backtrack_step(request)
if backtrack_step:
self._handle_backtracking(backtrack_step)
# Process work step - allow tools to customize field mapping
step_data = self.prepare_step_data(request)
@@ -992,13 +987,6 @@ class BaseWorkflowMixin(ABC):
except AttributeError:
return {}
def get_backtrack_step(self, request) -> Optional[int]:
"""Get backtrack step from request. Override for custom backtrack handling."""
try:
return request.backtrack_from_step
except AttributeError:
return None
def store_initial_issue(self, step_description: str):
"""Store initial issue description. Override for custom storage."""
# Default implementation - tools can override to store differently
@@ -1378,13 +1366,6 @@ class BaseWorkflowMixin(ABC):
return response_data
def _handle_backtracking(self, backtrack_step: int):
"""Handle backtracking to a previous step"""
# Remove findings after the backtrack point
self.work_history = [s for s in self.work_history if s["step_number"] < backtrack_step]
# Reprocess consolidated findings
self._reprocess_consolidated_findings()
def _update_consolidated_findings(self, step_data: dict):
"""Update consolidated findings with new step data"""
self.consolidated_findings.files_checked.update(step_data.get("files_checked", []))