from .command import Command from .command_result import CommandResult from .working_memory import WorkingMemory class StopCommand(Command): """ Command to stop the agent. Performs cleanup on all entries and clears working memory. """ def execute(self, memory: WorkingMemory) -> CommandResult: """ Signal that the agent should stop. Cleans up all entries and clears the working memory. Args: memory: WorkingMemory instance to clear Returns: CommandResult: Stop result """ # Get a copy of entries to iterate over entries = memory.get_entries() # Clean up each entry individually for entry in entries: entry.cleanup() memory.remove_entry(entry.id) return CommandResult.stop()