Skip to content

Feature: Secure Link Masking/Unmasking in Agent Responses #1565

Closed

Description

@adityabavadekar

Please make sure you read the contribution guide and file the issues in the right place.
Contribution guide

Is your feature request related to a problem? Please describe.

When building agents that include working with signed URLs (e.g., image generation agents that generate an image, upload image to a bucket, return a response after embedding the signed link), I ran into these problems:

  • The LLM often breaks or alters the URLs (truncation, formatting changes).
  • Sensitive URLs are unnecessarily exposed to the LLM, creating privacy and security concerns.
  • Developers have to write repetitive custom logic to mask and unmask links.

Describe the solution you'd like

A standard ADK utility or base agent class that handles this pattern cleanly:

class LinkInjectorAgent(Agent):
    """
    An agent that registers two callbacks:
    1. After tool callback: extracts URLs, stores the URL-to-identifier mapping in 
        the state, and replaces the URLs with identifiers.
    2. After model callback: restores URLs from identifiers mapping after
         the LLM response is generated. Returns this modified response.
   """

Example:

Tool response:
Image URL: https://storage.googleapis.com/bucket/...

(After replacing URL with link identifier):
Image URL: <link-a2c4-1>

LLM can then generate the response using the identifier:
Here is your image: [View](<link-a2c4-1>)

Final output (After replacing identifier with url):
Here is your image: [View](https://storage.googleapis.com/bucket/...)

I’ve implemented this in my project and found it effective and reliable. It would benefit from being part of ADK as a standard pattern.

Describe alternatives you've considered

  • Letting LLM handle raw URLs (creates security and integrity risks).
  • Storing all URL mappings in a temporary JSON file and retrieving as needed (can become complex when dealing with multiple sessions).
  • Building a URL shortener with automatic expiration.
  • Instructing the LLM to refer to resources as url_1, url_2, etc., without including links - requires extra post-processing to attach URLs later.

Additional context

  • Ideal for agents working with signed URLs, tokenized URLs, or other temporary user-specific links (e.g., images, files, charts), where secure handling of URLs is critical.
  • This could be added as a utility or as part of ADK agents.

I am interested in working on this feature and can provide implementation if accepted. (since I have already implemented a working version of this concept in my project)

Activity

  1. added
    core[Component] This issue is related to the core interface and implementation
    on Jun 22, 2025
  2. added theissue type on Jul 2, 2025
  3. surajksharma07 commented on Oct 8, 2025

    @surajksharma07
    Collaborator

    Hi @adityabavadekar and thanks to everyone who participated in this thread.

    We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

    If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

    Thanks for your contribution and understanding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

core[Component] This issue is related to the core interface and implementation

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions