Memory¶
Goal¶
Clarify memory ownership and usage in QitOS.
Ownership¶
Memory belongs to AgentModule (self.memory).
- Prefer passing memory at agent construction.
Memory contract¶
Memory provides:
append(record)retrieve(query, state, observation)summarize(max_items)reset(run_id)
How memory is used¶
- During runtime, Engine appends relevant records to
agent.memory. - In custom agents, you can read memory directly in
prepare(state).
Typical memory stream:
taskstatedecisionactionobservationnext_state- ...
Important boundary¶
observation should not embed memory by default.
observationis for world/action/env outputs of the step.- memory should be consumed explicitly from
self.memory.
Example¶
class MyAgent(...):
def prepare(self, state):
records = []
if self.memory is not None:
records = self.memory.retrieve(state=state, observation=None, query={"roles": ["observation"], "max_items": 8})
return f"Task: {state.task}\nRecords: {records[-4:]}"