runWithSubagentScope<R> function

R runWithSubagentScope<R>(
  1. String id,
  2. R body()
)

Runs body with id published as the enclosing subagent identity. Nested scopes shadow outer ones; the value is visible to every callback executed within body's async chain (tool executions included).

Implementation

R runWithSubagentScope<R>(String id, R Function() body) =>
    runZoned(body, zoneValues: {subagentIdZoneKey: id});