Skip to content

Memo Update

Enable memo

python
session.use_memo(chars=6000, messages=12, every_n_turns=2)
# or
session.configure(mode="memo", limit={"chars": 6000, "messages": 12}, every_n_turns=2)

memo_update_handler

python
def memo_update_handler(memo, messages, attachments, settings):
    return memo

Example: model-based memo

python
from agently.core import ModelRequest

def memo_update_handler(memo, messages, attachments, settings):
    requester = ModelRequest(
        agent.plugin_manager,
        agent_name=agent.name,
        parent_settings=settings,
    )
    prompt_input = {
        "current_memo": memo,
        "messages": [m.model_dump() for m in messages],
        "attachments": attachments,
    }
    instruct = ["Return the updated memo dict only."]
    output_schema = {"memo": (dict, "Updated memo")}
    data = requester.input(prompt_input).instruct(instruct).output(output_schema).get_data()
    if isinstance(data, dict) and isinstance(data.get("memo"), dict):
        return data["memo"]
    return memo

When memo updates

  • during resize (lite/deep)
  • on every_n_turns, size limits, or forced resize