Working memory helps an AI keep track of what it is doing right now. It stores important details so the AI can make good decisions step-by-step.
0
0
Working memory for current task state in Agentic AI
Introduction
When an AI needs to remember recent actions to plan the next step.
When handling tasks that require multiple steps and context.
When the AI must update its understanding as new information arrives.
When tracking progress in a conversation or interaction.
When managing temporary information that changes during a task.
Syntax
Agentic AI
working_memory = {}
# Store info
working_memory['current_step'] = 'fetch_data'
# Update info
working_memory['current_step'] = 'process_data'
# Access info
current = working_memory.get('current_step')Working memory is often a simple dictionary or key-value store.
It holds temporary data that changes as the task progresses.
Examples
Store and print the current task name.
Agentic AI
working_memory = {}
working_memory['task'] = 'cleaning'
print(working_memory['task'])Update the step number as the task moves forward.
Agentic AI
working_memory = {'step': 1}
working_memory['step'] += 1
print(working_memory['step'])Initialize a key if it does not exist yet.
Agentic AI
working_memory = {}
if 'result' not in working_memory:
working_memory['result'] = None
print(working_memory['result'])Sample Model
This simple agent uses working memory to track its current step and data. It prints each step and the data it handles.
Agentic AI
class SimpleAgent: def __init__(self): self.working_memory = {} def perform_task(self): self.working_memory['step'] = 'start' print(f"Step: {self.working_memory['step']}") self.working_memory['step'] = 'fetch_data' print(f"Step: {self.working_memory['step']}") self.working_memory['data'] = [1, 2, 3] print(f"Data fetched: {self.working_memory['data']}") self.working_memory['step'] = 'process_data' processed = [x * 2 for x in self.working_memory['data']] self.working_memory['processed_data'] = processed print(f"Processed data: {processed}") self.working_memory['step'] = 'finish' print(f"Step: {self.working_memory['step']}") agent = SimpleAgent() agent.perform_task()
OutputSuccess
Important Notes
Working memory is temporary and resets after the task ends.
It helps the AI remember what happened recently without storing everything forever.
Good working memory design makes AI more flexible and easier to debug.
Summary
Working memory stores temporary task details for AI.
It updates as the task moves forward step-by-step.
This helps AI make decisions based on recent context.