Skip to content

Bidirectional Streaming

Bidirectional streaming keeps a connection open between your application and the model so input and output flow at the same time. Instead of sending a message and waiting for the response, you keep sending input while the model is still processing and streaming its output. The conversation carries on over the same connection.

Voice is the most common use. While the agent is speaking, it’s still listening, so a user can talk over the agent (barge in), change their question, or add a detail, and the agent responds to the new input.

In Strands, you build these applications with BidiAgent. It holds a persistent connection to a realtime model for the whole conversation. Over that connection, it streams input to the model, streams the model’s output back to your application, and runs tool calls in the background without pausing either direction. It’s built for live interactions where users expect the agent to react as they go, like a voice assistant or a phone support agent.

Here’s how the pieces connect:

flowchart LR
User((User))
Input[Input stream<br/>microphone, keyboard, app]
Output[Output stream<br/>speakers, screen, app]
Agent[BidiAgent]
Model[Realtime model]
Tools[Your tools]
User -- "speaks, types, sends" --> Input
Input --> Agent
Agent <--> Model
Agent <--> Tools
Agent --> Output
Output -- "hears, reads" --> User
  • The input stream captures what the user says, types, or sends and passes it to the agent.
  • The agent sits in the middle, routing input to the model and replies to the output stream. It also runs your tools and records the conversation history.
  • The realtime model takes in the input, decides how to respond, and streams its reply back as it goes, as audio, text, or both.
  • The output stream delivers the reply to the user: playing audio, printing text, or sending it on to your app.

The quickstart walks you through your first voice conversation, then shows you how to talk over the agent, stop it from hearing its own voice, and give it a tool.