AgentInvocation.withExecution constructor

AgentInvocation.withExecution({
  1. required AgentExecutionGrant grant,
  2. required String residualRiskShown,
  3. required AgentScope scope,
  4. int stepBudget = defaultStepBudget,
  5. Duration timeBudget = defaultTimeBudget,
})

An invocation with execution — an explicit, per-invocation user act.

residualRiskShown must be grant's statement, exactly: the affordance that granted consent passes the text it showed.

Implementation

factory AgentInvocation.withExecution({
  required AgentExecutionGrant grant,
  required String residualRiskShown,
  required AgentScope scope,
  int stepBudget = defaultStepBudget,
  Duration timeBudget = defaultTimeBudget,
}) {
  if (residualRiskShown != grant.statement) {
    throw ArgumentError.value(
      residualRiskShown,
      'residualRiskShown',
      'execution is granted only against the residual-risk statement',
    );
  }
  return AgentInvocation._(
    invocationId: _newId(),
    origin: AgentOrigin.localAgent,
    allowExecution: true,
    scope: scope,
    stepBudget: stepBudget,
    timeBudget: timeBudget,
  );
}