feat(rawr): add RAWR post-turn auto-compaction policy and config#29
Draft
mateicanavra wants to merge 11 commits into
Draft
feat(rawr): add RAWR post-turn auto-compaction policy and config#29mateicanavra wants to merge 11 commits into
mateicanavra wants to merge 11 commits into
Conversation
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e2b0a81 to
466223e
Compare
e1adf10 to
7c6edae
Compare
d1a85a9 to
2c13ccb
Compare
7c6edae to
d891818
Compare
2c13ccb to
e3a041a
Compare
d891818 to
ab69346
Compare
e3a041a to
3ada214
Compare
ab69346 to
4a9f998
Compare
8ce0718 to
d854193
Compare
4a9f998 to
f0fa7a9
Compare
Add the RAWR auto-compaction feature/config surface on the current upstream config and feature crates, including schema regeneration for the new policy shape. Run post-turn auto-compaction from the current session task lifecycle immediately after TurnComplete, detaching the finished task from active-turn routing before awaiting compaction while keeping its task handle alive until completion bookkeeping finishes. Preserve the app-server-visible ContextCompaction flow through the existing compact implementations, prepend post-compact handoff context ahead of queued next-turn input, and document the current prompt/runtime semantics. Add focused RAWR policy/prompt tests plus an app-server v2 parity test covering automatic turn-complete compaction ordering.
Clear Bazel remote downloader settings when BuildBuddy is disabled, and make npm native artifact staging resolve upstream release workflows from openai/codex by default. Add an idempotent Desktop --ensure patch path for post-update adoption checks, document that hook, and keep Cargo lock package versions aligned with the 0.126.0-alpha.3 fork release. Stabilize load-sensitive agent-control persistence waits that failed only under the full local gate.
d854193 to
3f77bef
Compare
Move PR checks off unavailable OpenAI/internal runner labels in the fork: Bazel macOS jobs now use standard hosted macOS labels, rust-ci argument-comment lint uses hosted Windows, and sdk uses hosted Ubuntu. Format the agent docs that the root CI Prettier gate already flagged.
Avoid false red macOS PR lanes in the fork when BuildBuddy credentials are unavailable. The macOS Bazel and argument-comment lint paths need the authenticated BuildBuddy downloader/cache for the hermetic Apple SDK; without it GitHub-hosted macOS receives a 403 from Apple's CLTools package URL before any Codex code builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

External (non-OpenAI) Pull Request Requirements
Before opening this Pull Request, please read the dedicated "Contributing" markdown file or your PR may be closed:
https://github.com/openai/codex/blob/main/docs/contributing.md
RAWR automatic post-turn compaction policy
Adds a new
rawr_auto_compactionconfiguration option and the supporting runtime logic that automatically triggers context compaction after a turn completes when the model's context window is running low.Feature flag
A new
RawrAutoCompactionfeature flag (rawr_auto_compaction, stage:UnderDevelopment, off by default) gates all RAWR compaction behavior. Settingrawr_auto_compaction = trueinconfig.tomlenables the feature, or a structured[rawr_auto_compaction]table can be used for fine-grained control.Configuration schema (
RawrAutoCompactionToml)The new config type accepts either a plain boolean or a structured object with the following fields:
mode–tag,suggest, orauto(defaultauto). Intag/suggestmode a warning event is emitted instead of running compaction.packet_author–watcher(default) oragent. Controls who writes the post-compaction continuation context packet.scratch_write_enabled– when true, the agent is asked to write a scratchpad file before compaction so research notes survive history rewrite.compaction_model/compaction_reasoning_effort/compaction_verbosity– optional overrides for the compaction call.policy– per-tier thresholds and boundary requirements across four tiers:early,ready,asap, andemergency.Default percent-remaining thresholds are 85 / 75 / 65 / 15 for early / ready / asap / emergency respectively.
Boundary signals
Each policy tier specifies which
RawrAutoCompactionBoundarysignals must be observed before compaction fires:commit,plan_checkpoint,plan_update,pr_checkpoint,agent_done,topic_shift,concluding_thought, andturn_complete. Emergency tier always fires unconditionally. Plan boundaries can optionally require a semantic break (plan_boundaries_require_semantic_break) before they count.Runtime (
rawr_auto_compaction.rs/rawr_prompts.rs)rawr_should_compact_at_turn_completeevaluates tier eligibility and boundary satisfaction.rawr_build_watcher_post_compact_packetconstructs a structured continuation context packet injected as the first user message of the next turn.rawr_build_agent_continuation_packet_promptcombines scratch-write and packet prompts whenpacket_author = agent.<codex_home>/auto-compact/auto-compact.mdandscratch-write.md, with built-in defaults written on first use.{scratchFile},{threadId}, etc.) and YAML front-matter stripping are supported.Session integration
on_task_finishednow accepts aTaskKindparameter. ForTaskKind::Regularturns,maybe_run_rawr_post_turn_auto_compactionis called after the turn completes. It computes percent-remaining from total token usage and the configuredmodel_context_window, selects the appropriate inline compact task (local or remote), and queues the handoff message for the next turn. Active-turn cleanup is deferred until after RAWR compaction runs.Tests
rawr_turn_complete_auto_compaction_emits_started_and_completed_itemsverifies that enabling the feature with amodel_context_windowset causes compaction started/completed items to be emitted after a turn that exceeds the threshold.