Skip to content

Codex file-citation directives render as raw text: bb parses :codex-file-citation{…} then discards the parsed attributes #2933

Open

Description

@Borjampm

Summary

Codex writes file citations in the Codex-app directive format (:codex-file-citation{path=… purpose=… sheet=… range=…}). bb renders that directive as raw literal text in the middle of the assistant's prose, so every citation shows up as a wall of markup. bb already parses the directive correctly — remark-directive is in the pipeline and yields a clean textDirective node with all attributes — but remarkMessageDirectives mounts leaf directives (::name{}) only and unconditionally splices every text directive (:name{}) back as its verbatim source. The parsed attributes are discarded. I expected bb to either render the citation as a file reference or drop it, not to print the markup.

Versions and environment

  • bb 0.41.0 (desktop app), macOS 26.4 (build 25E246), Apple silicon
  • Provider: codex, codex-cli 0.152.1
  • Source read at main @ 6185c34984e3fea55b4a7ebbf047c23b8b657974
  • Occurs in both worktree and project-checkout environments; bb Connect paired (not required to reproduce)

Steps to reproduce

A. Renderer path — deterministic, no model involved.

Any assistant message whose text contains a :codex-file-citation{…} text directive renders it literally. Minimal body:

Revenue for July includes an adjustment. :codex-file-citation{path="/tmp/book.xlsx" purpose="source" artifact_kind="workbook" sheet="Sheet1" range="A1:G5"}

The same holds for any :name{…} text directive, registered or not — codex-file-citation is just the one that shows up in practice.

B. Field path — how it actually arises.

  1. Start a bb thread on the codex provider.
  2. Attach a spreadsheet or PDF with the composer's attachment button. bb stores it under ~/.bb/thread-storage/<thread-id>/Attachments/<name>.
  3. Ask a question that forces Codex to read the attachment and say where each figure came from, e.g. "Summarize the monthly revenue totals and cite the rows each number comes from."
  4. Codex answers and appends its citation in the Codex-app directive form.

Step 4 is model-dependent — not every turn emits a citation — but when it does, step A's rendering bug always follows. Codex also emits purpose="output" citations for files it wrote into the workspace, so thread attachments are not the only trigger.

Did not reproduce with: the claude-code provider, which does not emit this citation format.

Expected vs actual

Actual — verbatim from the timeline, paths redacted:

July B2C revenue includes a $264,013,444 adjustment, including $42,153,407 of VAT,
explicitly described as having no supporting boletas. :codex-file-citation{path="/Us
ers/<user>/.bb/thread-storage/<thread-id>/Attachments/<workbook>.xlsx" purpose="sourc
e" artifact_kind="workbook" sheet="Libro Diario 2025" range="A151522:G151526"}

Expected: the sentence, followed by a citation affordance — or, at minimum, nothing at all. The directive carries real provenance (sheet, range pin the exact rows behind the figure). Today that provenance is parsed, then thrown away, and the user is shown the serialization instead.

Two knock-on effects:

  • The raw directive text is indexed into thread_search_segments, so it pollutes thread search.
  • A reader skimming the answer sees what looks like a malfunction, which undercuts trust in a number that is in fact better sourced than an uncited one.

Evidence

The directive parses cleanly. Standalone check with the same remark-parse + remark-directive combination bb uses:

node.type   : textDirective
node.name   : codex-file-citation
attributes  : {"path":"…/<workbook>.xlsx","purpose":"source","artifact_kind":"workbook","sheet":"Libro Diario 2025","range":"A151522:G151526"}
source slice: :codex-file-citation{path="…

Every attribute is available. Nothing is malformed.

Where it is dropped. remarkMessageDirectives returns the literal source for any node that is not a leafDirective, before name lookup or registry lookup happens:

if (directive.type !== "leafDirective") {
return spliceLiteralDirective(parent, index, directive.type, source);
}

spliceLiteralDirective then restores the exact source slice into the text run:

},
};
}
function spliceLiteralDirective(
parent: Parent,
index: number,
type: DirectiveNodeType,
source: string,
): number {
if (type !== "textDirective") {
parent.children.splice(index, 1, {
type: "paragraph",
children: [{ type: "text", value: source }],
});
return index;
}
const previous = parent.children[index - 1];
const next = parent.children[index + 1];
if (previous?.type === "text") {
previous.value += source;
previous.position = undefined;
if (next?.type === "text") {
previous.value += next.value;
parent.children.splice(index, 2);
} else {

remark-directive is registered in the preview pipeline here, which is why the node exists to be discarded in the first place:

if (messageDirectiveMounts !== null) {
plugins.push(remarkDirective);
plugins.push([
remarkMessageDirectives,
{
mounts: messageDirectiveMounts.mounts,
registry: messageDirectiveMounts.registry,
},
]);
}

Frequency. In one bb installation: 29 occurrences across 8 threads (thr_fghc6jzzua, thr_gtp3379ggr, thr_j7ys8ph3ex, thr_na2qwx5b5h, thr_nf3bgm6naq, thr_sgddkbwnch, thr_smxthjni5h, thr_zxba8c72br), counted with:

select thread_id, count(*) from thread_search_segments
where text like '%codex-file-citation%' group by thread_id;

Observed attribute shapes across those 29: path always; purpose ∈ {source, output}; artifact_kind ∈ {workbook, spreadsheet} when present; sheet and range present for workbooks.

What you ruled out

  • Not a duplicate: searched open and closed issues for codex-file-citation, artifact_kind, "file citation", "citation directive" — no match. perf(app): replace react-markdown with Streamdown (PoC) #1317 (Streamdown PoC) and [issue sweep] Load the diff renderer and KaTeX on demand #1527 (lazy diff/KaTeX) touch the renderer but not directives.
  • Not a Codex malfunction: the directive is the Codex app's documented citation form and parses cleanly. bb is the side that does not handle it.
  • Not provider-specific to my setup: reproduces on the renderer path (A) with no provider involved at all.
  • Not a remark-directive bug: the parse output above is correct and complete.
  • Not caused by a plugin registering a colliding directive id: the leaf-only guard returns before any registry lookup.

Suggested priority and effort

Medium — hits every Codex user who attaches a file or has the agent write one; no workaround beyond ignoring the noise; no data lost, but provenance that bb already holds in parsed form is discarded. Effort likely Low-to-Medium depending on which direction is chosen:

  • Strip the directive in provider-codex — smallest diff, discards sheet/range.
  • Render it as a file chip in apps/app, reusing the existing markdown-local-file-link routing so a click opens the path; sheet/range become label and tooltip. Keeps the provenance.
  • Generalize: let remarkMessageDirectives mount text directives too and have provider-codex register a codex-file-citation message-directive slot. Most consistent with the existing plugin extension point, but changes core renderer behavior for every plugin, so it is a design call rather than a bug fix.

Happy to open a PR for whichever direction you prefer — per CONTRIBUTING.md I am filing the issue first, since the two renderer options are UI changes.

AGENT GENERATED

Activity

  1. added theissue type on Sep 2, 2026
  2. added
    ui
    provider-codex
    confirmed-repro
    on Sep 2, 2026
  3. bb-slop-cop commented on Sep 2, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

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

    confirmed-reproprovider-codexui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions