> **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.
# PromptOverrideConfiguration

Configuration for overriding prompt templates and behaviors in different parts of an agent's sequence.

This allows customizing how the agent processes inputs,
makes decisions, and generates responses.

Obtainable from: PromptOverrideConfiguration.fromSteps, PromptOverrideConfiguration.withCustomParser

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

## Example

TypeScript:

```ts
const agent = new bedrock.Agent(this, 'Agent', {
  foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
  instruction: 'You are a helpful assistant.',
  promptOverrideConfiguration: bedrock.PromptOverrideConfiguration.fromSteps([
    {
      stepType: bedrock.AgentStepType.ROUTING_CLASSIFIER,
      stepEnabled: true,
      customPromptTemplate: 'Your routing template here',
      foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2
    } as bedrock.PromptRoutingClassifierConfigCustomParser
  ])
});
```

Python:

```python
agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    instruction="You are a helpful assistant.",
    prompt_override_configuration=bedrock.PromptOverrideConfiguration.from_steps([
        step_type=bedrock.AgentStepType.ROUTING_CLASSIFIER,
        step_enabled=True,
        custom_prompt_template="Your routing template here",
        foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_V2

    ])
)
```

Java:

```java
Agent agent = Agent.Builder.create(this, "Agent")
        .foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
        .instruction("You are a helpful assistant.")
        .promptOverrideConfiguration(PromptOverrideConfiguration.fromSteps(List.of((PromptRoutingClassifierConfigCustomParser)PromptRoutingClassifierConfigCustomParser.builder()
                .stepType(AgentStepType.ROUTING_CLASSIFIER)
                .stepEnabled(true)
                .customPromptTemplate("Your routing template here")
                .foundationModel(BedrockFoundationModel.ANTHROPIC_CLAUDE_V2)
                .build())))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var agent = new Agent(this, "Agent", new AgentProps {
    FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
    Instruction = "You are a helpful assistant.",
    PromptOverrideConfiguration = PromptOverrideConfiguration.FromSteps(new [] { (PromptRoutingClassifierConfigCustomParser)new PromptRoutingClassifierConfigCustomParser {
        StepType = AgentStepType.ROUTING_CLASSIFIER,
        StepEnabled = true,
        CustomPromptTemplate = "Your routing template here",
        FoundationModel = BedrockFoundationModel.ANTHROPIC_CLAUDE_V2
    } })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
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_FromSteps([]PromptStepConfigBase{
		&PromptRoutingClassifierConfigCustomParser{
			StepType: bedrock.AgentStepType_ROUTING_CLASSIFIER,
			StepEnabled: jsii.Boolean(true),
			CustomPromptTemplate: jsii.String("Your routing template here"),
			FoundationModel: bedrock.BedrockFoundationModel_ANTHROPIC_CLAUDE_V2(),
		}.(PromptRoutingClassifierConfigCustomParser),
	}),
})
```

## Properties

- `knowledgeBaseResponseGenerationStep`: [PromptKnowledgeBaseResponseGenerationConfigCustomParser](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptKnowledgeBaseResponseGenerationConfigCustomParser.html) — Configuration for the knowledge base response generation step.

- `memorySummarizationStep`: [PromptMemorySummarizationConfigCustomParser](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptMemorySummarizationConfigCustomParser.html) — Configuration for the memory summarization step.

- `orchestrationStep`: [PromptOrchestrationConfigCustomParser](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptOrchestrationConfigCustomParser.html) — Configuration for the orchestration step.

- `parser`: [IFunction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) — The custom Lambda parser function to use.

  The Lambda parser processes and interprets the raw foundation model output.
  It receives an input event with:
  - messageVersion: Version of message format (1.0)
  - agent: Info about the agent (name, id, alias, version)
  - invokeModelRawResponse: Raw model output to parse
  - promptType: Type of prompt being parsed
  - overrideType: Type of override (OUTPUT_PARSER)

  The Lambda must return a response that the agent uses for next actions.

- `postProcessingStep`: [PromptPostProcessingConfigCustomParser](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptPostProcessingConfigCustomParser.html) — Configuration for the post-processing step.

- `preProcessingStep`: [PromptPreProcessingConfigCustomParser](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptPreProcessingConfigCustomParser.html) — Configuration for the pre-processing step.

- `routingClassifierStep`: [PromptRoutingClassifierConfigCustomParser](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.PromptRoutingClassifierConfigCustomParser.html) — Configuration for the routing classifier step.

## Methods

- `fromSteps(steps: PromptStepConfigBase[]): PromptOverrideConfiguration // chainable` (static) — Creates a PromptOverrideConfiguration from individual step configurations.

  Use this method when you want to override prompts without using a custom parser.

  **Parameters**

  - `steps` — The step configurations to use.

  **Returns:** A new PromptOverrideConfiguration instance

- `withCustomParser(props: CustomParserProps): PromptOverrideConfiguration // chainable` (static) — Creates a PromptOverrideConfiguration with a custom Lambda parser function.

  **Parameters**

  - `props` — Configuration including: - `parser`: Lambda function to use as custom parser - Individual step configurations.
