feat(runner): add NewInMemory convenience constructor#1133
Merged
Conversation
Mirror adk-python's InMemoryRunner: NewInMemory wires the in-memory session, artifact, and memory services and enables session auto-creation, so local development and tests can build a Runner without manually assembling services or pre-creating a session. Auto-creation is required (not just a default) because the helper owns its services and exposes no accessor on Runner; without it the returned Runner's first Run would always fail with "session not found" and the caller would have no way to recover. Purely additive and backward-compatible; runner.New is unchanged.
hanorik
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
runner.Newrequires callers to assemble and pass services explicitly andfails when
SessionServiceis nil (runner/runner.go:95). There is noPython/Java-style
InMemoryRunnerconvenience that auto-wires in-memoryservices, so every local/dev/test setup must construct the session, artifact,
and memory services (and pre-create a session) by hand.
Solution:
Add
runner.NewInMemory(appName, agent), mirroring adk-python'sInMemoryRunner. It wires the in-memory session, artifact, and memory servicesand enables session auto-creation, so a
Runnercan be built and run with zeromanual service/session setup. Auto-creation is required (not merely a default)
because the helper owns its services and
Runnerexposes no service accessor;without it the first
Runwould always fail with "session not found" and thecaller could not recover. The change is purely additive and
backward-compatible —
runner.Newis unchanged.