Skip to content

Common Use Cases

These scenarios focus on usage goals rather than internal mechanics.

1) My model supports unlimited context

Goal: keep full history without truncation.

Use: Quick Session (record only).

python
agent.enable_quick_session()
# ...
print(agent.session.full_chat_history)

2) My provider manages context server-side

Goal: let the service manage context; keep local logs only.

Use: do not attach Session to the agent; keep a separate Session for logging.

python
from agently.core import Session

log_session = Session().use_lite(chars=0, messages=0)
reply = agent.input("...").get_text()

log_session.append_message({"role": "user", "content": "..."})
log_session.append_message({"role": "assistant", "content": reply})

3) I already maintain memo, how do I use it?

Inject memo into the prompt or persist it.

python
agent.info({"memo": agent.session.memo})
python
saved = agent.session.to_json()
agent.enable_quick_session(load=saved)

4) “Infinite” dialog on limited-context models

Use memo + sliding window.

python
from agently.core import Session

session = Session(agent=agent).configure(
    mode="memo",
    limit={"chars": 6000, "messages": 12},
    every_n_turns=2,
)
agent.attach_session(session)

Tips:

  • keep current_chat_history bounded
  • rely on memo for stable info
  • force deep summarize when needed: session.resize(force="deep")
  • persist full_chat_history externally if you need full replay

5) Multi-user isolation

python
from agently.core import Session

sessions = {}

def get_session(user_id):
    if user_id not in sessions:
        sessions[user_id] = Session().use_memo(chars=6000, messages=12)
    return sessions[user_id]

agent.attach_session(get_session(user_id))

6) Low-cost short chats

python
agent.enable_session_lite(chars=8000, messages=6)

7) Audit / export

python
agent.enable_quick_session()
backup = agent.session.to_json()

8) Custom summarizer

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

session.set_memo_update_handler(custom_memo)