OpenAI's Python SDK adds agent context compaction controls
Version 3.42.0 lets you choose background or blocking compaction for agents, sessions and scheduled runs, plus an experimental setting so agents know the current time.
OpenAI shipped openai-python 3.42.0 on 31 October, adding configurable context compaction to its beta Agents API. A new async_ parameter lets you set background or blocking compaction when creating or updating an agent, a session, or a scheduled agent run, and those same objects now return their effective compaction setting so you can check what is actually applied.
The release also adds an experimental time_awareness setting you can turn on for an agent or session, so it knows the current date and time rather than relying on whatever got typed into the system prompt. Session review settings landed in the same release: you can now set review options on a session and swap its tools through agent.tools without recreating it, alongside organisation-level external key management and callable API keys that stay scoped to a single request.
Why it matters: context compaction is the thing that quietly breaks long-running agents once a session’s history outgrows the context window. Having it as a first-class, readable setting, with a background mode so it does not block the next turn, means you no longer have to hand-roll your own trimming logic for anything built on OpenAI’s Agents API.
The caveat: this sits on OpenAI’s beta Agents API and an experimental flag, so expect the interface to keep moving before either is finalised.