1616
1717package com .google .adk .apps ;
1818
19+ import static com .google .common .base .Preconditions .checkArgument ;
20+
1921import com .google .auto .value .AutoValue ;
2022import com .google .errorprone .annotations .CanIgnoreReturnValue ;
2123
2224/**
2325 * App resumability config, mirroring Python ADK v1's {@code ResumabilityConfig}: pause on a
2426 * long-running call and resume from the last event. Applies to all agents in the app.
2527 *
28+ * <p>The two flags select the same resumption behavior and are mutually exclusive: set {@link
29+ * #isResumable()}, or the deprecated shim, but not both.
30+ *
2631 * @deprecated Partial feature: only event-reconstruction-based pause/resume for {@code
2732 * SequentialAgent} is implemented. Full session resumability (persisted agent state, durable
2833 * resume, other workflow agents) is not yet available. Forward-compatible: the same config will
@@ -41,10 +46,13 @@ public abstract class ResumabilityConfig {
4146 * default, matching Python ADK, where a plain-text {@code runAsync} always starts a new
4247 * invocation and a paused invocation is resumed explicitly.
4348 *
49+ * <p>Selects the same resumption behavior as {@link #isResumable()}, with which it is mutually
50+ * exclusive; it differs only in also resuming on a plain-text continuation.
51+ *
4452 * @deprecated Back-compat shim for callers that deliver a resume as a plain-text turn. Migrate to
4553 * {@code Runner.runAsync(userId, sessionId, invocationId, message, runConfig, stateDelta)}
46- * (or send a function response to the paused call) and stop setting this flag; it will be
47- * removed.
54+ * (or send a function response to the paused call) and set {@link #isResumable()} instead;
55+ * this flag will be removed.
4856 */
4957 @ Deprecated
5058 public abstract boolean isPlainTextContinuationAutoResume ();
@@ -70,6 +78,22 @@ public abstract static class Builder {
7078 @ CanIgnoreReturnValue
7179 public abstract Builder plainTextContinuationAutoResume (boolean value );
7280
73- public abstract ResumabilityConfig build ();
81+ abstract ResumabilityConfig autoBuild ();
82+
83+ /**
84+ * Builds the config, rejecting a combination of flags that has no defined behavior.
85+ *
86+ * @throws IllegalArgumentException if both resumability and the deprecated shim are set; they
87+ * select the same behavior, so exactly one may be enabled.
88+ */
89+ @ SuppressWarnings ("deprecation" ) // Validating the deprecated shim against the supported flag.
90+ public ResumabilityConfig build () {
91+ ResumabilityConfig config = autoBuild ();
92+ checkArgument (
93+ !(config .isResumable () && config .isPlainTextContinuationAutoResume ()),
94+ "resumable and plainTextContinuationAutoResume are mutually exclusive: set resumable for"
95+ + " the supported flag, or the deprecated shim, but not both." );
96+ return config ;
97+ }
7498 }
7599}
0 commit comments