codex - 💡(How to fix) Fix Add opt-in BeforeModelRequest context-transform hook with strict request-integrity guardrails [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#22036Fetched 2026-05-11 03:20:27
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Code Example

trait ContextTransform {
    fn transform(&self, items: Vec<ResponseInputItem>) -> TransformResult;
}
RAW_BUFFERClick to expand / collapse

Upstream Submission Package

Title

Add opt-in BeforeModelRequest context-transform hook with strict request-integrity guardrails

Issue Body (copy/paste)

Problem statement

Codex hooks can currently prune tool output and inject memory, but there is no supported point to safely transform the full model request immediately before send. This blocks Dynamic Context Pruning use cases that require ordered-item transformation with integrity checks instead of post-hoc compression only.

Proxy-based request rewriting can help in some local HTTP flows, but it is outside Codex core and depends on request shape compatibility. A first-class, guarded extension point is needed inside Codex itself.

Minimal API contract

Please consider an opt-in BeforeModelRequest hook that receives ordered request items and returns one of:

  • continue with original items (no-op);
  • transformed ordered items;
  • structured refusal/diagnostics while fail-opening to original request.

Minimal conceptual shape:

trait ContextTransform {
    fn transform(&self, items: Vec<ResponseInputItem>) -> TransformResult;
}

An external command JSON contract is also acceptable if that aligns better with Codex hook architecture; the core requirement is deterministic validation of transformed item order and structure before send.

Safety constraints

The feature should be disabled by default and gated by:

  • trusted workspace or explicit user opt-in;
  • strict runtime timeout;
  • max transformed payload size;
  • schema validation;
  • tool call/result pair integrity enforcement;
  • user/system/developer message immutability by default;
  • redacted audit diagnostics;
  • fail-open behavior on timeout/crash/invalid transform.

Rejected transform payloads should include (at minimum):

  • result without prior call;
  • call without corresponding result where pairing is required;
  • unauthorized changes to protected roles/instructions;
  • schema-invalid items.

Acceptance questions for maintainers

  1. Is BeforeModelRequest acceptable as an upstream extension point?
  2. Should this be implemented as an external command hook, plugin API surface, or internal guarded hook first?
  3. What minimum validation contract is required for transformed ordered input items?
  4. Are there preferred defaults for runtime budget, redaction, and fail-open behavior?
  5. What test evidence would be required for upstream consideration (synthetic fixtures, replay harness, compatibility matrix)?

Submission checklist

  • Confirm preferred API surface (external hook vs plugin vs internal extension point).
  • Confirm validation requirements for tool call/result integrity.
  • Confirm policy for protected message roles/instruction immutability.
  • Confirm acceptance criteria for initial PR scope (feature flag + tests + docs).
  • Confirm maintainers' expectations for compatibility coverage across providers/auth modes.

Local submission-readiness evidence (2026-05-10)

  • gh auth status failed: default account token is invalid for github.com.
  • Repository remote is configured: origin https://github.com/hungcuong9125/codex-dcp.git.
  • Next action: re-authenticate with gh auth login -h github.com, then open the issue using the body above.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Add opt-in BeforeModelRequest context-transform hook with strict request-integrity guardrails [1 comments, 2 participants]