feat: block-level and inline markdown rendering for LLM responses - #3
Closed
KUSH42 wants to merge 1 commit into
Closed
feat: block-level and inline markdown rendering for LLM responses#3KUSH42 wants to merge 1 commit into
KUSH42 wants to merge 1 commit into
Conversation
KUSH42
marked this pull request as draft
April 1, 2026 20:58
KUSH42
force-pushed
the
feat/tool-output-highlighting
branch
from
April 1, 2026 21:41
d9ecc84 to
47ce516
Compare
KUSH42
force-pushed
the
feat/rich-output-renderer
branch
from
April 1, 2026 21:48
83c49e9 to
8a7fad8
Compare
KUSH42
force-pushed
the
feat/tool-output-highlighting
branch
from
April 1, 2026 21:49
d3045a2 to
47ce516
Compare
…responses Adds apply_block_line (headings, hr, blockquotes, lists, ref-link suppression) and extends apply_inline_markdown (images, links, HTML inline tags). format_response gains a pass-2 that applies both renderers to every non-highlighted line. The streaming path chains the same pair in _emit_stream_text and _flush_stream. Bug fixes included: - _code_highlight_active was gating apply_block_line/apply_inline_markdown in the streaming path; removed the guard (_RICH_RESPONSE is the correct gate; _code_highlight_active controls only tool-output highlighting) - _MD_ITALIC_UNDER_RE rejected phrases with spaces; changed [^_\s\n]+ to [^_\n]+ (word-boundary lookbehind prevents snake_case false positives) - _MD_REF_LINK_RE had a $ anchor that blocked titled reference-link definitions from being suppressed; removed $ - Blockquote inline spans reset to terminal default; added reset_suffix to the apply_inline_markdown call in the blockquote branch - format_response splitlines(keepends=True) fed \n into capture groups, silently dropping block elements; switched to splitlines() + manual join - CommonMark backslash escapes (\] → ]) were passed through literally; added step-7 re.sub pass in apply_inline_markdown - Pygments plain-text lexer emits lines with no ANSI codes; pass-2 guard "\x1b" in l then fell through and applied markdown to code-fence content (### was stripped, ** rendered, etc.); _highlight now prepends \x1b[0m to bare lines so the guard is always satisfied
KUSH42
force-pushed
the
feat/rich-output-renderer
branch
from
April 1, 2026 21:49
8a7fad8 to
eff70ff
Compare
Owner
Author
|
Superseded by NousResearch#4501 |
KUSH42
pushed a commit
that referenced
this pull request
May 10, 2026
## Summary - Forwards chat-completions `timeout` into the Codex Responses stream call. - Adds total elapsed-time enforcement while the Responses stream is still yielding events. - Closes the underlying client on timeout to unblock stalled streams, then raises `TimeoutError`. - Adds focused tests for timeout forwarding and total timeout enforcement. ## Why The Codex auxiliary adapter can be used by non-interactive auxiliary work such as context compression. If the stream keeps yielding progress-like events but never completes, SDK socket/read timeouts do not necessarily protect the full operation. This makes the CLI look stuck until the user force-interrupts the whole session. This is a refreshed upstream-ready version of the earlier fork fix around `d3f08e9a0` / PR #3. ## Verification - `python -m py_compile agent/auxiliary_client.py tests/agent/test_auxiliary_client.py` - `python -m pytest -o addopts='' tests/agent/test_auxiliary_client.py::TestCodexAuxiliaryAdapterTimeout -q` - `git diff --check`
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.
PR: block-level markdown rendering
Branch:
feat/markdown-block-renderingSummary
apply_block_line(line)— single-line-detectable block elements rendered to ANSIapply_inline_markdownwith images, links, and HTML inline tagsapply_block_linebeforeapply_inline_markdownin bothformat_responseand the streaming pathWhat's rendered
# Foo#stripped## Foo### Foo#### Foo---/***/___─line across terminal> text▌gutter + dim text>> text▌- item•at depth 0,◦at 1,▸at 2,·at 31. item[ref]: https://…[img: alt]dim placeholder[text](url)<em><em>text</em><strong><strong>text</strong>Architecture
apply_block_lineis purely line-local — no lookahead or state. Two early-exit guards:"\x1b" in line— already ANSI-rendered, skip"\n" in line— multi-line block fromStreamingBlockBuffer(PR4), skipHeadings and blockquotes apply inline spans internally (with
reset_suffixset to the heading/gutter style) so a closing\033[0mfrom a span doesn't kill the outer colour.List lines do not inject ANSI, so the outer
apply_inline_markdowncall handles their inline spans naturally.Files changed
agent/rich_output.py—apply_block_line, extendedapply_inline_markdown, updatedformat_response; removed dead_MD_OL_RE; fixed_MD_REF_LINK_REto suppress titled reference-link definitionscli.py— importapply_block_line, chain in_emit_stream_textand_flush_streamtests/test_rich_output.py—TestApplyBlockLine(23 tests), 5 newTestApplyInlineMarkdowncases, 3 newTestFormatResponseInlineMarkdowncasesBug fixes included
format_responsenewline loss —splitlines(keepends=True)fed newline-bearing strings intoapply_block_linewhose capture groups stop at\n; matched block elements (heading, hr, blockquote, list) were returned without\nand concatenated with the following line. Fixed by switching tosplitlines()+ manual"\n".joinwith trailing-newline restoration.reset_suffix— inline spans inside blockquotes were resetting to terminal default instead of restoring the dim gutter style. Fixed by passingreset_suffix=_BLOCKQUOTE_ANSItoapply_inline_markdownin the blockquote branch (mirrors the existing heading branch pattern)._MD_REF_LINK_REtitled forms — the$anchor prevented suppression of reference-link definitions that include a title ([ref]: url "Title",[ref]: url (Title)). Removed$; the URL\S+is sufficient to distinguish ref-links from prose.Known interim regression
---immediately after a paragraph renders as an hr instead of a setext h2. Corrected in PR4 (StreamingBlockBufferintercepts the setext case beforeapply_block_linesees it; seedocs/spec-markdown-stateful-blocks.md). Setext headings are rare in LLM output; the interim behaviour is acceptable.Non-goals (deferred to PR4)
===/---underline)>prefix on continuation lines)