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

Class StrategyRecord

core/strategy_tracker.py:25–55  ·  view source on GitHub ↗

Records a single strategy usage.

Source from the content-addressed store, hash-verified

23
24
25class StrategyRecord:
26 """Records a single strategy usage."""
27
28 def __init__(self, strategy: str, error_type: str, success: bool,
29 duration: float = 0.0, context: Dict = None):
30 self.strategy = strategy
31 self.error_type = error_type
32 self.success = success
33 self.duration = duration
34 self.context = context or {}
35 self.timestamp = datetime.now().isoformat()
36
37 def to_dict(self) -> Dict:
38 return {
39 "strategy": self.strategy,
40 "error_type": self.error_type,
41 "success": self.success,
42 "duration": self.duration,
43 "context": self.context,
44 "timestamp": self.timestamp,
45 }
46
47 @classmethod
48 def from_dict(cls, data: Dict) -> "StrategyRecord":
49 return cls(
50 strategy=data["strategy"],
51 error_type=data["error_type"],
52 success=data.get("success", False),
53 duration=data.get("duration", 0.0),
54 context=data.get("context", {}),
55 )
56
57
58class StrategyStats:

Callers 1

record_attemptMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected