Skip to content

Session & Memo Overview

Applies to: 4.0.8+

Starting from v4.0.8, Session was redesigned:

  • Session is now a first-class core object (agently.core.Session)
  • SessionExtension is mixed into default Agent
  • 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 requests
  • memo: user-defined durable memory (not auto-generated by default)
  • session_settings: session.* namespace (for example session.max_length)

Default behavior (without custom handlers)

  • auto_resize=True by default
  • built-in analyzer checks session.max_length
  • built-in strategy simple_cut trims 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:

  1. before request: inject context_window into chat_history
  2. after request: record input/output using session.input_keys and session.reply_keys
  3. when memo exists: inject CHAT SESSION MEMO