Class InProcessTransport<S>
java.lang.Object
com.google.genkit.ai.agent.internal.InProcessTransport<S>
- Type Parameters:
S- the type of custom session state
- All Implemented Interfaces:
AgentTransport<S>
In-process
AgentTransport that drives a locally-defined Agent via its bidi
action.
Each runTurn(com.google.genkit.ai.agent.AgentInput, com.google.genkit.ai.agent.AgentInit<S>, java.util.function.Consumer<com.google.genkit.ai.agent.AgentStreamChunk>) call feeds exactly one input (offer + end) into a fresh BufferedInputSource and invokes agent.runBidiJson, deserializing the returned node into
an AgentOutput. Snapshot retrieval and abort delegate to the agent's typed facades.
-
Constructor Summary
ConstructorsConstructorDescriptionInProcessTransport(Agent<S> agent, ActionContext ctx) Constructs an in-process transport. -
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).
-
Constructor Details
-
InProcessTransport
Constructs an in-process transport.- Parameters:
agent- the agent to drive (must not be null)ctx- the action context used for each turn invocation (must not be null)
-
-
Method Details
-
runTurn
public AgentOutput<S> runTurn(AgentInput input, AgentInit<S> init, Consumer<AgentStreamChunk> onChunk) Description copied from interface:AgentTransportRuns ONE turn: feedsinputwithinit, collects stream chunks viaonChunk, and returns the final output.- Specified by:
runTurnin interfaceAgentTransport<S>- 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
Description copied from interface:AgentTransportRetrieves a session snapshot.- Specified by:
getSnapshotin interfaceAgentTransport<S>- Parameters:
req- the request specifying which snapshot to retrieve- Returns:
- the matching snapshot, or
nullif not found / not supported
-
abort
Description copied from interface:AgentTransportAttempts to abort a pending snapshot.- Specified by:
abortin interfaceAgentTransport<S>- Parameters:
snapshotId- the snapshot to abort- Returns:
- the resulting status, or
nullif not found / not supported
-
serverManaged
public boolean serverManaged()Description copied from interface:AgentTransportReturns whether the underlying agent is server-managed (state persisted server-side) versus client-managed (state round-tripped by the caller).- Specified by:
serverManagedin interfaceAgentTransport<S>- Returns:
trueif server-managed
-