> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# CustomOrchestrationExecutor

Contains details about the Lambda function containing the orchestration logic carried out upon invoking the custom orchestration.

Obtainable from: CustomOrchestrationExecutor.fromLambda

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`bedrock/agents/orchestration-executor.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/agents/orchestration-executor.ts#L26)

## Example

TypeScript:

```ts
const orchestrationFunction = new lambda.Function(this, 'OrchestrationFunction', {
  runtime: lambda.Runtime.PYTHON_3_10,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda/orchestration'),
});

const agent = new bedrock.Agent(this, 'CustomOrchestrationAgent', {
  instruction: 'You are a helpful assistant with custom orchestration logic.',
  foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
  customOrchestrationExecutor: bedrock.CustomOrchestrationExecutor.fromLambda(orchestrationFunction),
});
```

Python:

```python
orchestration_function = lambda_.Function(self, "OrchestrationFunction",
    runtime=lambda_.Runtime.PYTHON_3_10,
    handler="index.handler",
    code=lambda_.Code.from_asset("lambda/orchestration")
)

agent = bedrock.Agent(self, "CustomOrchestrationAgent",
    instruction="You are a helpful assistant with custom orchestration logic.",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    custom_orchestration_executor=bedrock.CustomOrchestrationExecutor.from_lambda(orchestration_function)
)
```

Java:

```java
Function orchestrationFunction = Function.Builder.create(this, "OrchestrationFunction")
        .runtime(Runtime.PYTHON_3_10)
        .handler("index.handler")
        .code(Code.fromAsset("lambda/orchestration"))
        .build();

Agent agent = Agent.Builder.create(this, "CustomOrchestrationAgent")
        .instruction("You are a helpful assistant with custom orchestration logic.")
        .foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
        .customOrchestrationExecutor(CustomOrchestrationExecutor.fromLambda(orchestrationFunction))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var orchestrationFunction = new Function(this, "OrchestrationFunction", new FunctionProps {
    Runtime = Runtime.PYTHON_3_10,
    Handler = "index.handler",
    Code = Code.FromAsset("lambda/orchestration")
});

var agent = new Agent(this, "CustomOrchestrationAgent", new AgentProps {
    Instruction = "You are a helpful assistant with custom orchestration logic.",
    FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    CustomOrchestrationExecutor = CustomOrchestrationExecutor.FromLambda(orchestrationFunction)
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
orchestrationFunction := lambda.NewFunction(this, jsii.String("OrchestrationFunction"), &FunctionProps{
	Runtime: lambda.Runtime_PYTHON_3_10(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(jsii.String("lambda/orchestration")),
})

agent := bedrock.NewAgent(this, jsii.String("CustomOrchestrationAgent"), &AgentProps{
	Instruction: jsii.String("You are a helpful assistant with custom orchestration logic."),
	FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
	CustomOrchestrationExecutor: bedrock.CustomOrchestrationExecutor_FromLambda(orchestrationFunction),
})
```

## Properties

- `lambdaFunction`: [IFunction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — The Lambda function that contains the custom orchestration logic.

  This function is called when the agent needs to make decisions about action execution.

- `type`: [OrchestrationType](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.OrchestrationType.html) — The type of orchestration this executor performs.

## Methods

- `fromLambda(lambdaFunction: IFunction): CustomOrchestrationExecutor // chainable` (static) — Defines an orchestration executor with a Lambda function containing the business logic.

  **Parameters**

  - `lambdaFunction` — - Lambda function to be called by the orchestration.
