Session & Memo Overview
Applies to: 4.0.8+
Starting from v4.0.8, Session was redesigned:
Sessionis now a first-class core object (agently.core.Session)SessionExtensionis mixed into defaultAgent- Legacy quick/lite/memo helper methods are no longer the recommended path
This section documents the current API surface for recording, resizing, memo maintenance, and serialization.
Core state model
Each Session has four important parts:
full_context: full transcript (audit/replay source)context_window: prompt window actually injected into requestsmemo: user-defined durable memory (not auto-generated by default)session_settings:session.*namespace (for examplesession.max_length)
Default behavior (without custom handlers)
auto_resize=Trueby default- built-in analyzer checks
session.max_length - built-in strategy
simple_cuttrims window from the tail to fit max length
So you get a usable bounded-context session behavior even with zero custom code.
Agent integration behavior
Default agent already includes SessionExtension, so you can directly call:
agent.activate_session(session_id="...")agent.deactivate_session()agent.clean_context_window()agent.set_chat_history(...)agent.add_chat_history(...)
Lifecycle integration:
- before request: inject
context_windowintochat_history - after request: record input/output using
session.input_keysandsession.reply_keys - when memo exists: inject
CHAT SESSION MEMO