Part 2 of the zero-trust agents series: move security checks from build-time code-level controls to runtime platform governance — Model Armor, Semantic Governance Policies, and Agent Anomaly Detection with closed-loop remediation.
A voice agent that leaves dead air while it works feels broken. This ADK guide shows two patterns for streaming tools that keep the conversation alive — and the production details that trip people up.
For long operations the agent should narrate what it's doing:
query_sales_database, ADK immediately dispatches an asynchronous status event. The agent speaks right away ("Looking into the EMEA figures for you now...").yield sends a partial function response upstream; the model paraphrases each update as it arrives ("Connecting to the warehouse...", "Aggregating product line data..."), though narration can trail the tool by several seconds.Continuous commentary isn't always appropriate. If a user asks for a report and immediately pivots, an agent that keeps interrupting with status updates feels intrusive. When the wait has no story to narrate, run the task quietly in the background. The fastest setup is a single-yield generator: an async generator that yields only once, upon completion — an immediate verbal acknowledgment without ongoing chatter.
stop_streaming — ADK provides a built-in escape hatch: include a stop_streaming(function_name: str) function in the agent's tools, ADK intercepts the call and cancels the generator's underlying asyncio task, raising asyncio.CancelledError inside your function so you can cleanly close DB connections or file handles.interrupted=True so the client stops audio playback. Running streaming or background tools are not cancelled, and their results still arrive. To stop a tool, the model must call stop_streaming.The barge-in semantics are the subtle one: user interruption stops speech but not the tool — a design that prevents lost work but requires stop_streaming discipline. Between narration-on-demand, single-yield background tasks, and explicit idempotency, these two patterns give you a voice agent that talks when it should, shuts up when it should, and never silently drops a running job.