Skip to content

Commit 794dc5e

Browse files
authored
fix(workflow): carry the caller principal onto the node runtime path
main now runs a root LlmAgent through the node runtime, which builds its own invocation context. Thread caller_principal through _run_node_async into _node_runner_utils.run_node_async and set it on the context after construction, the way abort_signal is, so a principal set by a serving layer reaches the confirmation gate on that path too. Without this the gate saw None (in-process caller) for every A2A-served root agent.
1 parent 96c13a2 commit 794dc5e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/google/adk/workflow/_node_runner_utils.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from ._workflow import _LoopState
4343

4444
if TYPE_CHECKING:
45+
from ..agents._caller_principal import CallerPrincipal
4546
from ..runners import Runner
4647
from ._base_node import BaseNode
4748

@@ -61,6 +62,7 @@ async def run_node_async(
6162
node: BaseNode | None = None,
6263
session: Optional[Session] = None,
6364
abort_signal: Optional[asyncio.Event] = None,
65+
caller_principal: Optional[CallerPrincipal] = None,
6466
) -> AsyncGenerator[Event, None]:
6567
"""Runs a BaseNode or Workflow in async mode."""
6668
from ..runners import _CALLER_CLOSED_EARLY_MSG
@@ -123,6 +125,12 @@ async def _run() -> AsyncGenerator[Event, None]:
123125
# signature subclasses override. Safe at this point because nothing has
124126
# derived a sub-context from this one yet.
125127
ic._attach_abort_signal(abort_signal) # pylint: disable=protected-access
128+
if caller_principal is not None:
129+
# Set here rather than passed to `_new_invocation_context`, for the
130+
# same reason as the abort signal. The serving layer established this
131+
# principal from the request it authenticated; nothing on this path
132+
# derives one from message content or event authorship.
133+
ic.caller_principal = caller_principal
126134
if node and node is not runner.agent:
127135
ic.agent = node
128136
runner._restore_branch_from_history( # pylint: disable=protected-access

0 commit comments

Comments
 (0)