Class SessionResolver.Resolution<S>
java.lang.Object
com.google.genkit.ai.agent.internal.SessionResolver.Resolution<S>
- Type Parameters:
S- the type of custom session state
- Enclosing class:
SessionResolver
Result of session resolution: either a ready
Session, or a graceful pre-turn failure.
A failure resolution lets the agent generator (Task 4.5) emit an AgentOutput with
finishReason=FAILED instead of throwing.
-
Method Summary
Modifier and TypeMethodDescriptionerror()Returns the runtime error, ornullif this is a successful resolution.static <S> SessionResolver.Resolution<S> failure(RuntimeError error) Creates a failure resolution carrying aRuntimeError.booleanisOk()Returnstrueif this is a successful resolution with a ready session.static <S> SessionResolver.Resolution<S> Creates a successful resolution wrapping the given session.static <S> SessionResolver.Resolution<S> Creates a successful resolution wrapping the given session and the id of the snapshot it was resolved (resumed) from.session()Returns the resolved session, ornullif this is a failure resolution.Returns the id of the snapshot this session was resolved (resumed) from, ornullfor a fresh session.
-
Method Details
-
ok
Creates a successful resolution wrapping the given session.- Type Parameters:
S- the type of custom session state- Parameters:
session- the resolved session (must not be null)- Returns:
- a successful Resolution
-
ok
Creates a successful resolution wrapping the given session and the id of the snapshot it was resolved (resumed) from. The source snapshot id seeds the runner'slastSnapshotIdso the first post-resume turn chains itsparentIdto it (seeSessionRunner).- Type Parameters:
S- the type of custom session state- Parameters:
session- the resolved session (must not be null)sourceSnapshotId- the id of the snapshot this session was resumed from; may benullfor a fresh session- Returns:
- a successful Resolution carrying the source snapshot id
-
failure
Creates a failure resolution carrying aRuntimeError.The agent generator should translate this into an
AgentOutputwithfinishReason=FAILEDrather than throwing.- Type Parameters:
S- the type of custom session state- Parameters:
error- the runtime error describing the failure- Returns:
- a failure Resolution
-
isOk
public boolean isOk()Returnstrueif this is a successful resolution with a ready session.- Returns:
- true if ok
-
session
Returns the resolved session, ornullif this is a failure resolution.- Returns:
- the session, or null
-
error
Returns the runtime error, ornullif this is a successful resolution.- Returns:
- the error, or null
-
sourceSnapshotId
Returns the id of the snapshot this session was resolved (resumed) from, ornullfor a fresh session. Used to seed the runner'slastSnapshotIdso the first post-resume turn chains itsparentIdto the resumed snapshot.- Returns:
- the source snapshot id, or
null
-