Skip to content
v2.277.0

Experimental

@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

AgentCollaboration Class ​

Class to manage agent collaboration configuration.

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 AgentCollaboration(config: AgentCollaborationConfig)
python
AgentCollaboration(config: AgentCollaborationConfig)
java
new AgentCollaboration(AgentCollaborationConfig config)
csharp
new AgentCollaboration(AgentCollaborationConfig config)
go
NewAgentCollaboration(Config AgentCollaborationConfig)

Properties ​

collaboratorsAgentCollaborator[]collaboratorstyping.List[AgentCollaborator]collaboratorsList<AgentCollaborator>CollaboratorsAgentCollaborator[]Collaborators*[]AgentCollaborator #
Collaborators that this agent will work with.