# Agents API background compaction and auto review: what to re-measure

URL: https://infro.io/blog/agents-api-background-compaction-and-auto-review-what-to-re-measure
Author: INFRO Editorial (https://infro.io/blog/editorial)
Publisher: INFRO
Published: 2026-11-08
Last modified: 2026-11-08
Last reviewed: 2026-11-08 (next review due 2026-12-08)
Topic: Agents and multimodal systems
Format: Guide

> Two October 30 changes move tokens out of the turns you already count: compaction now runs in the background by default and may raise token usage, and automatic review bills reviewer tokens on top of the agent's model usage [^openai-changelog][^openai-auto-review]. Re-baseline per-session tokens with compaction.async both ways, add compaction and review as separate spans and cost lines, and check caps against the provider's own cost figures.

Key takeaways:
- Since Oct 30, 2026 Agents API compaction runs in the background by default, and OpenAI says this may increase token usage; compaction.async set to false restores blocking compaction [1].
- Automatic review (review set to auto_review) bills reviewer tokens in addition to the agent's model usage, and it applies to root turns and to subagents [2].
- Measure the same replay set four ways, with compaction async on and off and review on and off, before changing any cap.
- Give compaction and review their own spans and cost lines so a rising bill can be traced to a cause rather than to 'the agent'.
- Treat the provider's own cost figures as the check on your per-turn counts, because work that happens between turns is the easiest to miss.

## What changed on October 30

Two entries in OpenAI's changelog, both dated October 30, 2026, touch the accounting of an Agents API loop. The first says context compaction now runs in the background by default, that you set `compaction.async` to `false` for blocking compaction, and that background compaction may increase token usage[1]. The second adds automatic review for eligible Agents API projects: set the session's `review` field to `"auto_review"` and a model approves or denies supported tool and permission requests based on conversation intent and risk[1].

Both are in the Agents API public beta. Neither requires a code change to keep working, which is the reason to look at them: a default that moves work out of the turn you were counting, and a mode that adds a second model to the loop. If your token accounting, traces and spend caps were calibrated before October 30, the numbers they produce may now describe a different system.

This guide does not cover how the compaction itself is performed or how its usage is reported in API responses, because those pages were not read for this article. The measurement plan below is written so that it does not depend on those details: it compares totals you can read from the provider's own figures before and after each setting.

## Why background compaction changes your token accounting

Compaction shrinks a session's accumulated context so a long run keeps fitting in the model's window. In a blocking design the work sits inside the turn that triggers it. You can see it as extra latency in that turn, and whatever tokens it consumes show up beside that turn's other usage.

With the background default, that attribution gets weaker. OpenAI's changelog states the consequence in one sentence: background compaction may increase token usage[1]. It does not give a mechanism or a size. One plausible reason, which is an inference and not something the changelog says, is that work done off the critical path is not tied to a single turn's result and may run when a blocking design would not have, or alongside the next turn. Whatever the reason, treat the size as unknown until you measure it on your own traffic.

Four things in your accounting can go wrong:

- **Per-turn token sums stop matching the session total.** If you add up usage per turn and compare with the session or invoice figure, a gap can appear that was not there before.
- **Latency and cost move apart.** A turn may look as fast as before while the session consumes more tokens, because the compaction cost is no longer on that turn's path.
- **Cost per successful task rises with no change in task mix.** The extra tokens land on the denominator-free side of the ratio, and the dashboard shows 'the agent got more expensive'.
- **Caps that count per-turn usage under-count.** A cap fed only by turn-level figures will trip later than the real spend line.

None of these is an error. They are drift, and drift is found by comparing against a baseline, so the baseline is the first thing to build.

## What automatic review adds to the loop

Automatic review is the Codex harness's 'Approve for me' behavior brought to Agents API sessions. When an agent's action raises an approval request, an OpenAI-managed reviewer model uses the conversation context to assess what the action would do, what risk it carries and whether it matches the user's intent, then approves or denies it[2]. The guide's examples of requests that can arise are shell commands needing approval, file changes, broader filesystem or network access, network access subject to the environment's restrictions, and MCP tool calls whose rules require confirmation[2].

For accounting, the relevant lines are short:

- Tokens used for review are billed in addition to your agent's model usage[2].
- The setting applies to root turns and to any subagents they create[2]. A multi-agent run therefore multiplies review calls with its fan-out.
- Omitting `review` defaults to `"none"`, and the value persists when the session resumes[2]. A session created before you turned the feature on does not change by itself, but a session you resume keeps whatever it last had.
- Review does not override the environment's outbound network restrictions[2].
- It is not supported when reusing an existing hosted environment through `environment_id`, and a project without access has the request rejected with `review` named as the affected parameter[2].

There is also a behavioral change to measure, separate from cost. Denials and approvals now happen without your application's handlers: the guide says automatic review does not require new approval event handlers[2]. That is convenient, and it also means a denied action may only be visible as an event in the session's history. If your traces only record model calls and tool results, a denial leaves no mark.

## A before/after measurement plan

Run this on a replay set, not on live traffic. Pick 30 to 100 representative sessions, weighted toward long ones, because compaction only matters once context grows. For how to replay safely, see [replaying production traffic](https://infro.io/blog/can-you-replay-production-traffic-to-test-a-new-model-safely).

1. **Freeze the variables.** Pin the model snapshot, the tool list and the environment template. A tool-list update changes behavior on the next model call for function tools and MCP servers, and by the next turn for built-in tools[1], so do not edit tools mid-experiment.
2. **Build a four-cell matrix.** Run each session with `compaction.async` true and false, and with `review` set to `"none"` and `"auto_review"`. Create the sessions fresh for each cell, using a new environment for the review cells since reuse through `environment_id` is not supported with review[2].
3. **Record per session, not per turn:** total input, cached input, output and reasoning tokens as the provider reports them, wall-clock duration, turn count, number of approval requests, number of denials, and whether the task succeeded by your own check.
4. **Take the provider's total as ground truth.** After each batch, read the spend for the window from the provider's own cost data and compare it with your summed figures. The difference is your unattributed share.
5. **Compare cells.** The async-off, review-none cell is closest to pre-October 30 behavior and is your baseline. Report each other cell as a ratio to it, per session and as a median and a high percentile.
6. **Repeat on a second day.** Background work may depend on timing, so one run is a sample, not a measurement.

> **Example: Illustrative numbers only**
> These figures are invented to show how to read the result, not measurements. Suppose the baseline cell shows a median of 400,000 tokens per session. The async-on cell shows 440,000, a ratio of 1.10, and the provider total for the batch is 8% above your summed turn figures. The 8% is the share your turn-level accounting cannot see, so the cap and the dashboard need a line for it. Your own ratios will differ.

## Spans to add

Most agent traces have one span per model call and one per tool call. Add spans for the work that now happens beside them. The attribute names below are our own suggestions with an `agent.` prefix. OpenTelemetry's GenAI semantic conventions have moved to their own repository[3], so check there for the current standard names for model, operation and token-usage attributes before choosing yours, and use those where they exist.

| Span | When to open it | Attributes worth keeping |
| --- | --- | --- |
| `agent.session` | Create and resume | session id, `agent.review_mode`, `agent.compaction_async`, agent id, environment type |
| `agent.turn` | Each root turn | turn index, duration, tokens as reported, end reason |
| `agent.compaction` | When a compaction is observed in session events | session id, turn index it overlapped, tokens if reported, blocking or background |
| `agent.review` | Each approval request resolved by review | request kind, decision, subagent or root, reviewer tokens if reported |
| `agent.tool` | Each tool call | tool name, duration, whether a review preceded it |
| `agent.reconcile` | Batch job after a window closes | session total from provider, summed span total, unattributed difference |

Two choices matter more than the names. First, record `review_mode` and `compaction_async` on the session span so a change in either is visible as a dimension, not inferred from a deploy date. Second, link compaction and review spans to the turn they overlapped rather than nesting them inside it, because a background job can outlive the turn. OpenAI's session events and item history, including per-turn item retrieval added on October 2[1], are the place to read what actually happened; the spans should be built from them, not from your client's guess.

## Cost lines to add

Cost lines are what finance sees. If compaction and review tokens are folded into a single 'agent' line, a rise cannot be explained. Split them.

| Line | What goes in it | Why separate |
| --- | --- | --- |
| Agent model usage | Tokens of the agent's own model calls | The baseline you already have |
| Compaction | Tokens attributed to compaction, plus any unattributed difference you assign to it | OpenAI flags it as a possible increase[1] |
| Automatic review | Reviewer tokens | Billed in addition to the agent's usage[2] |
| Sandbox compute | OpenAI-hosted sandbox time | Billed during active turns, no longer for idle time between turns, since October 9[1] |
| Server-side tools | Search, fetch and other tool calls | A separate meter; see [what server-side tools cost](https://infro.io/blog/ai-agent-tool-call-costs) |

Keep an explicit 'unattributed' line equal to the provider total minus everything above it. A line that is usually near zero and then grows is the cheapest alarm you can build. Group all of them by project and by end-user id so the answer to 'which customer's sessions got more expensive' is a query, not an investigation.

If you use a service tier such as ultrafast on agents, record it as a dimension as well, since the changelog lists `agent.service_tier` as the switch[1]; the arithmetic for that is in [ultrafast mode in an agent loop](https://infro.io/blog/ultrafast-mode-in-an-agent-loop-which-steps-earn-the-6x-price).

## Keeping spend caps accurate

A cap is only as good as the counter behind it. Three adjustments follow from the above.

**Count at the session level, with a margin.** If your cap reads per-turn usage, add a reserve for work that is not attributed to a turn, sized from the unattributed share in your matrix. The ratio from your own replay is the input, not a number from this article.

**Cap review separately when you can.** A fan-out of subagents under `auto_review` gives each subagent's requests a reviewer pass[2]. A step limit that counts model turns will not bound that. Add a limit on approval requests per session, and treat a spike in requests as a signal that the agent is stuck asking for permissions it is not going to get. Bounds in general are covered in [bounding agent loops](https://infro.io/blog/bound-ai-agent-loops).

**Expect the cap to trip mid-session.** A hard cap on a provider-held session means the next call fails while the session still holds state. Decide in advance whether that ends the session, pauses it for a human, or lets the current turn finish. Test it, including the 409 case: changing `review` while a task is active returns `409 Conflict` and applies none of the updates in that request[2], so a cap handler that tries to switch review off under load has to retry after the task is idle.

## Failure modes to test

- **Resumed sessions keep old settings.** Because `review` persists on resume[2], a session created last week with review on keeps billing reviewer tokens after you thought you turned it off in config. Retrieve or list sessions and read the saved value; if the response omits the field, treat it as `"none"`[2].
- **Blocking and background compare unfairly across days.** Run both settings in the same window, interleaved, not one this week and one next.
- **A denial counted as a failure.** A task that stops because review denied an action is a different outcome from a model error. Record it separately or your success rate and cost per successful task will mislead; see [cost per successful task](https://infro.io/blog/cost-per-successful-task).
- **Experimental time awareness.** The same October 30 entry added `experimental.time_awareness`, off by default, which gives the model periodic current-time reminders[1]. Leave it off during the matrix so it does not add a third variable.
- **Retention of your own records.** If you rely on a vendor-side or gateway-side history window to run the comparison, check how long it is before the second-day repeat.

## Where a gateway helps, and where it does not

Whether a gateway sees compaction and review work depends on whether those calls pass through it. For provider-held sessions, much of that work happens inside the provider, so a gateway log can show less than the provider's bill. [Provider-held threads or your own history](https://infro.io/blog/provider-held-threads-or-your-own-history-what-a-gateway-owns) goes through the ownership question.

INFRO's documentation lists `POST /v1/responses` among its agent API endpoints, and pointing the OpenAI Agents SDK at INFRO is a change of base URL and key[4]. I did not confirm that the Agents API's `/v1/agents/sessions` resource is served this way, so check before assuming it is. Where traffic does go through INFRO, per-request usage and estimated provider cost, budgets and spend attribution are available, and spans can be pushed to your own collector over OTLP/HTTP with token counts and estimated cost; the docs say trace delivery is best effort and should not be the sole accounting record[5]. Daily reconciliation of estimated spend against OpenAI's cost API is the check that catches the unattributed share described above. Use it as a cross-check on the matrix, not a replacement for it.

## Questions

### Do I have to turn automatic review on?

No. Omitting the review field defaults to none, and the setting persists when a session resumes [2]. Note that none does not route actions to your application for manual approval, so decide deliberately what your approval path is.

### Can I change review in the middle of a task?

Not while the main task is active or input submission has not settled: the request returns 409 Conflict and none of the updates in it are applied [2]. Retry when the session is idle, and handle the 409 even if you checked status first.

## Sources

1. Changelog (OpenAI API), entries of Oct 30, Oct 9 and Oct 16, 2026 — OpenAI. https://developers.openai.com/api/docs/changelog.md (accessed 2026-11-08)
2. Automatic review (Agents API sessions) — OpenAI. https://developers.openai.com/api/docs/guides/agents-api/sessions/approvals.md (accessed 2026-11-08)
3. Generative AI semantic conventions (moved notice) — OpenTelemetry. https://opentelemetry.io/docs/specs/semconv/gen-ai/ (accessed 2026-11-08)
4. INFRO documentation overview — INFRO. https://infro.io/docs (accessed 2026-11-08)
5. Exports & OpenTelemetry — INFRO. https://infro.io/docs/observability/exports (accessed 2026-11-08)
