runAgent

open suspend override fun runAgent(item: TrainSetItem<Input, InputLabel>, agentToRun: GraphAIAgent<Input, Output>, retryPolicy: RetryPolicy?): Result<CompletedAgentRun<Output>>

Runs agentToRun on item and records exactly one leaf entry under the current stage — AgentRunRecord.Completed on success, or AgentRunRecord.Failed on any failure (regular exception, retry-exhausted transient, or ExecutionAbortException).

Transient-failure retries are applied automatically per the session's retry policy (overridable via retryPolicy); per-attempt detail lives in the resulting record's previousAttempts.

Abort handling. ExecutionAbortException can arise from two sites:

  • From inside agent.run(...) itself (currently theoretical — the project's only abort policy fires from recompute callbacks, not from agent code). The retryWith onAbort hook records a Failed leaf with the abort's resolvedId AND every preceding failed-retry captured up to that point; retryWith then rethrows the abort after the hook returns. The post-add recompute inside the hook is safe because AbortController is one-shot.

  • From inside the post-add recomputeMetricsAndUpdate() (spend-cap trip, etc.). The leaf is already recorded, so the abort just propagates out of this method without further bookkeeping.

Aborts always trump retries: retryWith's own abort short-circuit catches the exception and rethrows immediately without entering the retry loop.