2626from ....agents .invocation_context import InvocationContext
2727from ....agents .readonly_context import ReadonlyContext
2828from ....events .event import Event
29+ from ....features import FeatureName
30+ from ....features import is_feature_enabled
2931from ....models .llm_request import LlmRequest
3032from ....tools .base_tool import BaseTool
3133from ....tools .tool_confirmation import ToolConfirmation
3234from ....tools .tool_context import ToolContext
33- from ....utils .feature_decorator import _is_truthy_env
3435from .._base_llm_processor import BaseLlmRequestProcessor
3536from ..agent_transfer import _build_transfer_tool
3637from ..agent_transfer import _get_transfer_targets
@@ -255,9 +256,6 @@ def _map_confirmation_to_original_fc_ids(
255256 return mapping
256257
257258
258- _STRICT_CALLER_PRINCIPAL_ENV = "ADK_STRICT_CALLER_PRINCIPAL"
259-
260-
261259def _apply_caller_principal_gate (
262260 invocation_context : InvocationContext ,
263261 confirmations_by_fc_id : dict [str , ToolConfirmation ],
@@ -286,9 +284,10 @@ def _apply_caller_principal_gate(
286284 produces -- so the tool returns its rejection response and the turn ends with
287285 a reason the caller can see.
288286
289- Strict mode is opt-in for now, so upgrading cannot break a working
290- deployment that runs its A2A server without an authenticator; those get a
291- warning instead. The intent is to flip the default at the next major version.
287+ Strict mode is the STRICT_CALLER_PRINCIPAL feature, off by default for now
288+ so that upgrading cannot break a working deployment that runs its A2A server
289+ without an authenticator; those get a warning instead. The intent is to flip
290+ the registry default at the next major version.
292291
293292 Args:
294293 invocation_context: Current invocation context.
@@ -302,24 +301,22 @@ def _apply_caller_principal_gate(
302301 if principal is None or principal .authenticated :
303302 return confirmations_by_fc_id
304303
305- if not _is_truthy_env ( _STRICT_CALLER_PRINCIPAL_ENV ):
304+ if not is_feature_enabled ( FeatureName . STRICT_CALLER_PRINCIPAL ):
306305 logger .warning (
307306 "Honoring a tool confirmation from an unauthenticated caller"
308307 " (principal source %r). The serving layer could not say who sent this"
309- " approval, so it is not known to be the operator's. Set %s to refuse "
310- " these instead; that is intended to become the default in a future "
311- " major version." ,
308+ " approval, so it is not known to be the operator's. Enable the "
309+ " STRICT_CALLER_PRINCIPAL feature to refuse these instead; that is "
310+ " intended to become the default in a future major version." ,
312311 principal .source ,
313- _STRICT_CALLER_PRINCIPAL_ENV ,
314312 )
315313 return confirmations_by_fc_id
316314
317315 logger .error (
318316 "Refusing a tool confirmation from an unauthenticated caller (principal"
319- " source %r). Enable authentication on the serving layer, or unset %s to "
320- " downgrade this to a warning." ,
317+ " source %r). Enable authentication on the serving layer, or disable the "
318+ " STRICT_CALLER_PRINCIPAL feature to downgrade this to a warning." ,
321319 principal .source ,
322- _STRICT_CALLER_PRINCIPAL_ENV ,
323320 )
324321 return {
325322 confirmation_fc_id : confirmation .model_copy (update = {"confirmed" : False })
0 commit comments