🪨 fix: Preserve Bedrock Guardrail Config (#13381)

This commit is contained in:
Danny Avila 2026-05-28 21:38:53 -07:00 committed by GitHub
parent 94c73123ee
commit 786dae41bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 0 deletions

View file

@ -29,6 +29,34 @@ describe('excludedKeys', () => {
});
});
describe('bedrockEndpointSchema', () => {
it('preserves guardrailConfig from configSchema parsing', () => {
const guardrailConfig = {
guardrailIdentifier: '${BEDROCK_GUARDRAIL_ID}',
guardrailVersion: '${BEDROCK_GUARDRAIL_VERSION}',
trace: 'enabled_full',
streamProcessingMode: 'sync',
};
const result = configSchema.safeParse({
version: '1.0',
endpoints: {
bedrock: {
streamRate: 25,
availableRegions: ['us-west-2'],
guardrailConfig,
},
},
});
expect(result.success).toBe(true);
if (!result.success) {
return;
}
expect(result.data.endpoints?.bedrock?.guardrailConfig).toEqual(guardrailConfig);
});
});
describe('resolveEndpointType', () => {
describe('non-agents endpoints', () => {
it('returns the config type for a custom endpoint', () => {

View file

@ -403,10 +403,18 @@ export const baseEndpointSchema = z.object({
export type TBaseEndpoint = z.infer<typeof baseEndpointSchema>;
export const bedrockGuardrailConfigSchema = z.object({
guardrailIdentifier: z.string(),
guardrailVersion: z.string(),
trace: z.enum(['enabled', 'disabled', 'enabled_full']).optional(),
streamProcessingMode: z.enum(['sync', 'async']).optional(),
});
export const bedrockEndpointSchema = baseEndpointSchema.merge(
z.object({
availableRegions: z.array(z.string()).optional(),
models: z.array(z.string()).optional(),
guardrailConfig: bedrockGuardrailConfigSchema.optional(),
inferenceProfiles: z.record(z.string(), z.string()).optional(),
}),
);