Package com.google.genkit.ai.agent
Interface TurnBody<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.
The body of one agent turn. Implementations run the actual agent logic (e.g. calling the model,
executing tools) and return the
AgentFinishReason for this turn.
TurnBody is called by SessionRunner.runTurn(com.google.genkit.ai.agent.AgentInput, com.google.genkit.ai.agent.TurnBody<S>) after input validation and message
appending. On success the runner persists a COMPLETED snapshot; on exception the runner
persists a FAILED snapshot and swallows the exception.
-
Method Summary
Modifier and TypeMethodDescriptionrun(AgentInput input, TurnContext turnCtx) Runs the body of this turn.
-
Method Details
-
run
Runs the body of this turn.- Parameters:
input- the agent input for this turnturnCtx- the per-turn context (snapshot IDs, turn index)- Returns:
- the finish reason for this turn (e.g.
AgentFinishReason.STOP) - Throws:
Exception- if the turn body fails; the runner will catch and record a FAILED snapshot
-