Skip to content

Keep a PDF's title once and never print a chart marker as text - #271

Merged
MikeAlhayek merged 1 commit into
mainfrom
ma/pdf-title-and-chart-text
Oct 16, 2026
Merged

MikeAlhayek merged 1 commit into
mainfrom
ma/pdf-title-and-chart-text

Conversation

@MikeAlhayek

Copy link
Copy Markdown
Member

Problem

Asked for a report with the charts of the conversation, gpt-4.1 produced a PDF that:

  • opened with its title twice: it sent the title heading with create_pdf and again at the start of add_pdf_content;
  • printed [chart:Refer to chart marker above] under each chart heading where the chart should be: it wrote a placeholder marker as a paragraph, and text is printed as written. Only image and chart blocks were checked for chart markers.

Changes

In PdfBlockPreparer, for blocks the model writes (content converted from a file is not changed):

  • Repeated heading. A heading that repeats the heading right before it, with nothing between (same words, case and spacing ignored), is left out, both within a call and against the block the new content follows. add_pdf_content passes that block for append, insert and replace. The agent is told the heading was left out and to send only new content. A heading used again later, with content between, is kept.
  • Chart marker text. A paragraph or markdown block that is one whole [chart:{…}] marker with plottable data becomes that chart. Any other chart marker in a paragraph, heading, title or list fails the call ("Nothing was added") and lists the ways to add a chart, including conversation_chart, and the charts of the conversation. Code blocks are left as written.
  • The PDF agent prompt says never to write a marker or a placeholder for one in text.
  • Docs: Good to know in the PDF section of AI Documents, and the 2.0.0 changelog.

Tests

  • PdfRepeatedContentTests (new): title repeated across create_pdf and add_pdf_content, the same heading twice in one call, a heading used again with content between (kept), the placeholder marker (refused), a whole marker as a paragraph (drawn as the chart), and a marker inside a sentence (refused). Five of the six failed before the fix.
  • Full .NET suite (4677) passes with -warnaserror -p:TreatWarningsAsErrors=true -p:RunAnalyzers=true; the docs build passes.
  • In the MVC sample on gpt-4.1, "two charts in the chat, then a PDF report with them" gave a 6-page PDF with the title once, both charts drawn and no marker text. The model did not repeat either mistake in that run, so the new rules did not fire there; the tests are what cover them.

Asked for a report with the charts of the conversation, gpt-4.1 sent the
title heading with create_pdf and again at the start of add_pdf_content,
and wrote "[chart:Refer to chart marker above]" as a paragraph under each
chart's heading. The file opened with its title twice and printed that
line where each chart should be.

- A heading that repeats the heading right before it, with nothing
  between, is left out, within a call and against the block the new
  content follows, and the agent is told to send only what is new.
- A paragraph that is a whole [chart:{...}] marker is drawn as that chart.
  Any other chart marker in a paragraph, heading or list fails the call
  with the ways to add a chart and the charts of the conversation.
- Content converted from a file is not changed by either rule.
@MikeAlhayek
MikeAlhayek merged commit 76ca35e into main Oct 16, 2026
11 checks passed
@MikeAlhayek
MikeAlhayek deleted the ma/pdf-title-and-chart-text branch October 16, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant