---
type: email
from: Surfing Dev <notifications@github.com>
subject: [openai/openai-agents-python] Context window management on long

 sessions (Issue #1539)
received: 2026-03-05 10:12:28
date_header: Wed, 20 Aug 2025 06:24:47 -0700
priority: normal
status: awaiting_approval
uid: 28182
---

## Email Content

**From:** Surfing Dev <notifications@github.com>
**Subject:** [openai/openai-agents-python] Context window management on long

 sessions (Issue #1539)
**Date:** Wed, 20 Aug 2025 06:24:47 -0700

### Body (preview)

surfingdev created an issue (openai/openai-agents-python#1539)



The [sessions feature](https://openai.github.io/openai-agents-python/sessions/) is great to avoid handling conversation context. But its lack of tool to control its length. In large conversations, the context window grows big relatively fast if you have a multi-agent architecture and multiple tools. 



The current options are:

* Using input filters (https://openai.github.io/openai-agents-python/handoffs/#input-filters)

* Handling removal of items using a custom session implementation (https://openai.github.io/openai-agents-python/sessions/#custom-memory-implementations)

* Don't use sessions and instead deal with inputs manually.





The ideal experience would be to have a native compact, similar to what Claude Code does when the context window is reaching its limit.



There was also an existing attempt to do a `keep_last_n` policy but it was closed due to inactivity https://github.com/openai/openai-agents-python/pull/660



**Is there something I'm missing? Which are the techniques people are using to avoid the number of tokens increasing?**



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/issues/1539

You are receiving this because you are subscribed to this thread.



Message ID: <openai/openai-agents-python/issues/1539@github.com>

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
