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

Method learn_from_error_and_fix

core/learning.py:131–161  ·  view source on GitHub ↗

Learn from a complete error-fix cycle. Args: error_type: Type of error error_message: Error message fix: Fix that was applied success: Whether fix worked strategy: Strategy name (if applicable) duration: Time t

(self, error_type: str, error_message: str,
                                  fix: str, success: bool = True,
                                  strategy: str = None,
                                  duration: float = 0.0,
                                  context: Dict = None)

Source from the content-addressed store, hash-verified

129 )
130
131 def learn_from_error_and_fix(self, error_type: str, error_message: str,
132 fix: str, success: bool = True,
133 strategy: str = None,
134 duration: float = 0.0,
135 context: Dict = None):
136 """
137 Learn from a complete error-fix cycle.
138
139 Args:
140 error_type: Type of error
141 error_message: Error message
142 fix: Fix that was applied
143 success: Whether fix worked
144 strategy: Strategy name (if applicable)
145 duration: Time taken
146 context: Additional context
147 """
148 # Record in error database
149 error_key = self.error_db.record_error(error_type, error_message, context)
150 self.error_db.record_fix(error_key, fix, success)
151
152 # Record strategy effectiveness
153 if strategy:
154 self.strategy_tracker.record_attempt(
155 strategy, error_type, success, duration
156 )
157
158 if success:
159 log_success(f"Learned from {error_type}: {fix[:50]}...")
160 else:
161 warning(f"Failed fix for {error_type}: {fix[:50]}...")
162
163 def get_best_strategy(self, error_type: str) -> Optional[str]:
164 """

Callers 2

test_suggest_fixMethod · 0.95

Calls 4

warningFunction · 0.90
record_attemptMethod · 0.80
record_errorMethod · 0.45
record_fixMethod · 0.45

Tested by 2

test_suggest_fixMethod · 0.76