Skip to content

strands.experimental.bidi.types.io

Protocol for bidirectional streaming IO channels.

Defines callable protocols for input and output channels that can be used with BidiAgent. This approach provides better typing and flexibility by separating input and output concerns into independent callables.

BidiInput

@runtime_checkable
class BidiInput(Protocol)

Defined in: src/strands/experimental/bidi/types/io.py:17

Protocol for bidirectional input callables.

Input callables read data from a source (microphone, camera, websocket, etc.) and return events to be sent to the agent.

start

async def start(agent: "BidiAgent") -> None

Defined in: src/strands/experimental/bidi/types/io.py:24

Start input.

stop

async def stop() -> None

Defined in: src/strands/experimental/bidi/types/io.py:28

Stop input.

__call__

def __call__() -> Awaitable[BidiInputEvent]

Defined in: src/strands/experimental/bidi/types/io.py:32

Read input data from the source.

Returns:

Awaitable that resolves to an input event (audio, text, image, etc.)

BidiOutput

@runtime_checkable
class BidiOutput(Protocol)

Defined in: src/strands/experimental/bidi/types/io.py:42

Protocol for bidirectional output callables.

Output callables receive events from the agent and handle them appropriately (play audio, display text, send over websocket, etc.).

start

async def start(agent: "BidiAgent") -> None

Defined in: src/strands/experimental/bidi/types/io.py:49

Start output.

stop

async def stop() -> None

Defined in: src/strands/experimental/bidi/types/io.py:53

Stop output.

__call__

def __call__(event: BidiOutputEvent) -> Awaitable[None]

Defined in: src/strands/experimental/bidi/types/io.py:57

Process output events from the agent.

Arguments:

  • event - Output event from the agent (audio, text, tool calls, etc.)