Skip to content

Commit fa55580

Browse files
Tongzhou-Jiangcopybara-github
authored andcommitted
fix: Refactor session retrieval fallback _streaming_agent_run_with_events.
PiperOrigin-RevId: 868781249
1 parent 12f5aa5 commit fa55580

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

  • vertexai
    • agent_engines/templates
    • preview/reasoning_engines/templates

vertexai/agent_engines/templates/adk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,8 @@ async def streaming_agent_run_with_events(self, request_json: str):
11901190
session_id=request.session_id,
11911191
)
11921192
except ClientError:
1193+
session = None
1194+
if not session:
11931195
# Fall back to create session if the session is not found.
11941196
# Specifying session_id on creation is not supported,
11951197
# so session id will be regenerated.

vertexai/preview/reasoning_engines/templates/adk.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,11 @@ async def _invoke_agent_async():
10241024
session_id=request.session_id,
10251025
)
10261026
except ClientError:
1027+
session = None
1028+
if not session:
10271029
# Fall back to create session if the session is not found.
1030+
# Specifying session_id on creation is not supported,
1031+
# so session id will be regenerated.
10281032
session = await self._init_session(
10291033
session_service=session_service,
10301034
artifact_service=artifact_service,

0 commit comments

Comments
 (0)