liveBook · Manning

Sliding window

As explained in Designing AI Systems

A sliding window is a context-management technique that retains the most recent items while storing older items outside the active processing window.

A sliding window manages conversation context by sending only the most recent N messages to the model while preserving older messages in session storage. It prevents context-window overflow as conversations, tool calls, and verbose JSON results grow. section 10.3

The Session Service supplies bounded history to the workflow. A retrieval call such as get_messages(session_id=session.session_id, limit=50) makes the active context limit explicit while leaving the complete conversation available for later strategies. section 10.3

Use the technique when:

  • A conversation must retain recent turns for coherent follow-up questions. section 10.3
  • History may exceed the model's context window because of length or tool-call results. section 10.3
  • Older information can remain stored without occupying every model request. section 10.3

Bounded conversation history

For Claw, retrieving history with limit=50 keeps the latest 50 messages in the prompt. The assistant can continue an Italian restaurant discussion, but may forget preferences stated near the conversation's beginning. Long-term memory is introduced separately for facts that must survive the active window or future sessions. section 10.3 section 10.4

Listing 10.3 Managing context window limits
history, _ = platform.sessions.get_messages(    #A
    session_id=session.session_id, limit=50    #A
)    #A

Inspect the minimal implementation pattern for applying a message limit through the Session Service. section 10.3

How Designing AI Systems covers it

How deep it goes
Defines bounded retrieval and its tradeoff, but defers longer-term memory strategies to a separate design.
Examples
Uses Claw's Italian restaurant conversation and a get_messages limit of 50 as concrete examples.
What it assumes
Assumes session-based conversation storage and distinguishes recent history from persistent user memory.
What you can do after
Operate context limits through platform.sessions.get_messages with a bounded message count.
How it connects
Connects the Session Service, conversation history, context windows, tool calls, and long-term memory.

Also explained in

Compare how 8 books explain sliding window →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.