invoke_agent_runtime_command
¶
invoke_agent_runtime_command(
agent_runtime_arn: str,
body: InvokeAgentRuntimeCommandRequestBody,
*,
config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
content_type: Optional[MimeType] = None,
accept: Optional[MimeType] = None,
runtime_session_id: Optional[SessionType] = None,
trace_id: Optional[str] = None,
trace_parent: Optional[str] = None,
trace_state: Optional[str] = None,
baggage: Optional[str] = None,
qualifier: Optional[str] = None,
account_id: Optional[str] = None,
) -> Generator[InvokeAgentRuntimeCommandResponse]
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:
-
content_type(Optional[MimeType], default: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.
-
accept(Optional[MimeType], default: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.
-
runtime_session_id(Optional[SessionType], default: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.
-
trace_id(Optional[str], default:None) –The trace identifier for request tracking.
-
trace_parent(Optional[str], default:None) –The parent trace information for distributed tracing.
-
trace_state(Optional[str], default:None) –The trace state information for distributed tracing.
-
baggage(Optional[str], default:None) –Additional context information for distributed tracing.
-
agent_runtime_arn(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.
-
qualifier(Optional[str], default: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.
-
account_id(Optional[str], default: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. -
body(InvokeAgentRuntimeCommandRequestBody) –The request body containing the command to execute and optional configuration parameters such as timeout settings.
Raises:
-
AccessDeniedException–The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.
-
InternalServerException–The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.
-
ResourceNotFoundException–The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.
-
RetryableConflictException–The exception that occurs when there is a retryable conflict performing an operation. This is a temporary condition that may resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.
-
RuntimeClientError–The exception that occurs when there is an error in the runtime client. This can happen due to network issues, invalid configuration, or other client-side problems. Check the error message for specific details about the error.
-
ServiceQuotaExceededException–The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.
-
ThrottlingException–The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.
-
ValidationException–The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock_agentcore/_services/bedrock_agent_core.py
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | |