AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Calls the Amazon Bedrock Agent Runtime InvokeAgent API operation.

Syntax

Invoke-BARAgent
-AgentId <String>
-AgentAliasId <String>
-StreamingConfigurations_ApplyGuardrailInterval <Int32>
-EnableTrace <Boolean>
-EndSession <Boolean>
-PromptCreationConfigurations_ExcludePreviousThinkingStep <Boolean>
-SessionState_File <InputFile[]>
-InputText <String>
-SessionState_InvocationId <String>
-SessionState_KnowledgeBaseConfiguration <KnowledgeBaseConfiguration[]>
-PerformanceConfig_Latency <PerformanceConfigLatency>
-MemoryId <String>
-ConversationHistory_Message <Message[]>
-PromptCreationConfigurations_PreviousConversationTurnsToInclude <Int32>
-SessionState_PromptSessionAttribute <Hashtable>
-SessionState_ReturnControlInvocationResult <InvocationResultMember[]>
-SessionState_SessionAttribute <Hashtable>
-SessionId <String>
-SourceArn <String>
-StreamingConfigurations_StreamFinalResponse <Boolean>
-Select <String>
-Force <SwitchParameter>
-ClientConfig <AmazonBedrockAgentRuntimeConfig>

Description

Sends a prompt for the agent to process and respond to. Note the following fields for the request:
  • To continue the same conversation with an agent, use the same sessionId value in the request.
  • To activate trace enablement, turn enableTrace to true. Trace enablement helps you follow the agent's reasoning process that led it to the information it processed, the actions it took, and the final result it yielded. For more information, see Trace enablement.
  • End a conversation by setting endSession to true.
  • In the sessionState object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.
The response contains both chunk and trace attributes. The final response is returned in the bytes field of the chunk object. The InvokeAgent returns one chunk for the entire interaction.
  • The attribution object contains citations for parts of the response.
  • If you set enableTrace to true in the request, you can trace the agent's steps and reasoning process that led it to the response.
  • If the action predicted was configured to return control, the response returns parameters for the action, elicited from the user, in the returnControl field.
  • Errors are also surfaced in the response.

Parameters

-AgentAliasId <String>
The alias of the agent to use.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-AgentId <String>
The unique identifier of the agent to use.
Required?True
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
Amazon.PowerShell.Cmdlets.BAR.AmazonBedrockAgentRuntimeClientCmdlet.ClientConfig
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ConversationHistory_Message <Message[]>
The conversation's messages. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSessionState_ConversationHistory_Messages
-EnableTrace <Boolean>
Specifies whether to turn on the trace or not to track the agent's reasoning process. For more information, see Trace enablement.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-EndSession <Boolean>
Specifies whether to end the session with the agent or not.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-InputText <String>
The prompt text to send the agent.If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-MemoryId <String>
The unique identifier of the agent memory.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PerformanceConfig_Latency <PerformanceConfigLatency>
To use a latency-optimized version of the model, set to optimized.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesBedrockModelConfigurations_PerformanceConfig_Latency
-PromptCreationConfigurations_ExcludePreviousThinkingStep <Boolean>
If true, the service removes any content between <thinking> tags from previous conversations in an agent session. The service will only remove content from already processed turns. This helps you remove content which might not be useful for current and subsequent invocations. This can reduce the input token count and potentially save costs. The default value is false.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesPromptCreationConfigurations_ExcludePreviousThinkingSteps
-PromptCreationConfigurations_PreviousConversationTurnsToInclude <Int32>
The number of previous conversations from the ongoing agent session to include in the conversation history of the agent prompt, during the current invocation. This gives you more granular control over the context that the model is made aware of, and helps the model remove older context which is no longer useful during the ongoing agent session.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-Select <String>
Use the -Select parameter to control the cmdlet output. The default value is '*'. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.BedrockAgentRuntime.Model.InvokeAgentResponse). Specifying the name of a property of type Amazon.BedrockAgentRuntime.Model.InvokeAgentResponse will result in that property being returned. Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-SessionId <String>
The unique identifier of the session. Use the same value across requests to continue the same conversation.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-SessionState_File <InputFile[]>
Contains information about the files used by code interpreter. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSessionState_Files
-SessionState_InvocationId <String>
The identifier of the invocation of an action. This value must match the invocationId returned in the InvokeAgent response for the action whose results are provided in the returnControlInvocationResults field. For more information, see Return control to the agent developer and Control session context.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-SessionState_KnowledgeBaseConfiguration <KnowledgeBaseConfiguration[]>
An array of configurations, each of which applies to a knowledge base attached to the agent. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSessionState_KnowledgeBaseConfigurations
-SessionState_PromptSessionAttribute <Hashtable>
Contains attributes that persist across a prompt and the values of those attributes.
  • In orchestration prompt template, these attributes replace the $prompt_session_attributes$ placeholder variable. For more information, see Prompt template placeholder variables.
  • In multi-agent collaboration, the promptSessionAttributes will only be used by supervisor agent when $prompt_session_attributes$ is present in prompt template.
Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSessionState_PromptSessionAttributes
-SessionState_ReturnControlInvocationResult <InvocationResultMember[]>
Contains information about the results from the action group invocation. For more information, see Return control to the agent developer and Control session context.If you include this field, the inputText field will be ignored. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSessionState_ReturnControlInvocationResults
-SessionState_SessionAttribute <Hashtable>
Contains attributes that persist across a session and the values of those attributes. If sessionAttributes are passed to a supervisor agent in multi-agent collaboration, it will be forwarded to all agent collaborators. Starting with version 4 of the SDK this property will default to null. If no data for this property is returned from the service the property will also be null. This was changed to improve performance and allow the SDK and caller to distinguish between a property not set or a property being empty to clear out a value. To retain the previous SDK behavior set the AWSConfigs.InitializeCollections static property to true.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSessionState_SessionAttributes
-SourceArn <String>
The ARN of the resource making the request.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-StreamingConfigurations_ApplyGuardrailInterval <Int32>
The guardrail interval to apply as response is generated. By default, the guardrail interval is set to 50 characters. If a larger interval is specified, the response will be generated in larger chunks with fewer ApplyGuardrail calls. The following examples show the response generated for Hello, I am an agent input string.Example response in chunks: Interval set to 3 characters'Hel', 'lo, ','I am', ' an', ' Age', 'nt'Each chunk has at least 3 characters except for the last chunkExample response in chunks: Interval set to 20 or more charactersHello, I am an Agent
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-StreamingConfigurations_StreamFinalResponse <Boolean>
Specifies whether to enable streaming for the final response. This is set to false by default.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-EndpointUrl <String>
The endpoint to make the call against.Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet returns an Amazon.BedrockAgentRuntime.Model.InvokeAgentResponse object containing multiple properties.

Supported Version

AWS Tools for PowerShell: 2.x.y.z