Skip to content

fix(session/vertexai): drop temp: keys from the initial state on Create - #2100

Merged
wolo-lab merged 3 commits into
google:mainfrom
adityasingh2400:fix/vertexai-create-temp-state
Nov 4, 2026
Merged

wolo-lab merged 3 commits into
google:mainfrom
adityasingh2400:fix/vertexai-create-temp-state

Conversation

@adityasingh2400

Copy link
Copy Markdown
Contributor

Linked issue

Problem:
Create on the Vertex AI session service sends temp: keys from the initial state to Agent Engine, so they're stored with the session and returned by every later Get.

Solution:
Drop temp: keys from a copy of the initial state before building the RPC, the same way AppendEvent trims them from deltas. This matches adk-python's create_session (src/google/adk/sessions/vertex_ai_session_service.py:243-250). The caller's map isn't modified.

Behavior change

temp: keys passed to Create on the Vertex AI service are no longer stored or returned. Other keys are unchanged.

Testing Plan

Unit Tests:

  • All unit tests pass locally.

Added TestCreate_dropsTempKeysFromInitialState, which runs against an in-process fake gRPC server. No replay files are touched.

With your source change reverted and your tests kept, which test fails?

temp key reached the CreateSession RPC payload: key "temp:k1", state map[sk:v2 temp:k1:v1]
CreateSession RPC session_state = map[temp:k1:v1], want none
created session State().Get("temp:k1") error = <nil>, want state key does not exist

With the change, go test -race -count=1 ./session/vertexai/... passes, go build ./... succeeds, and golangci-lint run reports 0 issues, with golangci-lint fmt --diff and go mod tidy -diff both empty.

Manual End-to-End (E2E) Tests:

N/A, covered by the fake-server test. I didn't run it against a live Agent Engine.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

CreateRequest.State was sent to Agent Engine as given, so temp: keys were
stored with the session and came back on the created session and every
later Get. AppendEvent already trims them from state deltas, and
adk-python's VertexAiSessionService.create_session drops them too.
@indurireddy-TF

Copy link
Copy Markdown
Contributor

Hi @adityasingh2400 Thank you for addressing this issue and providing the fix!I reviewed the changes and verified the implementation against the expected behaviour. The temporary state keys are correctly filtered out, while regular session state is preserved.
I also verified the relevant test scenarios, and all tests are passing. Everything looks good from my side. Thanks for the fix!

ok google.golang.org/adk/v2/tool/mcptoolset 1.043s
ok google.golang.org/adk/v2/tool/preloadmemorytool 0.040s
ok google.golang.org/adk/v2/tool/skilltoolset 0.035s
ok google.golang.org/adk/v2/tool/skilltoolset/internal/skilltool 0.039s
ok google.golang.org/adk/v2/tool/skilltoolset/skill 0.045s
ok google.golang.org/adk/v2/tool/toolauth 0.039s
ok google.golang.org/adk/v2/tool/toolconfirmation 0.035s
ok google.golang.org/adk/v2/tool/toolsearch 0.097s
ok google.golang.org/adk/v2/tool/toolutils 0.024s
? google.golang.org/adk/v2/util/aiplatform [no test files]
? google.golang.org/adk/v2/util/instructionutil [no test files]
? google.golang.org/adk/v2/util/vertexai [no test files]
ok google.golang.org/adk/v2/workflow 0.766s

@wolo-lab wolo-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@wolo-lab
wolo-lab merged commit 0c109f7 into google:main Nov 4, 2026
14 checks passed
wolo-lab added a commit that referenced this pull request Nov 16, 2026
, #1919, #2189, #2285) (#2346)

* fix(session/vertexai): drop temp: keys from the initial state on Create (#2100)

(cherry picked from commit 0c109f7)

* fix(session): keep in-memory Get from returning events before After (#2089)

(cherry picked from commit 10395f0)

* fix(session/database): lock app and user state rows in Create (#1930)

(cherry picked from commit 2f3b2c2)

* fix(session/database): delete a session's events explicitly in Delete (#1774)

(cherry picked from commit 7af0f5f)

* fix(session): define List order as last update time ascending (#1919)

(cherry picked from commit 8be7e25)

* fix(session): skip nil parts in IsFinalResponse classification (#2189)

(cherry picked from commit 75ae920)

* fix(session): count a final error event as a final response (#2285)

(cherry picked from commit d9ecb34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session/vertexai: Create stores temp: keys from the initial state

3 participants