Repository navigation
fix: render Codex file citations as Markdown links, parsed the way Codex does - #698
Merged
Merged
Conversation
Codex models may cite files with `:codex-file-citation{path="..."}`. The
Codex TUI renders it as a file link, but the adapter passed it through, so
ACP clients showed the raw directive. Live messages and history replay now
turn it into a Markdown link to the file.
IJAI-5057
Replace the citation regexes with a port of Codex's directive parser (codex-rs/tui/src/assistant_directives.rs): single quotes, spaces around `=`, attributes without separating spaces, one to three colons, and the backslash-quote fallback now match Codex. A length limit bounds the scan, and Markdown escaping is a plain loop.
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.
Codex models may cite a file with
:codex-file-citation{path="policy.txt" purpose="source"}. The Codex TUI renders this as a link to the file. The adapter passed it through as plain text, so AIR showed the raw directive at the end of an answer.Codex has no setting to turn the directive off: neither the Codex instructions nor the feature flags mention it, so the model emits it on its own.
This change:
[docs/policy.txt](/workspace/docs/policy.txt). Relative paths resolve against the session cwd. Absolute paths, Windows drive paths, and URLs stay as citedcodex-rs/tui/src/assistant_directives.rs), not regexes, so it accepts the syntax Codex renders:"or'quotes, spaces around=, one to three colons, and backslashes kept literally in paths\:), as writtenThe port differs from Codex only where the adapter needs it: it parses citations alone, reports an unfinished directive for streaming, and caps a directive at 4096 characters instead of sharing a scan budget. The cap keeps the scan linear on malformed input. Link labels and targets escape a backslash before punctuation, so Markdown does not read it as an escape.
Reproduced on
mainwith a test that streams the directive across deltas: the raw text reached the client unchanged.Tests cover streaming on v1 and v2, replay on v1 and v2, and the edge cases: the Codex syntax variants, Windows paths, every split point of a streamed message, and linear time on malformed input.
standard-subagent-live.test.ts > keeps command rendering across parent attachment changesfails locally, the same way onmain.IJAI-5057