feat(explorer-agents): built-in `input_context` tool — for iterative context pack building
What variant of Codex are you using?
All (App, CLI, IDE Extension) — multi-explorer / agentic workflows
What feature would you like to see?
Problem
Explorer agents describe findings in free-form prose. The lead-agent has to
re-read source files itself and cannot trust accuracy. There is no mechanism
that forces an explorer to hand off actual code instead of paraphrasing it.
Proposed: built-in input_context tool
The context pack is a regular markdown file on disk at~/.codex/context_packs/{pack_name}_{session_id}/pack.md.input_context accepts a FREEFORM string in the same grammar as apply_patch,
with one additional hunk type: *** Anchor File: — which reads verbatim code
from a real file on disk and inserts it into the pack.
Reading and editing the pack uses existing tools — shell to read,apply_patch to edit structure/headings/rationale.
Examples
Creating the pack and anchoring code:
*** Begin Patch
+# Auth token refresh flow
+> TTL misconfigured in middleware — expiry check never fires
+
+## Token expiry check
+> Root cause — condition is inverted
+
*** Anchor File: src/auth/refresh.rs:42-67
*** Anchor File: src/auth/middleware.rs:101-118
+
+## Config defaults
+> Where the TTL constant is defined
+
*** Anchor File: config/defaults.toml
+
+## Diagram
+```mermaid
+graph TD
+ A --> B
+```
*** End Patch
Re-anchoring after code changed:
*** Begin Patch
@@ ## Token expiry check
*** Anchor File: src/auth/refresh.rs:42-67
*** End Patch
*** Anchor File:
*** Anchor File: <path>[:<start>-<end>]
- Reads the specified lines (or full file) from disk
- Inserts as a fenced code block labeled with path and line range
- Computes
CODE_REF=code:<path>#L<start>-L<end>@sha256:<hash>
Path traversal and invalid line ranges are rejected. All validation
is fail-closed.
What the lead-agent receives
The markdown file — verbatim anchored code with CODE_REF hashes,
section headings, rationale, optional mermaid diagrams. Lead-agent
builds patches directly from the pack.
Multiple explorers each build their own pack; lead-agent receives all
of them and can deduplicate by CODE_REF.
Why
- Explorer saves output tokens — instead of generating large diffs and code
blocks in its output, it places anchors and the actual content is pulled
from disk automatically
- Anchored code is read directly from disk — cannot be hallucinated
- Same patch grammar the agent already uses
- Context pack is a plain file — read/edit with existing tools
- One new hunk type, zero new commands to learn
Additional information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗