Repository navigation
fix(mcp): preserve Markdown headings, lists, and table structure in context compressor - #298
ABHISHEKUPAI wants to merge 2 commits into
Conversation
…ontext compressor Signed-off-by: ABHISHEKUPAI <abhishekupai6055@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
kmr-rohit
left a comment
There was a problem hiding this comment.
This looks right to me: joining with a space turned a heading plus its bullets into one long heading line, and _join_blocks handles the cases I'd expect (heading, list, code fence, prose).
One question: are table rows separate blocks at this point, or is a whole table one block? If rows are separate, two consecutive rows are joined with \n\n, which would split the table into one-row tables. A test with a three-row table going through compress_hits would settle it.
It touches the same lines in compressor.py as #296 and sits next to #283, so whichever lands second will need a rebase.
…compressor Signed-off-by: ABHISHEKUPAI <abhishekupai6055@gmail.com>
In _split_into_blocks(), Markdown tables are recognized and appended as single atomic paragraph blocks (blocks.append(para)). Because of this, table rows are not split into individual blocks the whole table is treated as one block, preserving single newlines (\n) between rows. I have added a test with a multi-row table going through compress_hits to verify that table rows remain intact and are not split into one-row tables with \n\n. |
|
Hi @tarekabouzeid |
|
Hi @tarekabouzeid @kmr-rohit , if at all further changes are required please do let me know about the same as well happy Really appreciate your time and help on this, thank you |
|
@tarekabouzeid @SanthoshToorpu this one is reviewed and ready: could one of you add (The preview still carries #290's old |
Closes #297
Overview
In
docs-agent-mcp/mcp-server/compressor.py, the compressor previously joined selected blocks with" "whenever a chunk didn't contain a fenced code block (```).For standard documentation chunks (such as API spec parameter dictionaries, prerequisites, or troubleshooting steps), this caused headings (
### Heading) to swallow following bullet points and parameters onto a single line without newlines, turning the entire block into a single heading tag in Markdown.Changes
any(p.startswith("```"))ternary join with a structure-aware_join_blocks()helper incompressor.py.\n\n.-,*,1.) with\nto preserve list formatting.\n\nboundaries when transitioning between list items and prose/headings.tests/test_reranker_and_compressor.py.Before vs After
before
Katib Configuration - Set
parallelTrialCount: 3in the experiment spec. - Enable metrics collector.After
Katib Configuration
parallelTrialCount: 3in the experiment spec.Verification
pytest tests/test_reranker_and_compressor.py passed (13/13).
Full test suite passed (163 passed, 69 skipped).
ruff check and ruff format --check passed cleanly across docs-agent-mcp/mcp-server and tests.