From 83ea3efbc136bcdcd58926187c1d78b216dc192c Mon Sep 17 00:00:00 2001 From: Dan Lew Date: Wed, 13 May 2026 13:54:50 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20feat:=20Support=20Guardrail=20Co?= =?UTF-8?q?nfig=20Option=20`streamProcessingMode`=20(#12815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `streamProcessingMode` affects how guardrail processes the stream from the model. If it's in "sync" mode, it chunks up the response and processes them before returning them to the user. If it's in "async" mode, it both processes the chunk & sends it to the user at the same time, allowing for smoother streaming (at the cost of guardrail only reacting *after* offending content starts to stream, in some cases). --- packages/api/src/endpoints/bedrock/initialize.spec.ts | 1 + packages/api/src/types/bedrock.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/api/src/endpoints/bedrock/initialize.spec.ts b/packages/api/src/endpoints/bedrock/initialize.spec.ts index decf9a7df9..a06dbb779c 100644 --- a/packages/api/src/endpoints/bedrock/initialize.spec.ts +++ b/packages/api/src/endpoints/bedrock/initialize.spec.ts @@ -129,6 +129,7 @@ describe('initializeBedrock', () => { guardrailIdentifier: 'test-guardrail-id', guardrailVersion: '1', trace: 'enabled' as const, + streamProcessingMode: 'async', }; const params = createMockParams({ diff --git a/packages/api/src/types/bedrock.ts b/packages/api/src/types/bedrock.ts index 8f34b2864d..6608c52fcf 100644 --- a/packages/api/src/types/bedrock.ts +++ b/packages/api/src/types/bedrock.ts @@ -19,6 +19,8 @@ export interface GuardrailConfiguration { guardrailVersion: string; /** The trace behavior for the guardrail */ trace?: 'enabled' | 'disabled' | 'enabled_full'; + /** The processing mode for guardrail; 'sync' is the default guardrail behavior if unset */ + streamProcessingMode?: 'sync' | 'async'; } /**