Skip to content

invoke_agent_runtime_command

Operation

Async only

This operation uses an event stream, so only the asynchronous client supports it.

invoke_agent_runtime_command async

invoke_agent_runtime_command(request: InvokeAgentRuntimeCommandInput | InvokeAgentRuntimeCommandInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[InvokeAgentRuntimeCommandInputDict]) -> AsyncOutputEventStream[InvokeAgentRuntimeCommandStreamOutput, InvokeAgentRuntimeCommandOutput]

Executes a command in a runtime session container and streams the output back to the caller. This operation allows you to run shell commands within the agent runtime environment and receive real-time streaming responses including standard output and standard error.

To invoke a command, you must specify the agent runtime ARN and a runtime session ID. The command execution supports streaming responses, allowing you to receive output as it becomes available through contentStart, contentDelta, and contentStop events.

To use this operation, you must have the bedrock-agentcore:InvokeAgentRuntimeCommand permission.

Parameters:

Name Type Description Default
request InvokeAgentRuntimeCommandInput | InvokeAgentRuntimeCommandInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[InvokeAgentRuntimeCommandInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
AsyncOutputEventStream[InvokeAgentRuntimeCommandStreamOutput, InvokeAgentRuntimeCommandOutput]

An AsyncOutputEventStream for server-to-client streaming.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

InvokeAgentRuntimeCommandInputDict

Bases: TypedDict

Dictionary form of InvokeAgentRuntimeCommandInput.

Attributes

accept instance-attribute
accept: str | None

The desired MIME type for the response from the agent runtime command. This tells the agent runtime what format to use for the response data. Common values include application/json for JSON data.

account_id instance-attribute
account_id: str | None

The identifier of the Amazon Web Services account for the agent runtime resource. This parameter is required when you specify an agent ID instead of the full ARN for agentRuntimeArn.

agent_runtime_arn instance-attribute
agent_runtime_arn: Required[str]

The Amazon Resource Name (ARN) of the agent runtime on which to execute the command. This identifies the specific agent runtime environment where the command will run.

baggage instance-attribute
baggage: str | None

Additional context information for distributed tracing.

body instance-attribute

The request body containing the command to execute and optional configuration parameters such as timeout settings.

content_type instance-attribute
content_type: str | None

The MIME type of the input data in the request payload. This tells the agent runtime how to interpret the payload data. Common values include application/json for JSON data.

qualifier instance-attribute
qualifier: str | None

The qualifier to use for the agent runtime. This is an endpoint name that points to a specific version. If not specified, Amazon Bedrock AgentCore uses the default endpoint of the agent runtime.

runtime_session_id instance-attribute
runtime_session_id: str | None

The unique identifier of the runtime session in which to execute the command. This session ID is used to maintain state and context across multiple command invocations.

This field is autopopulated if not provided.

trace_id instance-attribute
trace_id: str | None

The trace identifier for request tracking.

trace_parent instance-attribute
trace_parent: str | None

The parent trace information for distributed tracing.

trace_state instance-attribute
trace_state: str | None

The trace state information for distributed tracing.

InvokeAgentRuntimeCommandInput dataclass

Bases: _SerdeShape

Request for InvokeAgentRuntimeCommand operation.

Attributes

accept class-attribute instance-attribute
accept: str | None = ...

The desired MIME type for the response from the agent runtime command. This tells the agent runtime what format to use for the response data. Common values include application/json for JSON data.

account_id class-attribute instance-attribute
account_id: str | None = ...

The identifier of the Amazon Web Services account for the agent runtime resource. This parameter is required when you specify an agent ID instead of the full ARN for agentRuntimeArn.

agent_runtime_arn class-attribute instance-attribute
agent_runtime_arn: str | None = ...

The Amazon Resource Name (ARN) of the agent runtime on which to execute the command. This identifies the specific agent runtime environment where the command will run.

baggage class-attribute instance-attribute
baggage: str | None = ...

Additional context information for distributed tracing.

body class-attribute instance-attribute

The request body containing the command to execute and optional configuration parameters such as timeout settings.

content_type class-attribute instance-attribute
content_type: str | None = ...

The MIME type of the input data in the request payload. This tells the agent runtime how to interpret the payload data. Common values include application/json for JSON data.

qualifier class-attribute instance-attribute
qualifier: str | None = ...

The qualifier to use for the agent runtime. This is an endpoint name that points to a specific version. If not specified, Amazon Bedrock AgentCore uses the default endpoint of the agent runtime.

runtime_session_id class-attribute instance-attribute
runtime_session_id: str | None = ...

The unique identifier of the runtime session in which to execute the command. This session ID is used to maintain state and context across multiple command invocations.

This field is autopopulated if not provided.

trace_id class-attribute instance-attribute
trace_id: str | None = ...

The trace identifier for request tracking.

trace_parent class-attribute instance-attribute
trace_parent: str | None = ...

The parent trace information for distributed tracing.

trace_state class-attribute instance-attribute
trace_state: str | None = ...

The trace state information for distributed tracing.

Output

This operation returns an AsyncOutputEventStream for server-to-client streaming.

Event Stream Structure

Output Event Type

InvokeAgentRuntimeCommandStreamOutput

Initial Response Structure

InvokeAgentRuntimeCommandOutput dataclass

Bases: _SerdeShape

Response for InvokeAgentRuntimeCommand operation.

Attributes
baggage class-attribute instance-attribute
baggage: str | None = ...

Additional context information for distributed tracing.

content_type instance-attribute
content_type: str

The MIME type of the response data. This indicates how to interpret the response data. Common values include application/json for JSON data.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

runtime_session_id class-attribute instance-attribute
runtime_session_id: str | None = ...

The unique identifier of the runtime session in which the command was executed.

status_code class-attribute instance-attribute
status_code: int | None = ...

The HTTP status code of the response. A status code of 200 indicates a successful operation. Other status codes indicate various error conditions.

trace_id class-attribute instance-attribute
trace_id: str | None = ...

The trace identifier for request tracking.

trace_parent class-attribute instance-attribute
trace_parent: str | None = ...

The parent trace information for distributed tracing.

trace_state class-attribute instance-attribute
trace_state: str | None = ...

The trace state information for distributed tracing.