🚧 feat: Support Guardrail Config Option streamProcessingMode (#12815)

`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).
This commit is contained in:
Dan Lew 2026-05-13 13:54:50 -05:00 committed by GitHub
parent e0a4e53b7f
commit 83ea3efbc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View file

@ -129,6 +129,7 @@ describe('initializeBedrock', () => {
guardrailIdentifier: 'test-guardrail-id',
guardrailVersion: '1',
trace: 'enabled' as const,
streamProcessingMode: 'async',
};
const params = createMockParams({

View file

@ -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';
}
/**