MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / StrategyTracker

Class StrategyTracker

core/strategy_tracker.py:116–391  ·  view source on GitHub ↗

Tracks effectiveness of recovery strategies. Strategies are ranked by: - Success rate (primary) - Recent performance (weighted higher) - Average duration (tiebreaker) Provides: - Best strategy recommendations - Performance analytics - Adaptive strategy selectio

Source from the content-addressed store, hash-verified

114
115
116class StrategyTracker:
117 """
118 Tracks effectiveness of recovery strategies.
119
120 Strategies are ranked by:
121 - Success rate (primary)
122 - Recent performance (weighted higher)
123 - Average duration (tiebreaker)
124
125 Provides:
126 - Best strategy recommendations
127 - Performance analytics
128 - Adaptive strategy selection
129 """
130
131 # Built-in strategies with default configs
132 BUILTIN_STRATEGIES = {
133 "use_patch": {
134 "description": "Use patch_file instead of write_file",
135 "error_types": ["write_failed", "permission_denied"],
136 "confidence": 0.9,
137 },
138 "create_parent_dirs": {
139 "description": "Create parent directories before write",
140 "error_types": ["file_not_found", "path_error"],
141 "confidence": 0.95,
142 },
143 "install_dependency": {
144 "description": "Install missing Python package",
145 "error_types": ["ModuleNotFoundError", "ImportError"],
146 "confidence": 0.9,
147 },
148 "fix_syntax": {
149 "description": "Fix syntax error in code",
150 "error_types": ["SyntaxError", "IndentationError"],
151 "confidence": 0.8,
152 },
153 "fix_imports": {
154 "description": "Fix import statements",
155 "error_types": ["ImportError", "ModuleNotFoundError"],
156 "confidence": 0.85,
157 },
158 "retry_with_permissions": {
159 "description": "Retry command with sudo/permissions",
160 "error_types": ["PermissionError", "AccessDenied"],
161 "confidence": 0.7,
162 },
163 "search_for_solution": {
164 "description": "Search for similar errors and solutions",
165 "error_types": ["*"], # Any error type
166 "confidence": 0.6,
167 },
168 "run_single_test": {
169 "description": "Run failing test in isolation",
170 "error_types": ["AssertionError", "test_failure"],
171 "confidence": 0.85,
172 },
173 "check_file_exists": {

Callers 5

test_record_attemptMethod · 0.90
test_statisticsMethod · 0.90
get_strategy_trackerFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_record_attemptMethod · 0.72
test_statisticsMethod · 0.72