8000 Feature: Secure Link Masking/Unmasking in Agent Responses · Issue #1565 · google/adk-python · GitHub
[go: up one dir, main page]

Skip to content
Feature: Secure Link Masking/Unmasking in Agent Responses #1565
Open
@AdityaBavadekar

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot_triagedcoreIssues related to the core interface and implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0