Skip to content

Commit b6204f8

Browse files
author
awstools
committed
feat(client-bedrock-agent-runtime): Now supports streaming for inline agents.
1 parent a550721 commit b6204f8

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

clients/client-bedrock-agent-runtime/src/commands/InvokeAgentCommand.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
3838

3939
/**
4040
* <note>
41-
* <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeAgent</code>.</p>
42-
* </note>
41+
* </note>
4342
* <p>Sends a prompt for the agent to process and respond to. Note the following fields for the request:</p>
4443
* <ul>
4544
* <li>
@@ -74,7 +73,8 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
7473
* <p>In the <code>sessionState</code> object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.</p>
7574
* </li>
7675
* </ul>
77-
* <p>The response is returned in the <code>bytes</code> field of the <code>chunk</code> object.</p>
76+
* <p>The response contains both <b>chunk</b> and <b>trace</b> attributes.</p>
77+
* <p>The final response is returned in the <code>bytes</code> field of the <code>chunk</code> object. The <code>InvokeAgent</code> returns one chunk for the entire interaction.</p>
7878
* <ul>
7979
* <li>
8080
* <p>The <code>attribution</code> object contains citations for parts of the response.</p>

clients/client-bedrock-agent-runtime/src/commands/InvokeInlineAgentCommand.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
6161
* </li>
6262
* </ul>
6363
* <note>
64-
* <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeInlineAgent</code>.</p>
65-
* </note>
64+
* </note>
6665
* @example
6766
* Use a bare-bones client and the command you need to make an API call.
6867
* ```javascript
@@ -298,6 +297,10 @@ export interface InvokeInlineAgentCommandOutput extends InvokeInlineAgentRespons
298297
* latency: "standard" || "optimized",
299298
* },
300299
* },
300+
* streamingConfigurations: { // StreamingConfigurations
301+
* streamFinalResponse: true || false,
302+
* applyGuardrailInterval: Number("int"),
303+
* },
301304
* };
302305
* const command = new InvokeInlineAgentCommand(input);
303306
* const response = await client.send(command);

clients/client-bedrock-agent-runtime/src/models/models_0.ts

+11
Original file line numberDiff line numberDiff line change
@@ -8650,6 +8650,17 @@ export interface InvokeInlineAgentRequest {
86508650
* @public
86518651
*/
86528652
bedrockModelConfigurations?: InlineBedrockModelConfigurations | undefined;
8653+
8654+
/**
8655+
* <p>
8656+
* Specifies the configurations for streaming.
8657+
* </p>
8658+
* <note>
8659+
* <p>To use agent streaming, you need permissions to perform the <code>bedrock:InvokeModelWithResponseStream</code> action.</p>
8660+
* </note>
8661+
* @public
8662+
*/
8663+
streamingConfigurations?: StreamingConfigurations | undefined;
86538664
}
86548665

86558666
/**

clients/client-bedrock-agent-runtime/src/protocols/Aws_restJson1.ts

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ export const se_InvokeInlineAgentCommand = async (
341341
instruction: [],
342342
knowledgeBases: (_) => se_KnowledgeBases(_, context),
343343
promptOverrideConfiguration: (_) => se_PromptOverrideConfiguration(_, context),
344+
streamingConfigurations: (_) => _json(_),
344345
})
345346
);
346347
b.m("POST").h(headers).b(body);

codegen/sdk-codegen/aws-models/bedrock-agent-runtime.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -4657,7 +4657,7 @@
46574657
}
46584658
],
46594659
"traits": {
4660-
"smithy.api#documentation": "<note>\n <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeAgent</code>.</p>\n </note>\n <p>Sends a prompt for the agent to process and respond to. Note the following fields for the request:</p>\n <ul>\n <li>\n <p>To continue the same conversation with an agent, use the same <code>sessionId</code> value in the request.</p>\n </li>\n <li>\n <p>To activate trace enablement, turn <code>enableTrace</code> to <code>true</code>. Trace enablement helps you follow the agent's reasoning process that led it to the information it processed, the actions it took, and the final result it yielded. For more information, see <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/agents-test.html#trace-events\">Trace enablement</a>.</p>\n </li>\n <li>\n <p>To stream agent responses, make sure that only orchestration prompt is enabled. Agent streaming is not supported for the following steps:\n </p>\n <ul>\n <li>\n <p>\n <code>Pre-processing</code>\n </p>\n </li>\n <li>\n <p>\n <code>Post-processing</code>\n </p>\n </li>\n <li>\n <p>Agent with 1 Knowledge base and <code>User Input</code> not enabled</p>\n </li>\n </ul>\n </li>\n <li>\n <p>End a conversation by setting <code>endSession</code> to <code>true</code>.</p>\n </li>\n <li>\n <p>In the <code>sessionState</code> object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.</p>\n </li>\n </ul>\n <p>The response is returned in the <code>bytes</code> field of the <code>chunk</code> object.</p>\n <ul>\n <li>\n <p>The <code>attribution</code> object contains citations for parts of the response.</p>\n </li>\n <li>\n <p>If you set <code>enableTrace</code> to <code>true</code> in the request, you can trace the agent's steps and reasoning process that led it to the response.</p>\n </li>\n <li>\n <p>If the action predicted was configured to return control, the response returns parameters for the action, elicited from the user, in the <code>returnControl</code> field.</p>\n </li>\n <li>\n <p>Errors are also surfaced in the response.</p>\n </li>\n </ul>",
4660+
"smithy.api#documentation": "<note>\n </note>\n <p>Sends a prompt for the agent to process and respond to. Note the following fields for the request:</p>\n <ul>\n <li>\n <p>To continue the same conversation with an agent, use the same <code>sessionId</code> value in the request.</p>\n </li>\n <li>\n <p>To activate trace enablement, turn <code>enableTrace</code> to <code>true</code>. Trace enablement helps you follow the agent's reasoning process that led it to the information it processed, the actions it took, and the final result it yielded. For more information, see <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/agents-test.html#trace-events\">Trace enablement</a>.</p>\n </li>\n <li>\n <p>To stream agent responses, make sure that only orchestration prompt is enabled. Agent streaming is not supported for the following steps:\n </p>\n <ul>\n <li>\n <p>\n <code>Pre-processing</code>\n </p>\n </li>\n <li>\n <p>\n <code>Post-processing</code>\n </p>\n </li>\n <li>\n <p>Agent with 1 Knowledge base and <code>User Input</code> not enabled</p>\n </li>\n </ul>\n </li>\n <li>\n <p>End a conversation by setting <code>endSession</code> to <code>true</code>.</p>\n </li>\n <li>\n <p>In the <code>sessionState</code> object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.</p>\n </li>\n </ul>\n <p>The response contains both <b>chunk</b> and <b>trace</b> attributes.</p>\n <p>The final response is returned in the <code>bytes</code> field of the <code>chunk</code> object. The <code>InvokeAgent</code> returns one chunk for the entire interaction.</p>\n <ul>\n <li>\n <p>The <code>attribution</code> object contains citations for parts of the response.</p>\n </li>\n <li>\n <p>If you set <code>enableTrace</code> to <code>true</code> in the request, you can trace the agent's steps and reasoning process that led it to the response.</p>\n </li>\n <li>\n <p>If the action predicted was configured to return control, the response returns parameters for the action, elicited from the user, in the <code>returnControl</code> field.</p>\n </li>\n <li>\n <p>Errors are also surfaced in the response.</p>\n </li>\n </ul>",
46614661
"smithy.api#http": {
46624662
"code": 200,
46634663
"method": "POST",
@@ -4928,7 +4928,7 @@
49284928
}
49294929
],
49304930
"traits": {
4931-
"smithy.api#documentation": "<p>\n Invokes an inline Amazon Bedrock agent using the configurations you provide with the request.\n </p>\n <ul>\n <li>\n <p>Specify the following fields for security purposes.</p>\n <ul>\n <li>\n <p>(Optional) <code>customerEncryptionKeyArn</code> – The Amazon Resource Name (ARN) of a KMS key to encrypt the creation of the agent.</p>\n </li>\n <li>\n <p>(Optional) <code>idleSessionTTLinSeconds</code> – Specify the number of seconds for which the agent should maintain session information. After this time expires, the subsequent <code>InvokeInlineAgent</code> request begins a new session.</p>\n </li>\n </ul>\n </li>\n <li>\n <p>To override the default prompt behavior for agent orchestration and to use advanced prompts, include a <code>promptOverrideConfiguration</code> object. \n For more information, see <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/advanced-prompts.html\">Advanced prompts</a>.</p>\n </li>\n <li>\n <p>The agent instructions will not be honored if your agent has only one knowledge base, uses default prompts, has no action group, and user input is disabled.</p>\n </li>\n </ul>\n <note>\n <p>The CLI doesn't support streaming operations in Amazon Bedrock, including <code>InvokeInlineAgent</code>.</p>\n </note>",
4931+
"smithy.api#documentation": "<p>\n Invokes an inline Amazon Bedrock agent using the configurations you provide with the request.\n </p>\n <ul>\n <li>\n <p>Specify the following fields for security purposes.</p>\n <ul>\n <li>\n <p>(Optional) <code>customerEncryptionKeyArn</code> – The Amazon Resource Name (ARN) of a KMS key to encrypt the creation of the agent.</p>\n </li>\n <li>\n <p>(Optional) <code>idleSessionTTLinSeconds</code> – Specify the number of seconds for which the agent should maintain session information. After this time expires, the subsequent <code>InvokeInlineAgent</code> request begins a new session.</p>\n </li>\n </ul>\n </li>\n <li>\n <p>To override the default prompt behavior for agent orchestration and to use advanced prompts, include a <code>promptOverrideConfiguration</code> object. \n For more information, see <a href=\"https://docs.aws.amazon.com/bedrock/latest/userguide/advanced-prompts.html\">Advanced prompts</a>.</p>\n </li>\n <li>\n <p>The agent instructions will not be honored if your agent has only one knowledge base, uses default prompts, has no action group, and user input is disabled.</p>\n </li>\n </ul>\n <note>\n </note>",
49324932
"smithy.api#http": {
49334933
"code": 200,
49344934
"method": "POST",
@@ -5026,6 +5026,12 @@
50265026
"traits": {
50275027
"smithy.api#documentation": "<p>Model settings for the request.</p>"
50285028
}
5029+
},
5030+
"streamingConfigurations": {
5031+
"target": "com.amazonaws.bedrockagentruntime#StreamingConfigurations",
5032+
"traits": {
5033+
"smithy.api#documentation": "<p>\n Specifies the configurations for streaming.\n </p>\n <note>\n <p>To use agent streaming, you need permissions to perform the <code>bedrock:InvokeModelWithResponseStream</code> action.</p>\n </note>"
5034+
}
50295035
}
50305036
},
50315037
"traits": {

0 commit comments

Comments
 (0)