Package com.google.genkit.ai.agent
Interface AgentTransport<S>
- Type Parameters:
S- the type of custom session state
- All Known Implementing Classes:
HttpAgentTransport,InProcessTransport
public interface AgentTransport<S>
AgentTransport abstracts how a single agent turn is executed. The in-process transport (
internal.InProcessTransport) drives a locally-defined Agent's bidi action; a remote
transport (future) would issue HTTP/RPC calls. AgentChat is written against this
interface so it can drive either.
The transport models the agent's one-turn-per-request contract: runTurn(com.google.genkit.ai.agent.AgentInput, com.google.genkit.ai.agent.AgentInit<S>, java.util.function.Consumer<com.google.genkit.ai.agent.AgentStreamChunk>)
feeds exactly one AgentInput (with its AgentInit) and returns the turn's final
AgentOutput, streaming AgentStreamChunks along the way.
-
Method Summary
Modifier and TypeMethodDescriptionAttempts to abort a pending snapshot.Retrieves a session snapshot.runTurn(AgentInput input, AgentInit<S> init, Consumer<AgentStreamChunk> onChunk) Runs ONE turn: feedsinputwithinit, collects stream chunks viaonChunk, and returns the final output.booleanReturns whether the underlying agent is server-managed (state persisted server-side) versus client-managed (state round-tripped by the caller).
-
Method Details
-
runTurn
Runs ONE turn: feedsinputwithinit, collects stream chunks viaonChunk, and returns the final output.- Parameters:
input- the turn input (user message, resume, or detach)init- the initialization carrying resume context (snapshotId / sessionId / inline state); may benullfor the very first turn of a fresh sessiononChunk- consumer invoked for each streamed chunk; may be a no-op- Returns:
- the final
AgentOutputfor the turn
-
getSnapshot
Retrieves a session snapshot.- Parameters:
req- the request specifying which snapshot to retrieve- Returns:
- the matching snapshot, or
nullif not found / not supported
-
abort
Attempts to abort a pending snapshot.- Parameters:
snapshotId- the snapshot to abort- Returns:
- the resulting status, or
nullif not found / not supported
-
serverManaged
boolean serverManaged()Returns whether the underlying agent is server-managed (state persisted server-side) versus client-managed (state round-tripped by the caller).- Returns:
trueif server-managed
-