Skip to content

Reusable policy references and scoped context retrieval for auto-review and compaction #51017

Open

Description

@coreycoto

What variant of Codex are you using?

Codex App and CLI.

What feature would you like to see?

Provide a supported way to attach a small policy clarification to named, scoped context sources that Codex can resolve consistently for the working agent and the automatic approval reviewer. Start by referencing already-applied global and project guidance; optionally support narrowly selected advisory memory and authenticated original conversation records. Make source resolution and omission visible in diagnostics.

The goal is one authored working agreement plus a useful directed nudge, rather than maintaining another long policy body in reviewer configuration or depending on an ambiguous instruction to read an arbitrary path.

For example, a user could keep the rules for routine PR repair, validation and separately approved promotion in one AGENTS section. The reviewer supplement could say:

Assess this action against current task authorization and the applied autonomy guidance. Use permitted inspection when relevant context is missing.

That short clarification should point to a defined source/context object. It should not implicitly replace the default security policy or grant permission for unrelated actions.

This request does not require a particular TOML spelling. A path-only extra_policy_file would address some authoring duplication, but a reference to the already-applied snapshot would additionally preserve environment, version and authority information without rereading a changed file during the same decision.

What problem does this solve?

A long-running development task often contains a working agreement, task authorization, exceptions and later corrections. The working agent and reviewer need to interpret the same applicable agreement while distinguishing routine continuation from a new consequential action.

Today, users can compose AGENTS files and literal reviewer supplements themselves. However, a short instruction to “consult my global guidance” leaves unanswered:

  • Which applied source, home, repository or section is intended?
  • Is the reviewer using the same captured revision as the agent, a newer on-disk file or a stale summary?
  • Was that source included, deliberately excluded, unavailable or omitted by a budget?
  • Can relevant advisory context be recovered after compaction without copying a growing body of prose into every policy?
  • When authorization depends on an earlier user answer, can the reviewer trace the answer to the original question and check later restrictions?

Larger policy copies drift. A summary can preserve the rough intent while losing an exact target, delivery stage or revocation. Reviewers may then ask again for already-authorized routine work, or reason from stale context. Conversely, importing all memories would risk unrelated context affecting a decision. The desired behavior is directed, bounded retrieval with explicit provenance.

Why is it important?

Useful autonomy depends on consistent interpretation of current authorization. Repeated approval loops interrupt work; broad “always allow” workarounds weaken the distinction between routine repair and newly authorized publication, deployment or access changes.

A reusable context reference would let users maintain one understandable policy and make small, purposeful clarifications in reviewer configuration. It would also make a denial actionable: diagnostics could distinguish a policy restriction from missing context, an omitted source or an unresolved provenance conflict.

Token and latency benefits should be measured. References could reduce repeated policy copies and redundant file exploration, but resolving a source still consumes context and time. This is an improvement to context selection and lifecycle, not a promise of token-free recall.

What is already implemented?

This proposal builds on existing public implementation, inspected at Codex CLI 0.160.0 and upstream main 7f892275e31002f0422477c6219189284560e689:

Public source inspection does not establish the effective private desktop backend or each account's server feature rollout.

Proposed behavior

  1. Reuse applied sources. Allow a nudge to identify a named global, organization or project guidance section already present in the applied instruction snapshot. Preserve the source's original authority level and provenance. Avoid assigning file content a higher priority merely because reviewer configuration refers to it.

  2. Capture one coherent decision snapshot. Record source identity, scope, section, content version/hash and availability with the review request. Both agent and reviewer should resolve the same relevant snapshot for an action. A later applicable instruction or source refresh should invalidate cached context explicitly, following existing instruction-reuse semantics.

  3. Offer scoped recall separately. With explicit owner opt-in, permit bounded retrieval of relevant advisory memory or original conversation evidence. Resolve the active environment and configured Codex home correctly. Exclude unrelated projects by default, and preserve all existing read-permission restrictions.

  4. Preserve authorization provenance. Advisory memory can explain preferences or help locate an original grant; it must not manufacture one. Historical permission requires authentic original user attribution and context for the question, target, scope and later changes. Summaries, paths and assistant/tool claims must not become new authorization. Existing managed policy still governs.

  5. Integrate with context lifecycle. Preserve relevant source references and their metadata across compaction, resume and forks, using the existing retained-evidence machinery. Retrieve complete necessary records when resolving them. Identify missing, stale or budget-omitted context rather than silently using a partial restriction.

  6. Expose bounded diagnostics. Show which references were applied, their revisions and why a requested source was unavailable or skipped. Reviewer rationale should identify material unresolved context. Diagnostic output should reveal only the relevant excerpts or identifiers, not dump unrelated memories or whole private conversations.

These are desired semantics, not a request for unrestricted shared memory, extra writes, new permission bypasses, or automatic trust in hooks.

Use cases this opens up

  • Personal and team working agreements: maintain one autonomy/communication/approval agreement while adding a short reviewer-specific clarification.
  • Routine development versus promotion: continue authorized CI fixes and PR maintenance while checking whether an exact candidate is approved for merge, release or deployment.
  • Long-running tasks: recover the relevant agreement and original answer after compaction, resume or fork, including later scope changes and revocations.
  • Project-scoped memory recall: retrieve an applicable convention or previous decision and its source without loading all memories into every review.
  • Better compaction: retain compact source identities alongside protected original grants and restrictions, then recover necessary detail from the correct revision instead of repeatedly paraphrasing a large policy.
  • Better memory management: identify stale, superseded or unused policy memories through source versions and lifecycle events; prevent an old summary from persisting as an active instruction.
  • Debuggable approval behavior: distinguish a genuine restriction from missing evidence, incompatible prompt composition or an unresolved source.

Acceptance criteria

  • One authored policy fixture can be referenced consistently by the working agent and reviewer without duplicating its body in configuration.
  • A short nudge has a documented meaning, and diagnostics show the actual resolved source/revision.
  • Default and custom Codex homes and AGENTS override precedence resolve correctly.
  • Tests cover source changes, removals, unavailable reads, review-cache invalidation and explicit user revocation.
  • Compaction, resume, fork and bounded eviction preserve source identity and authentic answer/question relationships.
  • Omission and truncation are explicit; partial context cannot silently weaken a restriction.
  • Adversarial file or memory content cannot impersonate original user authorization or escalate its instruction priority.
  • Opt-in retrieval stays scoped and read-only, with no cross-project exposure or permission expansion.
  • Prompt delivery is tested through actual catalog/template selection, not solely by validating a configuration string.
  • Evaluation compares redundant policy tokens, retrieval latency and context-related approval failures against the current implementation.

Additional information and related reports

Issue #50309 concerns silent omission of configured extra policy when the selected catalog template lacks an insertion slot. An isolated execution of the 0.160.0 renderer with a current local cached template reproduced that omission; the bundled-template control inserted the marker. Fixing that existing bug is a prerequisite for relying on a textual nudge, but does not itself add source references or scoped memory retrieval.

Issue #47060 reports enforcement of superseded AGENTS instructions after direct same-task user replacement. It is a related provenance/revocation problem, not proof that this proposal would fix that incident.

A bounded public search on 2026-10-04 America/Los_Angeles checked extra-policy, policy-reference/file, reviewer-memory and AGENTS/auto-review issues plus related PRs. It found the reports above and PR #47125, which added the supplement. No exact feature duplicate was found in that bounded search. An additional bounded search immediately before filing found no exact duplicate.

This request includes no private repository topology, local home paths, credentials, conversation logs or project business data.

Activity

  1. added
    enhancement
    CLI
    sandbox
    context
    config
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIconfigcontextenhancementmemorysandbox

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions