Skip to content

Commit c4305eb

Browse files
committed
feat: Rich Approval Mechanism for Human in the loop Tool Approvals
1 parent 14cf910 commit c4305eb

25 files changed

+2608
-5
lines changed

src/google/adk/approval/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# from .approval_handler import ApprovalHandler
16+
# from .approval_tool import ApprovalConfig
17+
# from .approval_processor import request_processor
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from __future__ import annotations
2+
from datetime import datetime
3+
from enum import Enum
4+
from typing import Literal, Optional
5+
6+
from pydantic import BaseModel
7+
8+
9+
class ApprovalActor(BaseModel):
10+
id: str
11+
type: str = Literal["user", "agent", "tool"]
12+
on_behalf_of: ApprovalActor | None = None
13+
14+
15+
class ApprovalEffect(str, Enum):
16+
allow = "allow"
17+
deny = "deny"
18+
challenge = "challenge"
19+
20+
21+
ApprovalAction = str
22+
ApprovalResource = str
23+
24+
25+
class ApprovalGrant(BaseModel):
26+
"""Effect the actions on the resources to the grantee by the grantor until the expiration."""
27+
28+
effect: Literal[ApprovalEffect.allow, ApprovalEffect.deny]
29+
"""Whether to grant an allow or deny."""
30+
actions: list[ApprovalAction]
31+
"""The actions to which the grant will effect."""
32+
resources: list[ApprovalResource]
33+
"""The resources that this grant affects."""
34+
grantee: ApprovalActor
35+
"""Who the grant applies to."""
36+
grantor: ApprovalActor
37+
"""The permission holder that granted toe access (e.g. user, or delegated by a parent agent)."""
38+
expiration_time: Optional[datetime] = None # Optional expiration time
39+
"""The time after which the grant ceases to be valid."""
40+
41+
comment: Optional[str] = None
42+
"""Comment from the grantor (typically the end user) from the point of granting. This is used when communicating a grant update to a model, for example a deny, to explain the reason."""

0 commit comments

Comments
 (0)