src.core.memory module#
Memory System for Marcus.
Multi-tier memory system that enables learning from past experiences and predictive task assignment. Inspired by cognitive memory models with working, episodic, semantic, and procedural memory layers.
- class src.core.memory.TaskOutcome[source]#
Bases:
objectRecord of a task execution outcome.
- __init__(task_id, agent_id, task_name, estimated_hours, actual_hours, success, blockers=<factory>, started_at=None, completed_at=None)#
- class src.core.memory.AgentProfile[source]#
Bases:
objectLearned profile of an agent’s capabilities.
- __init__(agent_id, total_tasks=0, successful_tasks=0, failed_tasks=0, blocked_tasks=0, skill_success_rates=<factory>, average_estimation_accuracy=0.0, common_blockers=<factory>, peak_performance_hours=<factory>)#
- class src.core.memory.TaskPattern[source]#
Bases:
objectLearned pattern about task types.
- __init__(pattern_type, task_labels, recent_durations, success_rate, common_blockers, prerequisites, best_agents, max_samples=100)#
- class src.core.memory.Memory[source]#
Bases:
objectMulti-tier memory system for Marcus.
Tiers: - Working Memory: Current state and active tasks - Episodic Memory: Specific task execution records - Semantic Memory: Extracted facts and patterns - Procedural Memory: Learned workflows and strategies
- __init__(events=None, persistence=None)[source]#
Initialize the Memory system.
- Parameters:
events (
Optional[Events]) – Optional Events system for integration.persistence (
Optional[Persistence]) – Optional Persistence for long-term storage.
- async record_task_completion(agent_id, task_id, success, actual_hours, blockers=None)[source]#
Record task completion and learn from it.
- async predict_task_outcome(agent_id, task)[source]#
Predict likely outcome for agent-task combination.
- async predict_completion_time(agent_id, task)[source]#
Predict task completion time with confidence intervals.
- get_median_duration_by_type(task_type)[source]#
Get median task duration for a given task type.
- Parameters:
task_type (
str) – Task type label (e.g., “design”, “implement”, “test”)- Returns:
Median duration in hours, or None if no data available
- Return type:
Examples
>>> memory.get_median_duration_by_type("design") 0.1 # 6 minutes
Notes
Uses median instead of average to be robust to outliers (tasks that sat for hours waiting for user input, etc.)
- async predict_blockage_probability(agent_id, task)[source]#
Predict likelihood and types of blockages.
- async predict_cascade_effects(task_id, delay_hours)[source]#
Predict impact of task delay on dependent tasks.
- Return type:
- Returns:
Dictionary with: - affected_tasks: List of tasks that will be impacted - total_delay: Cumulative delay across all tasks - critical_path_impact: Whether this affects project completion - mitigation_options: Ways to reduce impact
- Parameters:
- async calculate_agent_performance_trajectory(agent_id)[source]#
Calculate agent’s skill development trajectory.
- Return type:
- Returns:
Dictionary with: - current_skills: Current skill levels - improving_skills: Skills showing improvement - struggling_skills: Skills needing attention - projected_skills: Predicted skill levels in 30 days - recommendations: Training/task recommendations
- Parameters:
agent_id (str)
- async find_similar_outcomes(task, limit=5)[source]#
Find similar past task executions.
- Return type:
- Parameters:
- async get_global_median_duration()[source]#
Get the global median task duration from all completed tasks.
- Returns:
Median task duration in hours. Returns 1.0 if no historical data.
- Return type:
Notes
Uses SQL-based median calculation for efficiency and scalability. Queries ALL historical data from persistence layer, not just in-memory cache. Uses median instead of mean to be more robust to outliers.