Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
AgentCollaborator Class
**************************************************************************** Agent Collaborator Class ***************************************************************************.
| Stability | Experimental |
|---|---|
| Source | bedrock/agents/agent-collaborator.ts |
Example
ts
// Create a specialized agent
const customerSupportAgent = new bedrock.Agent(this, 'CustomerSupportAgent', {
instruction: 'You specialize in answering customer support questions.',
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
});
// Create an agent alias
const customerSupportAlias = new bedrock.AgentAlias(this, 'CustomerSupportAlias', {
agent: customerSupportAgent,
agentAliasName: 'production',
});
// Create a main agent that collaborates with the specialized agent
const mainAgent = new bedrock.Agent(this, 'MainAgent', {
instruction: 'You route specialized questions to other agents.',
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
agentCollaboration: {
type: bedrock.AgentCollaboratorType.SUPERVISOR,
collaborators: [
new bedrock.AgentCollaborator({
agentAlias: customerSupportAlias,
collaborationInstruction: 'Route customer support questions to this agent.',
collaboratorName: 'CustomerSupport',
relayConversationHistory: true
}),
],
},
});
python
# Create a specialized agent
customer_support_agent = bedrock.Agent(self, "CustomerSupportAgent",
instruction="You specialize in answering customer support questions.",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1
)
# Create an agent alias
customer_support_alias = bedrock.AgentAlias(self, "CustomerSupportAlias",
agent=customer_support_agent,
agent_alias_name="production"
)
# Create a main agent that collaborates with the specialized agent
main_agent = bedrock.Agent(self, "MainAgent",
instruction="You route specialized questions to other agents.",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
agent_collaboration={
"type": bedrock.AgentCollaboratorType.SUPERVISOR,
"collaborators": [
bedrock.AgentCollaborator(
agent_alias=customer_support_alias,
collaboration_instruction="Route customer support questions to this agent.",
collaborator_name="CustomerSupport",
relay_conversation_history=True
)
]
}
)
java
// Create a specialized agent
Agent customerSupportAgent = Agent.Builder.create(this, "CustomerSupportAgent")
.instruction("You specialize in answering customer support questions.")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.build();
// Create an agent alias
AgentAlias customerSupportAlias = AgentAlias.Builder.create(this, "CustomerSupportAlias")
.agent(customerSupportAgent)
.agentAliasName("production")
.build();
// Create a main agent that collaborates with the specialized agent
Agent mainAgent = Agent.Builder.create(this, "MainAgent")
.instruction("You route specialized questions to other agents.")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.agentCollaboration(Map.of(
"type", AgentCollaboratorType.SUPERVISOR,
"collaborators", List.of(
AgentCollaborator.Builder.create()
.agentAlias(customerSupportAlias)
.collaborationInstruction("Route customer support questions to this agent.")
.collaboratorName("CustomerSupport")
.relayConversationHistory(true)
.build())))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
// Create a specialized agent
var customerSupportAgent = new Agent(this, "CustomerSupportAgent", new AgentProps {
Instruction = "You specialize in answering customer support questions.",
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1
});
// Create an agent alias
var customerSupportAlias = new AgentAlias(this, "CustomerSupportAlias", new AgentAliasProps {
Agent = customerSupportAgent,
AgentAliasName = "production"
});
// Create a main agent that collaborates with the specialized agent
var mainAgent = new Agent(this, "MainAgent", new AgentProps {
Instruction = "You route specialized questions to other agents.",
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
AgentCollaboration = new Dictionary<string, object> {
{ "type", AgentCollaboratorType.SUPERVISOR },
{ "collaborators", new [] {
new AgentCollaborator(new AgentCollaboratorProps {
AgentAlias = customerSupportAlias,
CollaborationInstruction = "Route customer support questions to this agent.",
CollaboratorName = "CustomerSupport",
RelayConversationHistory = true
}) } }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
// Create a specialized agent
customerSupportAgent := bedrock.NewAgent(this, jsii.String("CustomerSupportAgent"), &AgentProps{
Instruction: jsii.String("You specialize in answering customer support questions."),
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
})
// Create an agent alias
customerSupportAlias := bedrock.NewAgentAlias(this, jsii.String("CustomerSupportAlias"), &AgentAliasProps{
Agent: customerSupportAgent,
AgentAliasName: jsii.String("production"),
})
// Create a main agent that collaborates with the specialized agent
mainAgent := bedrock.NewAgent(this, jsii.String("MainAgent"), &AgentProps{
Instruction: jsii.String("You route specialized questions to other agents."),
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
AgentCollaboration: map[string]interface{}{
"type": bedrock.AgentCollaboratorType_SUPERVISOR,
"collaborators": []AgentCollaborator{
bedrock.NewAgentCollaborator(&AgentCollaboratorProps{
"agentAlias": customerSupportAlias,
"collaborationInstruction": jsii.String("Route customer support questions to this agent."),
"collaboratorName": jsii.String("CustomerSupport"),
"relayConversationHistory": jsii.Boolean(true),
}),
},
},
})
Initializer
ts
new AgentCollaborator(props: AgentCollaboratorProps)
python
AgentCollaborator(props: AgentCollaboratorProps)
java
new AgentCollaborator(AgentCollaboratorProps props)
csharp
new AgentCollaborator(AgentCollaboratorProps props)
go
NewAgentCollaborator(Props AgentCollaboratorProps)
Properties
agentAliasIAgentAliasagent_aliasIAgentAliasagentAliasIAgentAliasAgentAliasIAgentAliasAgentAliasIAgentAlias #The agent alias that this collaborator represents.
This is the agent that will be called upon for collaboration.
collaborationInstructionstringcollaboration_instructionstrcollaborationInstructionStringCollaborationInstructionstringCollaborationInstruction*string #Instructions on how this agent should collaborate with the main agent.
collaboratorNamestringcollaborator_namestrcollaboratorNameStringCollaboratorNamestringCollaboratorName*string #A friendly name for the collaborator.
relayConversationHistorymay be undefinedbooleanrelay_conversation_historymay be undefinedboolrelayConversationHistorymay be undefinedBooleanRelayConversationHistorymay be undefinedboolRelayConversationHistorymay be undefined*bool #Whether to relay conversation history to this collaborator.
Default: undefined (uses service default)
Methods
grant(grantee: IGrantable): Grantdef grant(self, grantee: IGrantable) -> Grantpublic Grant grant(IGrantable grantee)public Grant Grant(IGrantable grantee)func Grant(Grantee IGrantable) Grant #Grants the given identity permissions to collaborate with the agent [disable-awslint:no-grants].
1 parameter · returns
Parameters
granteegranteegranteegranteeGrantee— The principal to grant permissions to.
Returns: The Grant object