Repository navigation
[Feature] Add --state_file to adk run for loading initial session state from JSON聽#7083
Description
Activity
SHAI-shivansh-sharma commented
on Sep 10, 2026 ContributorAuthorMore actionsHi @ross-p @joefernandez @sanketpatil06 @llalitkumarrr @GWeale @wuliang229 ,I opened a small PR for this: #7084.
It adds
adk run --state_fileby reusing the existing--stateparsing path, with tests for interactive mode, single-query mode, and mutual exclusion with--state.- addedcore[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementation
on Sep 11, 2026 Hi @SHAI-shivansh-sharma , Thanks for bringing this and taking time to raise a PR. Your request is currently being reviewed, and we will let you know if anything further is needed. We appreciate your contribution.
- addedneeds review[Status] The PR/issue is awaiting review from the maintainer[Status] The PR/issue is awaiting review from the maintainer
on Sep 11, 2026 SHAI-shivansh-sharma commented
on Sep 25, 2026 ContributorAuthorMore actionsThanks @sanketpatil06, appreciate you taking the time to review it.
I鈥檒l keep an eye on the PR and will be happy to make any changes if something needs adjustment during review.
SHAI-shivansh-sharma commented
on Oct 6, 2026 ContributorAuthorMore actionsHi @sanketpatil06 and maintainers, a brief follow-up on this feature request and PR #7084.
The PR is open, mergeable, and all completed checks are passing. It adds
adk run --state_filefor loading initial session state from JSON while preserving the existing--statebehavior and validating mutual exclusion. This gives users a simple, repeatable way to start runs from saved state without changing the current workflow.When you have a chance, could you please take a look and let me know whether any changes are needed to move it forward?
PR: #7084
- added a commit that references this issue
on Oct 8, 2026
馃敶 Required Information
Is your feature request related to a specific problem?
adk runcurrently supports initial session state through--state, but the state must be passed as an inline JSON string:adk run path/to/agent --state '{"customer_id": "123", "region": "us"}'For realistic state payloads this becomes hard to use:
This is especially painful when testing agents that depend on session state, dynamic instructions, or state-backed tools.
I searched for existing issues/PRs targeting this specific CLI feature and did not find one for
--state_file/--state-file. Related but distinct: #4961 proposes declarative initial state foradk web; this request is specifically for theadk runCLI path.Describe the Solution You'd Like
Add a
--state_fileoption toadk runthat loads initial session state from a JSON file:adk run path/to/agent --state_file state.json adk run path/to/agent "hello" --state_file state.jsonThe file should contain a JSON object used as the initial session state.
Expected behavior:
--state_fileworks in both interactive mode and single-query mode.--stateand--state_fileare mutually exclusive.--stateJSON.Impact on your work
This would make local agent development and repeatable testing much smoother for stateful agents. Instead of copying JSON into a shell command, developers could keep reusable fixtures like:
and run the same agent against each state file.
It also reduces quoting friction on Windows/PowerShell, where inline JSON can be particularly awkward.
Willingness to contribute
Yes. I can open a small PR if this direction looks reasonable.
馃煛 Recommended Information
Describe Alternatives You've Considered
--statewith inline JSON. This works for tiny examples but becomes brittle for realistic payloads and varies by shell.--replay. This creates a session from an input file with queries, but it is a different workflow and not ideal when I only want to seed state and continue interactively or run a single query.Proposed API / Implementation
The CLI already forwards
--stateasstate_strintorun_cli/run_once_cli, where the JSON parsing path already exists.A minimal implementation could:
adk run:--stateand--state_filecannot be used together.cli_runand pass the contents asstate_strto the existingrun_cli/run_once_clicalls.tests/unittests/cli/utils/test_cli_tools_click.pycovering interactive mode, single-query mode, mutual exclusion, and bad/missing file behavior.Additional Context
This is intentionally smaller than a broader declarative state feature. It only makes the existing
adk run --statecapability easier and safer to use with real JSON files.