Back to prompt library
Implement Simulated Secure Data Tools
Linked challenge: Secure Personal Intelligence Agent with Google ADK & Gemini 2.5 Pro
Prompt source
implementation14 lines4 sectionsNo variables1 code block
Develop Python classes that simulate secure access to personal data (Gmail, Google Photos). These tools should expose methods like `read_emails(user_id, consent_level)` or `analyze_photos(user_id, tags, consent_level)`. Crucially, each method must check a `consent_level` parameter before returning any data, simulating a secure access mechanism. Integrate these as custom tools for your Google ADK agent.
```python
from google_adk.tools import Tool, tool_decorator
# from vertexai.preview.generative_models import GenerativeModel
# @tool_decorator
# class SimulatedGmailReader(Tool):
# def call(self, user_id: str, consent_level: dict):
# if consent_level.get('email') == 'full':
# # Simulate fetching emails
# return [{"subject": "Meeting", "body": "Details..."}]
# return "Access denied to email data."
# agent = create_agent(model=GenerativeModel("gemini-2.5-pro"), tools=[SimulatedGmailReader()])
# agent.run_conversation("user123", "Summarize my latest emails.")
```