get_session_summary to get a pre-formatted string ready for prompt injection.
Why Use Session Summary?
When building agents that need awareness of their previous work, you often want to include task history in the system prompt or context. The session summary method:- Saves tokens: Compact format optimized for LLM consumption
- Let your agent run longer: Consider this summary is a automatic TODO list, your agent can use it to track its work and progress.
Usage
Output Format
The summary returns an XML-formatted string optimized for LLM parsing:idattribute - Task order numberdescriptionattribute - Task description<progress>element with numbered steps (if any)<user_preference>element with numbered items (if any)
How It Works
Session summary leverages Acontext’s automatic task extraction which runs in the background as your agent converses. The extracted tasks include:- Task description: What the agent planned to do
- Progress updates: Steps the agent completed
- User preferences: Requirements mentioned by the user
get_session_summary method fetches these tasks and formats them into a compact string.
Options
You can limit the number of tasks returned:If no tasks have been extracted yet, the method returns an empty string. Task extraction happens asynchronously - see Session Buffer for details on timing.