Creates a Bedrock Agent Runnable that can be used with an AgentExecutor or with LangGraph.
This also sets up the Bedrock agent, actions and action groups infrastructure if they don't exist, ensures the agent is in PREPARED state so that it is ready to be called.
create_agent(
cls,
agent_name: str,
agent_resource_role_arn: str,
foundation_model: str,
instruction: str,
tools: List[BaseTool] = [],
*,
client_token: Optional[str] = None,
customer_encryption_key_arn: Optional[str] = None,
description: Optional[str] = None,
guardrail_configuration: Optional[GuardrailConfiguration] = None,
idle_session_ttl_in_seconds: Optional[int] = None,
credentials_profile_name: Optional[str] = None,
region_name: Optional[str] = None,
bedrock_endpoint_url: Optional[str] = None,
runtime_endpoint_url: Optional[str] = None,
enable_trace: Optional[bool] = False,
enable_human_input: Optional[bool] = False,
enable_code_interpreter: Optional[bool] = False,
**kwargs: Any = {}
) -> BedrockAgentsRunnableReturns: BedrockAgentsRunnable configured to invoke the Bedrock agent
| Name | Type | Description |
|---|---|---|
agent_name* | str | Name of the agent |
agent_resource_role_arn* | str | The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the agent. |
foundation_model* | str | The foundation model to be used for orchestration by the agent you create |
instruction* | str | Instructions that tell the agent what it should do and how it should interact with users |
tools | List[BaseTool] | Default: []List of tools. Accepts LangChain's BaseTool format |
client_token | Optional[str] | Default: NoneA unique, case-sensitive identifier to ensure that the API request completes no more than one time. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error |
customer_encryption_key_arn | Optional[str] | Default: NoneThe Amazon Resource Name (ARN) of the KMS key with which to encrypt the agent |
description | Optional[str] | Default: NoneA description of the agent |
guardrail_configuration | Optional[GuardrailConfiguration] | Default: NoneThe unique Guardrail configuration assigned to the agent when it is created. |
idle_session_ttl_in_seconds | Optional[int] | Default: NoneThe number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent. A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout |
credentials_profile_name | Optional[str] | Default: NoneThe profile name to use if different from default |
region_name | Optional[str] | Default: NoneRegion for the Bedrock agent |
bedrock_endpoint_url | Optional[str] | Default: NoneEndpoint URL for bedrock agent |
runtime_endpoint_url | Optional[str] | Default: NoneEndpoint URL for bedrock agent runtime |
enable_trace | Optional[bool] | Default: FalseBoolean flag to specify whether trace should be enabled when invoking the agent |
enable_human_input | Optional[bool] | Default: FalseBoolean flag to specify whether a human as a tool should be enabled for the agent. |
enable_code_interpreter | Optional[bool] | Default: FalseBoolean flag to specify whether a code interpreter |
**kwargs | Any | Default: {}Additional arguments |