Package com.google.genkit.ai.agent
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.
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 Summary
Modifier and TypeMethodDescriptionrun(SessionRunner<S> sess, AgentFnContext ctx) Runs one turn of agent logic.
-
Method Details
-
run
Runs one turn of agent logic.- Parameters:
sess- the session runner for reading/mutating session statectx- 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
-