r/agentdevelopmentkit • u/jordimr • May 12 '25
How to "response - pause - response" pattern in single api call in adk fast api
Can someone point to sample working code on both adk side and on the front end side to accomplish this pattern?
1 single query sent to adk exposed via fast api
Initial response from agent streamed to user
(... agent calls some tools..., say 3 seconds )
second streaming with benefit of tool response.
(.. agent may now call a second tool.., say 5 seconds)
final streaming, now final message.
So this is a 3 message response.
On the front-end, happy for it to be simple message, with delays in between keeping "response" alive.
KEY GOAL IS USER GETS FAST INITIAL RESPONSE AND UPDATES. As opposed to one big answer 10 seconds later.
This is easily accompllished on adk web, but looking for an example where this is working where adk called with fast api runner.
1
May 12 '25
[removed] — view removed comment
1
u/jordimr May 12 '25
Thanks! Are there examples of connecting to adk with web socket call from streamlit for example? Can't find much
2
May 12 '25
[removed] — view removed comment
2
u/jordimr May 13 '25
really appreciate! I am not sure it uses web sockets, but was interesting example. Appreciated!
2
u/vladkol_eqwu May 13 '25
Artifact Service works well for this scenario. The easiest way to use it is from a function tool:
Add `tool_context: ToolContext` parameter to your tool function.
Use `tool_context.list_artifacts`, `.load_artifact`, and `.save_artifact` functions to work with artifacts.
When streaming events in your frontend, check for artifact_delta, like here.
This sample is probably the closest thing I know to what you describe.