strands.experimental.hooks.events
¶
Experimental hook events emitted as part of invoking Agents and BidiAgents.
This module defines the events that are emitted as Agents and BidiAgents run through the lifecycle of a request.
_DEPRECATED_ALIASES = {'BeforeToolInvocationEvent': BeforeToolCallEvent, 'AfterToolInvocationEvent': AfterToolCallEvent, 'BeforeModelInvocationEvent': BeforeModelCallEvent, 'AfterModelInvocationEvent': AfterModelCallEvent}
module-attribute
¶
AfterModelCallEvent
dataclass
¶
Bases: HookEvent
Event triggered after the model invocation completes.
This event is fired after the agent has finished calling the model, regardless of whether the invocation was successful or resulted in an error. Hook providers can use this event for cleanup, logging, or post-processing.
Note: This event uses reverse callback ordering, meaning callbacks registered later will be invoked first during cleanup.
Note: This event is not fired for invocations to structured_output.
Attributes:
| Name | Type | Description |
|---|---|---|
stop_response |
Optional[ModelStopResponse]
|
The model response data if invocation was successful, None if failed. |
exception |
Optional[Exception]
|
Exception if the model invocation failed, None if successful. |
retry |
bool
|
Whether to retry the model invocation. Can be set by hook callbacks to trigger a retry. When True, the current response is discarded and the model is called again. Defaults to False. |
Source code in strands/hooks/events.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
should_reverse_callbacks
property
¶
True to invoke callbacks in reverse order.
ModelStopResponse
dataclass
¶
Model response data from successful invocation.
Attributes:
| Name | Type | Description |
|---|---|---|
stop_reason |
StopReason
|
The reason the model stopped generating. |
message |
Message
|
The generated message from the model. |
Source code in strands/hooks/events.py
223 224 225 226 227 228 229 230 231 232 233 | |
AfterToolCallEvent
dataclass
¶
Bases: HookEvent
Event triggered after a tool invocation completes.
This event is fired after the agent has finished executing a tool, regardless of whether the execution was successful or resulted in an error. Hook providers can use this event for cleanup, logging, or post-processing.
Note: This event uses reverse callback ordering, meaning callbacks registered later will be invoked first during cleanup.
Attributes:
| Name | Type | Description |
|---|---|---|
selected_tool |
Optional[AgentTool]
|
The tool that was invoked. It may be None if tool lookup failed. |
tool_use |
ToolUse
|
The tool parameters that were passed to the tool invoked. |
invocation_state |
dict[str, Any]
|
Keyword arguments that were passed to the tool |
result |
ToolResult
|
The result of the tool invocation. Either a ToolResult on success or an Exception if the tool execution failed. |
cancel_message |
str | None
|
The cancellation message if the user cancelled the tool call. |
Source code in strands/hooks/events.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
should_reverse_callbacks
property
¶
True to invoke callbacks in reverse order.
AgentTool
¶
Bases: ABC
Abstract base class for all SDK tools.
This class defines the interface that all tool implementations must follow. Each tool must provide its name, specification, and implement a stream method that executes the tool's functionality.
Source code in strands/types/tools.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
is_dynamic
property
¶
Whether the tool was dynamically loaded during runtime.
Dynamic tools may have different lifecycle management.
Returns:
| Type | Description |
|---|---|
bool
|
True if loaded dynamically, False otherwise. |
supports_hot_reload
property
¶
Whether the tool supports automatic reloading when modified.
Returns:
| Type | Description |
|---|---|
bool
|
False by default. |
tool_name
abstractmethod
property
¶
The unique name of the tool used for identification and invocation.
tool_spec
abstractmethod
property
¶
Tool specification that describes its functionality and parameters.
tool_type
abstractmethod
property
¶
The type of the tool implementation (e.g., 'python', 'javascript', 'lambda').
Used for categorization and appropriate handling.
__init__()
¶
Initialize the base agent tool with default dynamic state.
Source code in strands/types/tools.py
227 228 229 | |
get_display_properties()
¶
Get properties to display in UI representations of this tool.
Subclasses can extend this to include additional properties.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary of property names and their string values. |
Source code in strands/types/tools.py
295 296 297 298 299 300 301 302 303 304 305 306 | |
mark_dynamic()
¶
Mark this tool as dynamically loaded.
Source code in strands/types/tools.py
291 292 293 | |
stream(tool_use, invocation_state, **kwargs)
abstractmethod
¶
Stream tool events and return the final result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_use
|
ToolUse
|
The tool use request containing tool ID and parameters. |
required |
invocation_state
|
dict[str, Any]
|
Caller-provided kwargs that were passed to the agent when it was invoked (agent(), agent.invoke_async(), etc.). |
required |
**kwargs
|
Any
|
Additional keyword arguments for future extensibility. |
{}
|
Yields:
| Type | Description |
|---|---|
ToolGenerator
|
Tool events with the last being the tool result. |
Source code in strands/types/tools.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
BaseHookEvent
dataclass
¶
Base class for all hook events.
Source code in strands/hooks/registry.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
should_reverse_callbacks
property
¶
Determine if callbacks for this event should be invoked in reverse order.
Returns:
| Type | Description |
|---|---|
bool
|
False by default. Override to return True for events that should |
bool
|
invoke callbacks in reverse order (e.g., cleanup/teardown events). |
__post_init__()
¶
Disallow writes to non-approved properties.
Source code in strands/hooks/registry.py
48 49 50 51 52 | |
__setattr__(name, value)
¶
Prevent setting attributes on hook events.
Raises:
| Type | Description |
|---|---|
AttributeError
|
Always raised to prevent setting attributes on hook events. |
Source code in strands/hooks/registry.py
54 55 56 57 58 59 60 61 62 63 64 65 66 | |
BeforeModelCallEvent
dataclass
¶
Bases: HookEvent
Event triggered before the model is invoked.
This event is fired just before the agent calls the model for inference, allowing hook providers to inspect or modify the messages and configuration that will be sent to the model.
Note: This event is not fired for invocations to structured_output.
Source code in strands/hooks/events.py
176 177 178 179 180 181 182 183 184 185 186 187 | |
BeforeToolCallEvent
dataclass
¶
Bases: HookEvent, _Interruptible
Event triggered before a tool is invoked.
This event is fired just before the agent executes a tool, allowing hook providers to inspect, modify, or replace the tool that will be executed. The selected_tool can be modified by hook callbacks to change which tool gets executed.
Attributes:
| Name | Type | Description |
|---|---|---|
selected_tool |
Optional[AgentTool]
|
The tool that will be invoked. Can be modified by hooks to change which tool gets executed. This may be None if tool lookup failed. |
tool_use |
ToolUse
|
The tool parameters that will be passed to selected_tool. |
invocation_state |
dict[str, Any]
|
Keyword arguments that will be passed to the tool. |
cancel_tool |
bool | str
|
A user defined message that when set, will cancel the tool call.
The message will be placed into a tool result with an error status. If set to |
Source code in strands/hooks/events.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
BidiAfterConnectionRestartEvent
dataclass
¶
Bases: BidiHookEvent
Event emitted after agent attempts to restart model connection after timeout.
Attribtues
exception: Populated if exception was raised during connection restart. None value means the restart was successful.
Source code in strands/experimental/hooks/events.py
216 217 218 219 220 221 222 223 224 225 | |
BidiAfterInvocationEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered when BidiAgent ends a streaming session.
This event is fired after the BidiAgent has completed a streaming session, regardless of whether it completed successfully or encountered an error. Hook providers can use this event for cleanup, logging, or state persistence.
Note: This event uses reverse callback ordering, meaning callbacks registered later will be invoked first during cleanup.
This event is triggered at the end of agent.stop().
Source code in strands/experimental/hooks/events.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
should_reverse_callbacks
property
¶
True to invoke callbacks in reverse order.
BidiAfterToolCallEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered after BidiAgent executes a tool.
This event is fired after the BidiAgent has finished executing a tool during a streaming session, regardless of whether the execution was successful or resulted in an error. Hook providers can use this event for cleanup, logging, or post-processing.
Note: This event uses reverse callback ordering, meaning callbacks registered later will be invoked first during cleanup.
Attributes:
| Name | Type | Description |
|---|---|---|
selected_tool |
AgentTool | None
|
The tool that was invoked. It may be None if tool lookup failed. |
tool_use |
ToolUse
|
The tool parameters that were passed to the tool invoked. |
invocation_state |
dict[str, Any]
|
Keyword arguments that were passed to the tool. |
result |
ToolResult
|
The result of the tool invocation. Either a ToolResult on success or an Exception if the tool execution failed. |
exception |
Exception | None
|
Exception if the tool execution failed, None if successful. |
cancel_message |
str | None
|
The cancellation message if the user cancelled the tool call. |
Source code in strands/experimental/hooks/events.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
should_reverse_callbacks
property
¶
True to invoke callbacks in reverse order.
BidiAgent
¶
Agent for bidirectional streaming conversations.
Enables real-time audio and text interaction with AI models through persistent connections. Supports concurrent tool execution and interruption handling.
Source code in strands/experimental/bidi/agent/agent.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
tool
property
¶
Call tool as a function.
Returns:
| Type | Description |
|---|---|
_ToolCaller
|
ToolCaller for method-style tool execution. |
Example
agent = BidiAgent(model=model, tools=[calculator])
agent.tool.calculator(expression="2+2")
tool_names
property
¶
Get a list of all registered tool names.
Returns:
| Type | Description |
|---|---|
list[str]
|
Names of all tools available to this agent. |
__aenter__(invocation_state=None)
async
¶
Async context manager entry point.
Automatically starts the bidirectional connection when entering the context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
invocation_state
|
dict[str, Any] | None
|
Optional context to pass to tools during execution. This allows passing custom data (user_id, session_id, database connections, etc.) that tools can access via their invocation_state parameter. |
None
|
Returns:
| Type | Description |
|---|---|
BidiAgent
|
Self for use in the context. |
Source code in strands/experimental/bidi/agent/agent.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
__aexit__(*_)
async
¶
Async context manager exit point.
Automatically ends the connection and cleans up resources including when exiting the context, regardless of whether an exception occurred.
Source code in strands/experimental/bidi/agent/agent.py
324 325 326 327 328 329 330 331 | |
__init__(model=None, tools=None, system_prompt=None, messages=None, record_direct_tool_call=True, load_tools_from_directory=False, agent_id=None, name=None, description=None, hooks=None, state=None, session_manager=None, tool_executor=None, **kwargs)
¶
Initialize bidirectional agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
BidiModel | str | None
|
BidiModel instance, string model_id, or None for default detection. |
None
|
tools
|
list[str | AgentTool | ToolProvider] | None
|
Optional list of tools with flexible format support. |
None
|
system_prompt
|
str | None
|
Optional system prompt for conversations. |
None
|
messages
|
Messages | None
|
Optional conversation history to initialize with. |
None
|
record_direct_tool_call
|
bool
|
Whether to record direct tool calls in message history. |
True
|
load_tools_from_directory
|
bool
|
Whether to load and automatically reload tools in the |
False
|
agent_id
|
str | None
|
Optional ID for the agent, useful for connection management and multi-agent scenarios. |
None
|
name
|
str | None
|
Name of the Agent. |
None
|
description
|
str | None
|
Description of what the Agent does. |
None
|
hooks
|
list[HookProvider] | None
|
Optional list of hook providers to register for lifecycle events. |
None
|
state
|
AgentState | dict | None
|
Stateful information for the agent. Can be either an AgentState object, or a json serializable dict. |
None
|
session_manager
|
SessionManager | None
|
Manager for handling agent sessions including conversation history and state. If provided, enables session-based persistence and state management. |
None
|
tool_executor
|
ToolExecutor | None
|
Definition of tool execution strategy (e.g., sequential, concurrent, etc.). |
None
|
**kwargs
|
Any
|
Additional configuration for future extensibility. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If model configuration is invalid or state is invalid type. |
TypeError
|
If model type is unsupported. |
Source code in strands/experimental/bidi/agent/agent.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
receive()
async
¶
Receive events from the model including audio, text, and tool calls.
Yields:
| Type | Description |
|---|---|
AsyncGenerator[BidiOutputEvent, None]
|
Model output events processed by background tasks including audio output, |
AsyncGenerator[BidiOutputEvent, None]
|
text responses, tool calls, and connection updates. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If start has not been called. |
Source code in strands/experimental/bidi/agent/agent.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
run(inputs, outputs, invocation_state=None)
async
¶
Run the agent using provided IO channels for bidirectional communication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
list[BidiInput]
|
Input callables to read data from a source |
required |
outputs
|
list[BidiOutput]
|
Output callables to receive events from the agent |
required |
invocation_state
|
dict[str, Any] | None
|
Optional context to pass to tools during execution. This allows passing custom data (user_id, session_id, database connections, etc.) that tools can access via their invocation_state parameter. |
None
|
Example
# Using model defaults:
model = BidiNovaSonicModel()
audio_io = BidiAudioIO()
text_io = BidiTextIO()
agent = BidiAgent(model=model, tools=[calculator])
await agent.run(
inputs=[audio_io.input()],
outputs=[audio_io.output(), text_io.output()],
invocation_state={"user_id": "user_123"}
)
# Using custom audio config:
model = BidiNovaSonicModel(
provider_config={"audio": {"input_rate": 48000, "output_rate": 24000}}
)
audio_io = BidiAudioIO()
agent = BidiAgent(model=model, tools=[calculator])
await agent.run(
inputs=[audio_io.input()],
outputs=[audio_io.output()],
)
Source code in strands/experimental/bidi/agent/agent.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
send(input_data)
async
¶
Send input to the model (text, audio, image, or event dict).
Unified method for sending text, audio, and image input to the model during an active conversation session. Accepts TypedEvent instances or plain dicts (e.g., from WebSocket clients) which are automatically reconstructed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
BidiAgentInput | dict[str, Any]
|
Can be:
|
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If start has not been called. |
ValueError
|
If invalid input type. |
Example
await agent.send("Hello") await agent.send(BidiAudioInputEvent(audio="base64...", format="pcm", ...)) await agent.send({"type": "bidirectional_text_input", "text": "Hello", "role": "user"})
Source code in strands/experimental/bidi/agent/agent.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
start(invocation_state=None)
async
¶
Start a persistent bidirectional conversation connection.
Initializes the streaming connection and starts background tasks for processing model events, tool execution, and connection management.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
invocation_state
|
dict[str, Any] | None
|
Optional context to pass to tools during execution. This allows passing custom data (user_id, session_id, database connections, etc.) that tools can access via their invocation_state parameter. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If agent already started. |
Example
await agent.start(invocation_state={
"user_id": "user_123",
"session_id": "session_456",
"database": db_connection,
})
Source code in strands/experimental/bidi/agent/agent.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
stop()
async
¶
End the conversation connection and cleanup all resources.
Terminates the streaming connection, cancels background tasks, and closes the connection to the model provider.
Source code in strands/experimental/bidi/agent/agent.py
298 299 300 301 302 303 304 305 | |
BidiAgentInitializedEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered when a BidiAgent has finished initialization.
This event is fired after the BidiAgent has been fully constructed and all built-in components have been initialized. Hook providers can use this event to perform setup tasks that require a fully initialized agent.
Source code in strands/experimental/hooks/events.py
54 55 56 57 58 59 60 61 62 63 | |
BidiBeforeConnectionRestartEvent
dataclass
¶
Bases: BidiHookEvent
Event emitted before agent attempts to restart model connection after timeout.
Attributes:
| Name | Type | Description |
|---|---|---|
timeout_error |
BidiModelTimeoutError
|
Timeout error reported by the model. |
Source code in strands/experimental/hooks/events.py
205 206 207 208 209 210 211 212 213 | |
BidiBeforeInvocationEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered when BidiAgent starts a streaming session.
This event is fired before the BidiAgent begins a streaming session, before any model connection or audio processing occurs. Hook providers can use this event to perform session-level setup, logging, or validation.
This event is triggered at the beginning of agent.start().
Source code in strands/experimental/hooks/events.py
66 67 68 69 70 71 72 73 74 75 76 77 | |
BidiBeforeToolCallEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered before BidiAgent executes a tool.
This event is fired just before the BidiAgent executes a tool during a streaming session, allowing hook providers to inspect, modify, or replace the tool that will be executed. The selected_tool can be modified by hook callbacks to change which tool gets executed.
Attributes:
| Name | Type | Description |
|---|---|---|
selected_tool |
AgentTool | None
|
The tool that will be invoked. Can be modified by hooks to change which tool gets executed. This may be None if tool lookup failed. |
tool_use |
ToolUse
|
The tool parameters that will be passed to selected_tool. |
invocation_state |
dict[str, Any]
|
Keyword arguments that will be passed to the tool. |
cancel_tool |
bool | str
|
A user defined message that when set, will cancel the tool call.
The message will be placed into a tool result with an error status. If set to |
Source code in strands/experimental/hooks/events.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
BidiHookEvent
dataclass
¶
Bases: BaseHookEvent
Base class for BidiAgent hook events.
Attributes:
| Name | Type | Description |
|---|---|---|
agent |
BidiAgent
|
The BidiAgent instance that triggered this event. |
Source code in strands/experimental/hooks/events.py
43 44 45 46 47 48 49 50 51 | |
BidiInterruptionEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered when model generation is interrupted.
This event is fired when the user interrupts the assistant (e.g., by speaking during the assistant's response) or when an error causes interruption. This is specific to bidirectional streaming and doesn't exist in standard agents.
Hook providers can use this event to log interruptions, implement custom interruption handling, or trigger cleanup logic.
Attributes:
| Name | Type | Description |
|---|---|---|
reason |
Literal['user_speech', 'error']
|
The reason for the interruption ("user_speech" or "error"). |
interrupted_response_id |
str | None
|
Optional ID of the response that was interrupted. |
Source code in strands/experimental/hooks/events.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
BidiMessageAddedEvent
dataclass
¶
Bases: BidiHookEvent
Event triggered when BidiAgent adds a message to the conversation.
This event is fired whenever the BidiAgent adds a new message to its internal message history, including user messages (from transcripts), assistant responses, and tool results. Hook providers can use this event for logging, monitoring, or implementing custom message processing logic.
Note: This event is only triggered for messages added by the framework itself, not for messages manually added by tools or external code.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Message
|
The message that was added to the conversation history. |
Source code in strands/experimental/hooks/events.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
BidiModelTimeoutError
¶
Bases: Exception
Model timeout error.
Bidirectional models are often configured with a connection time limit. Nova sonic for example keeps the connection open for 8 minutes max. Upon receiving a timeout, the agent loop is configured to restart the model connection so as to create a seamless, uninterrupted experience for the user.
Source code in strands/experimental/bidi/models/model.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
__init__(message, **restart_config)
¶
Initialize error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Timeout message from model. |
required |
**restart_config
|
Any
|
Configure restart specific behaviors in the call to model start. |
{}
|
Source code in strands/experimental/bidi/models/model.py
125 126 127 128 129 130 131 132 133 134 | |
Message
¶
Bases: TypedDict
A message in a conversation with the agent.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
List[ContentBlock]
|
The message content. |
role |
Role
|
The role of the message sender. |
Source code in strands/types/content.py
178 179 180 181 182 183 184 185 186 187 | |
ToolResult
¶
Bases: TypedDict
Result of a tool execution.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
list[ToolResultContent]
|
List of result content returned by the tool. |
status |
ToolResultStatus
|
The status of the tool execution ("success" or "error"). |
toolUseId |
str
|
The unique identifier of the tool use request that produced this result. |
Source code in strands/types/tools.py
87 88 89 90 91 92 93 94 95 96 97 98 | |
ToolUse
¶
Bases: TypedDict
A request from the model to use a specific tool with the provided input.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
Any
|
The input parameters for the tool. Can be any JSON-serializable type. |
name |
str
|
The name of the tool to invoke. |
toolUseId |
str
|
A unique identifier for this specific tool use request. |
Source code in strands/types/tools.py
52 53 54 55 56 57 58 59 60 61 62 63 64 | |
__getattr__(name)
¶
Source code in strands/experimental/hooks/events.py
28 29 30 31 32 33 34 35 36 37 | |