Skip to content

Refine insert links agent for URL preservation#128

Merged
rasulkireev merged 1 commit intomainfrom
link-hallucinations
Dec 1, 2025
Merged

Refine insert links agent for URL preservation#128
rasulkireev merged 1 commit intomainfrom
link-hallucinations

Conversation

@rasulkireev
Copy link
Copy Markdown
Owner

@rasulkireev rasulkireev commented Dec 1, 2025

Updated the instructions for the insert_links_agent to enforce stricter rules regarding existing links and new link insertion. The primary goal is to ensure the integrity of existing content.

Key changes include:

  • Added explicit rules preventing the removal of any existing links.
  • Implemented a critical constraint: existing link URLs must remain EXACTLY the same and must not be changed, updated, or corrected under any circumstances.
  • Clarified that while reference-style links can be converted to inline format, their original URLs must be preserved.
  • Emphasized that new links can ONLY be inserted from the provided project pages and only if they are not already present in the document.
  • Revised examples to clearly illustrate these new constraints, especially concerning URL preservation during formatting corrections.
  • The agent's role is now more precisely defined as formatting existing links without altering their URLs and inserting new links from a specific list.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced link management system with improved preservation rules. Existing URLs are now fully protected against unintended modifications. The system enables controlled text formatting corrections and addition of new links from designated project sources. All current references maintain complete integrity and remain unchanged.

✏️ Tip: You can customize this high-level summary in your review settings.

Updated the instructions for the `insert_links_agent` to enforce stricter rules regarding existing links and new link insertion. The primary goal is to ensure the integrity of existing content.

Key changes include:
- Added explicit rules preventing the removal of any existing links.
- Implemented a critical constraint: existing link URLs must remain EXACTLY the same and must not be changed, updated, or corrected under any circumstances.
- Clarified that while reference-style links can be converted to inline format, their original URLs must be preserved.
- Emphasized that new links can ONLY be inserted from the provided project pages and only if they are not already present in the document.
- Revised examples to clearly illustrate these new constraints, especially concerning URL preservation during formatting corrections.
- The agent's role is now more precisely defined as formatting existing links without altering their URLs and inserting new links from a specific list.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The insert links agent's instructions were modified to shift from restrictive link modification policies to a controlled formatting workflow. Existing links are now explicitly preserved (URL immutability) while allowing anchor-text adjustments, and new link insertions from project pages are permitted.

Changes

Cohort / File(s) Summary
Agent Instructions Update
core/agents/insert_links_agent.py
Modified link handling rules to prohibit removal and URL changes of existing links, added "HANDLING EXISTING LINKS - FORMATTING CORRECTION ONLY" section, and clarified that only new links from provided project pages may be inserted.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Single file with instruction/configuration text changes only
  • No code logic or structural modifications
  • Review scope: verify instruction clarity and correctness of guidelines

Poem

🐰 Links preserved with pristine care,
Old anchors stay, though text may dare,
New links from pages, fresh and bright,
Formatting touched—but URLs tight!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch link-hallucinations

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 951bf32 and 875697f.

📒 Files selected for processing (1)
  • core/agents/insert_links_agent.py (2 hunks)

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 and usage tips.

@rasulkireev rasulkireev merged commit 86f3e32 into main Dec 1, 2025
2 of 3 checks passed
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 1, 2025

Greptile Overview

Greptile Summary

This PR refines the insert_links_agent system prompt to enforce stricter URL preservation rules when inserting links into blog posts.

Key changes:

  • Added explicit rules preventing removal of existing links (rule 4)
  • Added critical constraint that existing URLs must remain exactly unchanged (rule 5)
  • Clarified that only NEW links from provided project pages should be inserted (rule 6)
  • Added new "PRESERVING EXISTING LINK URLS" section with detailed guidelines
  • Updated examples to clearly illustrate URL preservation during formatting corrections
  • Expanded the dynamic prompt instructions from 4 to 8 items for better clarity

The changes address a specific use case where the AI agent was potentially modifying or "fixing" existing URLs in blog posts, which could break valid links or alter citations. The new instructions make it clear that while reference-style links can be converted to inline format, the underlying URL must never change.

Confidence Score: 5/5

  • This PR is safe to merge - it contains only prompt text refinements with no code logic changes.
  • Score of 5 reflects that this is a low-risk change affecting only AI agent prompt text. The Python syntax is valid, and the changes improve clarity and constraint enforcement without altering any code logic, data models, or API behavior.
  • No files require special attention.

Important Files Changed

File Analysis

Filename Score Overview
core/agents/insert_links_agent.py 5/5 Refined AI agent prompt to enforce strict URL preservation rules. Changes are well-structured, clear, and include comprehensive examples. No issues found.

Sequence Diagram

sequenceDiagram
    participant User
    participant GeneratedBlogPost
    participant InsertLinksAgent
    participant AIModel

    User->>GeneratedBlogPost: Request link insertion
    GeneratedBlogPost->>GeneratedBlogPost: Collect project pages & external pages
    GeneratedBlogPost->>InsertLinksAgent: Create agent with refined prompt
    GeneratedBlogPost->>AIModel: Run agent with blog content & pages
    Note over AIModel: Apply URL preservation rules:<br/>1. DO NOT change existing URLs<br/>2. Convert reference-style to inline<br/>3. Insert only NEW links from provided pages
    AIModel-->>GeneratedBlogPost: Return content with links
    GeneratedBlogPost->>GeneratedBlogPost: Save updated content
    GeneratedBlogPost-->>User: Content with links inserted
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

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