Skip to content

Commit 3f9f773

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Add ability to send state change with message
PiperOrigin-RevId: 783589708
1 parent 7e87628 commit 3f9f773

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

src/google/adk/cli/fast_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ class AgentRunRequest(common.BaseModel):
177177
session_id: str
178178
new_message: types.Content
179179
streaming: bool = False
180-
state_delta: Optional[dict[str, Any]] = None
181180

182181

183182
class AddSessionToEvalSetRequest(common.BaseModel):
@@ -878,7 +877,6 @@ async def event_generator():
878877
user_id=req.user_id,
879878
session_id=req.session_id,
880879
new_message=req.new_message,
881-
state_delta=req.state_delta,
882880
run_config=RunConfig(streaming_mode=stream_mode),
883881
):
884882
# Format as SSE data

src/google/adk/runners.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@
1717
import asyncio
1818
import logging
1919
import queue
20-
import time
21-
from typing import Any
2220
from typing import AsyncGenerator
2321
from typing import Callable
2422
from typing import Generator
2523
from typing import List
2624
from typing import Optional
27-
import uuid
2825
import warnings
2926

3027
from google.genai import types
@@ -41,7 +38,6 @@
4138
from .auth.credential_service.base_credential_service import BaseCredentialService
4239
from .code_executors.built_in_code_executor import BuiltInCodeExecutor
4340
from .events.event import Event
44-
from .events.event import EventActions
4541
from .flows.llm_flows.functions import find_matching_function_call
4642
from .memory.base_memory_service import BaseMemoryService
4743
from .memory.in_memory_memory_service import InMemoryMemoryService
@@ -178,7 +174,6 @@ async def run_async(
178174
user_id: str,
179175
session_id: str,
180176
new_message: types.Content,
181-
state_delta: Optional[dict[str, Any]] = None,
182177
run_config: RunConfig = RunConfig(),
183178
) -> AsyncGenerator[Event, None]:
184179
"""Main entry method to run the agent in this runner.
@@ -221,7 +216,6 @@ async def run_async(
221216
new_message,
222217
invocation_context,
223218
run_config.save_input_blobs_as_artifacts,
224-
state_delta,
225219
)
226220

227221
invocation_context.agent = self._find_agent_to_run(session, root_agent)
@@ -290,7 +284,6 @@ async def _append_new_message_to_session(
290284
new_message: types.Content,
291285
invocation_context: InvocationContext,
292286
save_input_blobs_as_artifacts: bool = False,
293-
state_delta: Optional[dict[str, Any]] = None,
294287
):
295288
"""Appends a new message to the session.
296289
@@ -322,19 +315,11 @@ async def _append_new_message_to_session(
322315
text=f'Uploaded file: {file_name}. It is saved into artifacts'
323316
)
324317
# Appends only. We do not yield the event because it's not from the model.
325-
if state_delta:
326-
event = Event(
327-
invocation_id=invocation_context.invocation_id,
328-
author='user',
329-
actions=EventActions(state_delta=state_delta),
330-
content=new_message,
331-
)
332-
else:
333-
event = Event(
334-
invocation_id=invocation_context.invocation_id,
335-
author='user',
336-
content=new_message,
337-
)
318+
event = Event(
319+
invocation_id=invocation_context.invocation_id,
320+
author='user',
321+
content=new_message,
322+
)
338323
await self.session_service.append_event(session=session, event=event)
339324

340325
async def run_live(

0 commit comments

Comments
 (0)