Memory Module¶
Memory module.
- class atloop.memory.AgentState(step: int = 0, phase: str = 'DISCOVER', last_error: ~atloop.memory.state.LastError = <factory>, memory: ~atloop.memory.state.Memory = <factory>, artifacts: ~atloop.memory.state.Artifacts = <factory>, budget_used: ~atloop.memory.state.BudgetUsed = <factory>)[source]¶
Bases:
objectAgent execution state.
- __init__(step: int = 0, phase: str = 'DISCOVER', last_error: ~atloop.memory.state.LastError = <factory>, memory: ~atloop.memory.state.Memory = <factory>, artifacts: ~atloop.memory.state.Artifacts = <factory>, budget_used: ~atloop.memory.state.BudgetUsed = <factory>) None¶
- budget_used: BudgetUsed¶
- class atloop.memory.LastError(summary: str = '', repro_cmd: str = '', raw_stderr_tail: str = '', error_signature: str = '')[source]¶
Bases:
objectLast error information.
- class atloop.memory.Memory(decisions: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, attempts: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, key_files: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, notes: ~typing.List[str] = <factory>, created_files: ~typing.List[str] = <factory>, plan: str | ~typing.List[~typing.Any] = <factory>, task_summary: str = '', important_decisions: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, milestones: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, learnings: ~typing.List[str] = <factory>, llm_responses: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, tool_results_history: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, modified_files_content: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>)[source]¶
Bases:
objectMemory for tracking decisions and attempts.
- __init__(decisions: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, attempts: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, key_files: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, notes: ~typing.List[str] = <factory>, created_files: ~typing.List[str] = <factory>, plan: str | ~typing.List[~typing.Any] = <factory>, task_summary: str = '', important_decisions: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, milestones: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, learnings: ~typing.List[str] = <factory>, llm_responses: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, tool_results_history: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>, modified_files_content: ~typing.List[~typing.Dict[str, ~typing.Any]] = <factory>) None¶
- class atloop.memory.Artifacts(current_diff: str = '', test_results: str = '', verification_success: bool | None = None, dod_result: Any | None = None)[source]¶
Bases:
objectArtifacts produced during execution.
- class atloop.memory.BudgetUsed(llm_calls: int = 0, tool_calls: int = 0, wall_time_sec: int = 0)[source]¶
Bases:
objectBudget usage tracking.
- class atloop.memory.MemorySummarizer[source]¶
Bases:
objectSummarize agent memory for LLM input.
- static get_memory_overview(state: AgentState) str[source]¶
Get a brief overview of memory for terminal output.
- Parameters:
state – Agent state
- Returns:
Brief overview string (single line, compact format)
MemoryManager¶
- class atloop.memory.memory_manager.MemoryManager[source]¶
Bases:
objectManager for dynamic memory updates.
- static update_plan(state: AgentState, plan: str, reason: str | None = None) None[source]¶
Update the execution plan in long-term memory.
- Parameters:
state – Agent state
plan – New plan text
reason – Optional reason for the update
- static add_important_decision(state: AgentState, content: str, step: int | None = None, context: Dict[str, Any] | None = None) None[source]¶
Add an important decision to long-term memory.
- Parameters:
state – Agent state
content – Decision content
step – Step number (defaults to current step)
context – Optional context information
- static add_milestone(state: AgentState, content: str, step: int | None = None, context: Dict[str, Any] | None = None) None[source]¶
Add a milestone to long-term memory.
- Parameters:
state – Agent state
content – Milestone content
step – Step number (defaults to current step)
context – Optional context information
- static add_learning(state: AgentState, learning: str, step: int | None = None) None[source]¶
Add a learning to long-term memory.
- Parameters:
state – Agent state
learning – Learning content
step – Step number (defaults to current step)
- static update_task_summary(state: AgentState, summary: str) None[source]¶
Update task summary in long-term memory.
- Parameters:
state – Agent state
summary – Task summary text
- static get_long_term_memory_summary(state: AgentState) str[source]¶
Get a summary of long-term memory.
- Parameters:
state – Agent state
- Returns:
Summary string
MemorySummarizer¶
- class atloop.memory.summarizer.MemorySummarizer[source]¶
Bases:
objectSummarize agent memory for LLM input.
- static get_memory_overview(state: AgentState) str[source]¶
Get a brief overview of memory for terminal output.
- Parameters:
state – Agent state
- Returns:
Brief overview string (single line, compact format)
MemoryCompressor¶
- class atloop.memory.compressor.MemoryCompressor[source]¶
Bases:
objectCompress old memory to prevent unbounded growth.
- ATTEMPTS_KEEP_RECENT = 10¶
- DECISIONS_KEEP_RECENT = 5¶
- IMPORTANT_DECISIONS_KEEP = 20¶
- MILESTONES_KEEP = 20¶
- LEARNINGS_KEEP = 10¶
- static compress_if_needed(state: AgentState, memory_config=None, llm_client=None) bool[source]¶
Compress memory if it exceeds limits.
Phase 4: Enhanced with LLM compression and deduplication.
- Parameters:
state – Agent state
memory_config – Optional MemoryConfig instance (if None, uses defaults)
llm_client – Optional LLMClient for LLM compression (if None, LLM compression is skipped)
- Returns:
True if compression was performed, False otherwise
AgentState¶
- class atloop.memory.state.AgentState(step: int = 0, phase: str = 'DISCOVER', last_error: ~atloop.memory.state.LastError = <factory>, memory: ~atloop.memory.state.Memory = <factory>, artifacts: ~atloop.memory.state.Artifacts = <factory>, budget_used: ~atloop.memory.state.BudgetUsed = <factory>)[source]¶
Bases:
objectAgent execution state.
- budget_used: BudgetUsed¶