<#1174 feat(agents): decouple MemoryStore from Age...
# flyte-github
a
#1174 feat(agents): decouple MemoryStore from Agent Pull request opened by cosmicBboy Summary Redesigns agent memory (
flyte.ai.agents
) to be more functional, decoupled, and easier to reason about. • MemoryStore is a serializable Flyte I/O type. It implements mashumaro's
SerializableType
, so it can be passed as a task input/output. The transcript (
messages
) travels inline; the local working dir is transient and keyed stores hydrate their artifacts lazily from the remote path. • MemoryStore is keyed-only.
key
is now required — there is no unkeyed/ephemeral store.
save()
always targets the deterministic keyed remote path (removed the
remote_destination
override and the
Dir.from_local
branch). • Agent is decoupled from memory. Removed the
Agent.memory
field and the
agent.memory = ...
assignment.
Agent.run(message, memory=...)
accepts a
list[dict]
(chat history) or a
MemoryStore
, prepends the prior transcript, appends the new turn back onto the store, and returns it on
AgentResult.memory
. • Saving is explicit.
run
never persists; the caller invokes
memory.save()
(e.g. right after
agent.run
). This removes hidden I/O from the loop. • Tools never touch MemoryStore. Continuity comes from the auto-threaded transcript; the artifact/audit/version features remain available to the caller (not tools). Also updates
AgentProtocol
/
CodeModeAgent.run
signatures (
history
->
memory
), the chat app call site, and the agent examples (the
history
arg/usage is renamed to
memory
). Changes • `src/flyte/ai/agents/memory.py`:
SerializableType
(`_serialize`/`_deserialize`), lazy
_ensure_hydrated
, required
key
, keyed-only
save()
, lazy
remote_path
resolution. • `src/flyte/ai/agents/agent.py`: drop
memory
field; `run(message, memory=...)`; in-place transcript write-back; return
AgentResult.memory
. • `src/flyte/ai/agents/protocol.py`:
AgentResult.memory
field; protocol
run
signature. •
src/flyte/ai/agents/codemode.py
, `src/flyte/ai/chat/app.py`: signature/call-site updates. • `examples/agents/**`: explicit
memory.save()
in the memory example;
history
->
memory
renames. Test plan •
pytest tests/flyte/ai/agents tests/flyte/ai/chat
(230 passed) •
mypy
clean on changed sources (pre-commit hook) • Added a TypeEngine round-trip test proving
MemoryStore
survives a task I/O boundary • Added
test_run_does_not_save_memory
(explicit-save contract) and
test_key_is_required
• Follow-ups (from review, not in this PR): trigger lazy-hydration coverage, end-to-end save+reload through
Agent.run
, transcript last-writer-wins docs Made with Cursor flyteorg/flyte-sdk