Skip to content

feat(runner): support steering active LLM invocations - #1932

Draft
zhangxiangnan wants to merge 2 commits into
google:mainfrom
zhangxiangnan:feature/invocation-steering
Draft

zhangxiangnan wants to merge 2 commits into
google:mainfrom
zhangxiangnan:feature/invocation-steering

Conversation

@zhangxiangnan

@zhangxiangnan zhangxiangnan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Draft — depends on #1929. The branch contains the current queue fix from #1929 (42eba47a, rebased without changing its added/removed lines) plus one steering commit, on main aa183f8b. After #1929 merges, this PR will be rebased onto main to remove the dependency commit and leave a single feature commit.

Closes #1931

Description of Change

Allow applications to submit additional user messages to an active ordinary LLM invocation. Steering is explicitly enabled by runSteerableAsync; configuring a service only selects its backend. Existing runAsync and RunConfig contracts remain unchanged.

  • Experimental SteeringInputQueue exposes readiness, text/content submission, and cancellation for one invocation. Receipts acknowledge persisted user events, not provider receipt or model compliance.
  • Experimental BaseSteeringService separates admission/storage from execution. The SDK supplies InMemorySteeringService; applications can provide shared storage for cross-Runner/process submission through Runner.steer(...).
  • The Runner persists accepted input FIFO at model/tool step boundaries. Already accepted input can continue the same invocation after a final response, within its existing budgets. Cancellation, explicit termination, pending tools/confirmations, and execution limits take precedence.
  • The first version requires a non-resumable root LlmAgent without sub-agents and with default conversation history. It admits user text/media, rejects model output/tool responses, and leaves live execution on LiveRequestQueue.

The service Javadocs specify immediate admission, atomic closing, backend admission order, stable input IDs, replayable receipts across clients, caller-thread I/O with finite timeouts, and application ownership of backend clients. The SDK does not supply distributed execution ownership, transport retry deduplication, or crash recovery.

Python alignment: google/adk-python#7642 is related design work, not an accepted API being ported. Its scoped-task proposal marks messages undelivered when no subsequent model request occurs; this proposal can continue an ordinary invocation for accepted input after a final response. The FIFO/boundary concepts are related, but completion semantics differ. #7643 was closed pending RFC agreement.

Testing Plan

Current steering commit ba4e1fed: 682 tests, 0 failures, 0 errors, 0 skipped across 11 test classes. This includes RunnerTest (187) and InMemorySteeringServiceTest (5), plus RunConfig, LLM flow/history, root-node execution, workflow handoffs/HITL/resume, and Live callbacks. Counts are from one execution, not added across reruns.

./mvnw -pl core \
  -Dtest=RunnerTest,InMemorySteeringServiceTest,RunConfigTest,BaseLlmFlowTest,ContentsTest,RunnerRootNodeTest,LlmAgentAsNodeTest,WorkflowTest,WorkflowResumeTest,WorkflowHitlTest,LiveModelCallbacksTest \
  test-compile surefire:test@basic

The rebase retains main's workflow handoff stop condition, task isolation scope, and Live input persistence. It also retains main's beforeRun early-exit fix (aa183f8b): events pass through onEvent callbacks before persistence, including Live execution. The existing RunnerTest.steering_shortCircuitClosesBeforeLifecycleAndTerminalCallbacks additionally verifies callback delivery and persistence with steering enabled, while preserving its closure assertions. Main's three new early-exit regressions are included in the 682-test run. Queue-dependent steering tests now wait for asynchronous startup as introduced by the current #1929; the Live compatibility fixture keeps its model stream open until input has been sent.

Local Maven settings/offline dependency caches were used. Coverage includes readiness/cancellation, ordered persistence, shared-service submission, limits, pending tools, rejected configurations, and backend failures.

  • RunnerTest.steering_admissionAndFinalClosureHonorBothOrderings deterministically pauses before or after the real inbox closeIfIdle(), while the invocation is still active. It forces both admission-before-close and close-before-admission, verifying persistence plus the next model request in the first case and synchronous rejection in the second.
  • The existing steering_racingNormalCompletionIsConsumedOrRejected remains a concurrent repetition test; it does not guarantee both interleavings on every execution.
  • At 8f2d549a, temporary mutation probes confirmed the deterministic test fails if normal closure only checks emptiness without closing admission, or if it closes despite pending input. These probes are not additional passing test cases.
  • steeringService_failedCloseIsRetriedByLifecycleCleanup is in RunnerTest; InMemorySteeringServiceTest covers receipt replay, closure, identity, and callbacks outside locks.

Full repository build at implementation revision 44c4711d: JDK 21, ./mvnw -Prelease clean package, all 23 reactor modules succeeded. This is not a Java 17/25 matrix result. This is historical validation, not a full-reactor run at the rebased head. The current 682-test run above covers integration with the newer main and queue fix.

Consumer-side evidence at 44c4711d (separate application, not included in this PR): 14 tests and a scripted demo passed. A standalone run processed 42M measured messages without duplicate/lost acknowledgements or per-producer reordering, plus 2,000 Runner submit/complete and submit/cancel races and 500 startup-cancel races. These are controlled-model/in-memory checks, not live-provider E2E, a JMH benchmark, or production capacity measurements. They were not rerun for this rebase.

Remote storage, process-restart recovery, and live-provider behavior have not been validated.

Checklist

Add opt-in input queues and a steering service contract with an in-memory
implementation. Persist accepted user messages at model/tool step boundaries
without resetting invocation budgets, and close admission on termination.

Preserve existing RunConfig and runAsync contracts. Cover lifecycle races,
ordered persistence, shared-service submission, and unsupported configurations.
@zhangxiangnan
zhangxiangnan force-pushed the feature/invocation-steering branch from 1deb55b to ba4e1fe Compare November 30, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Steer an active LLM invocation with additional user messages

1 participant