Replies: 2 comments
|
@adk-bot could you take a look at this one, please? |
|
For a Python For one issue selected by a trusted workflow, a simple pattern is to bind the resource when constructing the tool and expose only the comment body to the model: from google.adk.tools import FunctionTool
def make_comment_tool(
*, actor_id, repository, issue_number, can_comment, write_comment
):
def comment_on_assigned_issue(body: str) -> dict:
"""Add a comment to the issue assigned to this run.
Args:
body: Text to add to the assigned issue.
"""
if not can_comment(actor_id, repository, issue_number):
return {"status": "denied"}
write_comment(actor_id, repository, issue_number, body)
return {"status": "ok"}
return FunctionTool(func=comment_on_assigned_issue)Here, The backend should also enforce authorization at the write itself, using appropriately scoped credentials. Bind the full identity/resource/action tuple: an issue number alone is not unique across repositories. Avoid sharing a mutable global allowlist across users or runs, and do not treat ordinary model-editable session state as authoritative permission data. If your tool genuinely needs to accept a resource ID, compare it with the trusted run's allowed resource set and reject a mismatch before calling the backend. Injected Validation: this example was prepared with AI assistance and checked locally with Relevant implementation: |
Uh oh!
There was an error while loading. Please reload this page.
I'm building a custom FunctionTool for my own ADK agent and want to follow best practice for scoping its permissions to a single resource. Some of the GitHub sample agents in this repo (e.g. the issue triaging one) bind a tool's write access to a single issue/PR number chosen by the workflow, rather than trusting whatever id the model passes in. Is there a built-in ADK primitive for that kind of per-call authorization binding, or is implementing an allowlist set (like
AUTHORIZED_ISSUESin the Java samples) the recommended pattern for FunctionTools that take a resource id?Thanks in advance!
All reactions