Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
AgentProps Struct
Properties for creating a CDK managed Bedrock Agent.
TODO: Knowledge bases configuration will be added in a future update TODO: Inference profile configuration will be added in a future update
| Stability | Experimental |
|---|---|
| Source | bedrock/agents/agent.ts |
Example
const parserFunction = new lambda.Function(this, 'ParserFunction', {
runtime: lambda.Runtime.PYTHON_3_10,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda'),
});
const agent = new bedrock.Agent(this, 'Agent', {
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
instruction: 'You are a helpful assistant.',
promptOverrideConfiguration: bedrock.PromptOverrideConfiguration.withCustomParser({
parser: parserFunction,
preProcessingStep: {
stepType: bedrock.AgentStepType.PRE_PROCESSING,
useCustomParser: true
}
})
});
parser_function = lambda_.Function(self, "ParserFunction",
runtime=lambda_.Runtime.PYTHON_3_10,
handler="index.handler",
code=lambda_.Code.from_asset("lambda")
)
agent = bedrock.Agent(self, "Agent",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
instruction="You are a helpful assistant.",
prompt_override_configuration=bedrock.PromptOverrideConfiguration.with_custom_parser(
parser=parser_function,
pre_processing_step=bedrock.PromptPreProcessingConfigCustomParser(
step_type=bedrock.AgentStepType.PRE_PROCESSING,
use_custom_parser=True
)
)
)
Function parserFunction = Function.Builder.create(this, "ParserFunction")
.runtime(Runtime.PYTHON_3_10)
.handler("index.handler")
.code(Code.fromAsset("lambda"))
.build();
Agent agent = Agent.Builder.create(this, "Agent")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.instruction("You are a helpful assistant.")
.promptOverrideConfiguration(PromptOverrideConfiguration.withCustomParser(CustomParserProps.builder()
.parser(parserFunction)
.preProcessingStep(PromptPreProcessingConfigCustomParser.builder()
.stepType(AgentStepType.PRE_PROCESSING)
.useCustomParser(true)
.build())
.build()))
.build();
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var parserFunction = new Function(this, "ParserFunction", new FunctionProps {
Runtime = Runtime.PYTHON_3_10,
Handler = "index.handler",
Code = Code.FromAsset("lambda")
});
var agent = new Agent(this, "Agent", new AgentProps {
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
Instruction = "You are a helpful assistant.",
PromptOverrideConfiguration = PromptOverrideConfiguration.WithCustomParser(new CustomParserProps {
Parser = parserFunction,
PreProcessingStep = new PromptPreProcessingConfigCustomParser {
StepType = AgentStepType.PRE_PROCESSING,
UseCustomParser = true
}
})
});
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
parserFunction := lambda.NewFunction(this, jsii.String("ParserFunction"), &FunctionProps{
Runtime: lambda.Runtime_PYTHON_3_10(),
Handler: jsii.String("index.handler"),
Code: lambda.Code_FromAsset(jsii.String("lambda")),
})
agent := bedrock.NewAgent(this, jsii.String("Agent"), &AgentProps{
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
Instruction: jsii.String("You are a helpful assistant."),
PromptOverrideConfiguration: bedrock.PromptOverrideConfiguration_WithCustomParser(&CustomParserProps{
Parser: parserFunction,
PreProcessingStep: &PromptPreProcessingConfigCustomParser{
StepType: bedrock.AgentStepType_PRE_PROCESSING,
UseCustomParser: jsii.Boolean(true),
},
}),
})
Properties
actionGroupsoptionalAgentActionGroup[]action_groupsoptionaltyping.List[AgentActionGroup]actionGroupsoptionalList<AgentActionGroup>ActionGroupsoptionalAgentActionGroup[]ActionGroupsoptional*[]AgentActionGroup #Default: Only default action groups (UserInput and CodeInterpreter) are added
agentCollaborationoptionalAgentCollaborationagent_collaborationoptionalAgentCollaborationagentCollaborationoptionalAgentCollaborationAgentCollaborationoptionalAgentCollaborationAgentCollaborationoptionalAgentCollaboration #Default: No agent collaboration configuration.
This property allows you to define how the agent collaborates with other agents and what collaborators it can work with.
agentNameoptionalstringagent_nameoptionalstragentNameoptionalStringAgentNameoptionalstringAgentNameoptional*string #Default: A name is generated by CDK. Supported pattern : ^([0-9a-zA-Z][_-]?){1,100}$
This will be used as the physical name of the agent.
codeInterpreterEnabledoptionalbooleancode_interpreter_enabledoptionalboolcodeInterpreterEnabledoptionalBooleanCodeInterpreterEnabledoptionalboolCodeInterpreterEnabledoptional*bool = false #customOrchestrationExecutoroptionalCustomOrchestrationExecutorcustom_orchestration_executoroptionalCustomOrchestrationExecutorcustomOrchestrationExecutoroptionalCustomOrchestrationExecutorCustomOrchestrationExecutoroptionalCustomOrchestrationExecutorCustomOrchestrationExecutoroptionalCustomOrchestrationExecutor #Default: Default orchestration
If provided, custom orchestration will be used. If not provided, default orchestration will be used.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #Default: No description is provided.
existingRoleoptionalIRoleexisting_roleoptionalIRoleexistingRoleoptionalIRoleExistingRoleoptionalIRoleExistingRoleoptionalIRole #Default: A new role is created for you.
Use this property when you want to reuse an existing IAM role rather than create a new one. The role must have a trust policy that allows the Bedrock service to assume it.
forceDeleteoptionalbooleanforce_deleteoptionalboolforceDeleteoptionalBooleanForceDeleteoptionalboolForceDeleteoptional*bool = false #foundationModelIBedrockInvokablefoundation_modelIBedrockInvokablefoundationModelIBedrockInvokableFoundationModelIBedrockInvokableFoundationModelIBedrockInvokable required #guardrailoptionalIGuardrailguardrailoptionalIGuardrailguardrailoptionalIGuardrailGuardrailoptionalIGuardrailGuardrailoptionalIGuardrail #Default: No guardrail is provided.
idleSessionTTLoptionalDurationidle_session_ttloptionalDurationidleSessionTTLoptionalDurationIdleSessionTTLoptionalDurationIdleSessionTTLoptionalDuration #Default: 10 minutes
If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout.
This determines how the agent will perform his task. This instruction must have a minimum of 40 characters.
Default: An AWS managed key is used.
memoryoptionalMemorymemoryoptionalMemorymemoryoptionalMemoryMemoryoptionalMemoryMemoryoptionalMemory #Default: No memory will be used. Agents will retain context from the current session only.
This can be useful for maintaining continuity in multi-turn conversations and recalling user preferences or past interactions.
promptOverrideConfigurationoptionalPromptOverrideConfigurationprompt_override_configurationoptionalPromptOverrideConfigurationpromptOverrideConfigurationoptionalPromptOverrideConfigurationPromptOverrideConfigurationoptionalPromptOverrideConfigurationPromptOverrideConfigurationoptionalPromptOverrideConfiguration #Default: No overrides are provided.
shouldPrepareAgentoptionalbooleanshould_prepare_agentoptionalboolshouldPrepareAgentoptionalBooleanShouldPrepareAgentoptionalboolShouldPrepareAgentoptional*bool = false #The DRAFT version can be continually iterated upon during internal development.
userInputEnabledoptionalbooleanuser_input_enabledoptionalbooluserInputEnabledoptionalBooleanUserInputEnabledoptionalboolUserInputEnabledoptional*bool = false #