Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Rich Approval Mechanism for Human in the loop Tool Approvals #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
calvingiles wants to merge 15 commits into google:main
base: main
Choose a base branch
Loading
from calvingiles:feature/approval-mechanism

Conversation

@calvingiles
Copy link
Contributor

@calvingiles calvingiles commented May 14, 2025
edited
Loading

This is an initial proposal seeking feedback adds an Approval Mechanism.

This is a fully working implementation that we have begun using in our internal agents.

This mechanism allows tools to be annotated like:

@tool_policy(
 actions=["tool:local_file:read"],
 resources=resource_parameters("tool:local_file", ["path"]),
)
def read_file(*, path: str):
 try:
 with open(path, "r") as f:
 return f.read()
 except Exception as e:
 return str(e)

when you then try to use the agent, you will receive an approval request in response with the challenges that need to be granted in order to call the tool:

{
 "id": "adk-38e8d3c6-a14c-4673-b4e8-cc2e2908d64a",
 "args": {
 "grantee": {
 "id": "tool:list_directory:adk-6b26eed9-2fa7-496e-ba8f-9d75362d0e0a",
 "type": "tool",
 "on_behalf_of": {
 "id": "3a0400f2-d9d9-4909-8ec3-41f8f28c76fe",
 "type": "agent",
 "on_behalf_of": {
 "id": "calvingiles",
 "type": "user"
 }
 }
 },
 "challenges": [
 {
 "actions": [
 "tool:local_file:read"
 ],
 "resources": [
 "tool:local_file:/Users/calvingiles/eng/repos/adk-python"
 ]
 }
 ],
 "function_call": {
 "id": "adk-6b26eed9-2fa7-496e-ba8f-9d75362d0e0a",
 "args": {
 "dir_path": "/Users/calvingiles/eng/repos/adk-python"
 },
 "name": "list_directory"
 }
 },
 "name": "adk_request_approval"
}

This can then be granted by sending a message like:

{
 "name": "adk_request_approval",
 "response": {
 "grants": [
 {
 "effect": "allow",
 "actions": [
 "tool:local_file:read"
 ],
 "grantee": {
 "id": "tool:list_directory:*",
 "type": "tool",
 "on_behalf_of": {
 "id": "3a0400f2-d9d9-4909-8ec3-41f8f28c76fe",
 "type": "agent",
 "on_behalf_of": {
 "id": "calvingiles",
 "type": "user"
 }
 }
 },
 "grantor": {
 "id": "calvingiles",
 "type": "user"
 },
 "resources": [
 "tool:local_file:/Users/calvingiles/eng/repos/adk-python"
 ]
 }
 ]
 }
}

Where the grant can include wildcards so that )for example, in this case) any function call that matches these actions and resources called by this agent will be approved in the future.

This is working in our internal service, but I am interested in whether this would be suitable to include in adk directly.

Relates to the issue #640

TrevorBenson, Axibord, and tommyhutcheson reacted with eyes emoji
Copy link
Contributor Author

This PR is now significantly updated from its initial version - we are using it day to day with our UI and it is working well. I have simplified the design, but it still requires changes to the core logic - implementing it using only callbacks would be challenging as it relies on logic in the content preprocessor before the before_model_callback and it would be very hard to replicate this entirely after that preprocessor has run.

@calvingiles calvingiles force-pushed the feature/approval-mechanism branch from 4afd578 to bc77db3 Compare May 23, 2025 07:27
Copy link
Collaborator

hangfei commented May 30, 2025

@calvingiles thanks for your contribution. We will evaluate it in the upcoming weeks.

calvingiles and others added 12 commits June 4, 2025 11:16
@calvingiles calvingiles force-pushed the feature/approval-mechanism branch from e272c56 to d0d1865 Compare June 12, 2025 04:43
Copy link
Collaborator

We have released a new plugin framework. Could you try if this feature can be implemented as a plugin? 162228d

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /