Skip to content

fix: reduce compact citation marker scaling (#118)#123

Open
yyiilluu wants to merge 1 commit into
mainfrom
fix/issue-118-compact-citation-marker
Open

fix: reduce compact citation marker scaling (#118)#123
yyiilluu wants to merge 1 commit into
mainfrom
fix/issue-118-compact-citation-marker

Conversation

@yyiilluu

@yyiilluu yyiilluu commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Change compact citation guidance from a prebuilt all-memory citation marker to example-based instructions.
  • Keep injected memory detail URLs available while telling the model to cite only memories it actually used.
  • Update compact context and UserPromptSubmit tests to guard against over-citation regressions.

Test Plan

  • uv run --project plugin pytest tests/test_context_format.py tests/test_events.py -q
  • git diff --check

Fixes #118

Summary by CodeRabbit

  • Bug Fixes

    • Updated citation rendering so only used items are shown, with clearer separator formatting and simpler final-marker guidance.
    • Refined compact citation output for Markdown, OSC8, and plain-text styles to match the expected visible format.
    • Improved context-related messaging so it no longer suggests prebuilt citations for unused entries.
  • Tests

    • Adjusted coverage to reflect the new citation output and formatting rules across inline, OSC8, and remote-reference cases.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The _compact_citation_instruction function in context_format.py was simplified to ignore marker_parts entirely, now emitting a fixed instruction string based only on citation enablement and link style, rather than building a per-call "copy exactly" marker. Tests were updated to match, including a new non-prebuilding test.

Changes

Compact Citation Instruction Simplification

Layer / File(s) Summary
Instruction generation logic
plugin/src/claude_smart/context_format.py
_compact_citation_instruction no longer uses marker_parts to build an exact final marker; it now emits a fixed guidance template based solely on the citations toggle and link style (osc8 vs markdown).
Test expectations for new instruction behavior
tests/test_context_format.py, tests/test_events.py
Tests updated to assert absence of the old "copy this final marker exactly" phrasing, presence of cs_cite.MARKDOWN_EXAMPLE_ONE and separator guidance, updated OSC8 multi-link expectations, plain-text formatting for reflexio remote entries, and a new test confirming unused items are not pre-cited.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: simplifying compact citation marker scaling.
Linked Issues check ✅ Passed The changes replace the all-memory compact marker with example-based guidance and update tests to prevent over-citation, matching #118.
Out of Scope Changes check ✅ Passed The PR stays focused on compact citation guidance and its tests, with no obvious unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-118-compact-citation-marker

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugin/src/claude_smart/context_format.py (1)

223-250: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Remove the dead marker_parts work from compact rendering

render_inline_compact_with_registry still builds marker_parts for every entry and passes it into _compact_citation_instruction(), but that helper immediately discards the argument. Drop the list construction and the parameter so compact rendering no longer does per-entry link formatting that is never used.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugin/src/claude_smart/context_format.py` around lines 223 - 250, The
compact citation path in render_inline_compact_with_registry still builds
marker_parts even though _compact_citation_instruction ignores it, so remove the
per-entry link formatting work and stop passing that unused data through the
call. Update the render_inline_compact_with_registry flow to only collect the
rendered skill/preference items and adjust _compact_citation_instruction
accordingly so its signature no longer accepts the discarded marker input.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@plugin/src/claude_smart/context_format.py`:
- Around line 223-250: The compact citation path in
render_inline_compact_with_registry still builds marker_parts even though
_compact_citation_instruction ignores it, so remove the per-entry link
formatting work and stop passing that unused data through the call. Update the
render_inline_compact_with_registry flow to only collect the rendered
skill/preference items and adjust _compact_citation_instruction accordingly so
its signature no longer accepts the discarded marker input.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b63e3ac8-44a0-4653-8fb5-68618291876e

📥 Commits

Reviewing files that changed from the base of the PR and between 0f12576 and 7124585.

📒 Files selected for processing (3)
  • plugin/src/claude_smart/context_format.py
  • tests/test_context_format.py
  • tests/test_events.py

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.

Compact citation marker scales O(N) and forces over-citation of all injected memories

1 participant