Interface AgentFn<S>

Type Parameters:
S - the type of the custom session state
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AgentFn<S>
Custom agent handler: runs one invocation's turn loop body for ONE turn at a time via the runner.

Implementations receive the SessionRunner (giving access to session state, messages, and artifacts) and an AgentFnContext (chunk emitter, abort signal). Task 4.5 ( defineCustomAgent) wraps this interface.

  • Method Details

    • run

      Runs one turn of agent logic.
      Parameters:
      sess - the session runner for reading/mutating session state
      ctx - per-invocation context (streaming and abort support)
      Returns:
      the agent result for this invocation
      Throws:
      Exception - if the agent fails; callers should propagate or handle appropriately