Skip to content

Commit 9621bd3

Browse files
author
awstools
committed
feat(client-bedrock-agent-runtime): bedrock flow now support node action trace.
1 parent 7b29a72 commit 9621bd3

File tree

7 files changed

+201
-63
lines changed

7 files changed

+201
-63
lines changed

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

-19
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,6 @@ export interface InvokeAgentCommandOutput extends InvokeAgentResponse, __Metadat
4444
* <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>
4545
* </li>
4646
* <li>
47-
* <p>To stream agent responses, make sure that only orchestration prompt is enabled. Agent streaming is not supported for the following steps:
48-
* </p>
49-
* <ul>
50-
* <li>
51-
* <p>
52-
* <code>Pre-processing</code>
53-
* </p>
54-
* </li>
55-
* <li>
56-
* <p>
57-
* <code>Post-processing</code>
58-
* </p>
59-
* </li>
60-
* <li>
61-
* <p>Agent with 1 Knowledge base and <code>User Input</code> not enabled</p>
62-
* </li>
63-
* </ul>
64-
* </li>
65-
* <li>
6647
* <p>End a conversation by setting <code>endSession</code> to <code>true</code>.</p>
6748
* </li>
6849
* <li>

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

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ export interface InvokeFlowCommandOutput extends InvokeFlowResponse, __MetadataB
117117
* // },
118118
* // ],
119119
* // },
120+
* // nodeActionTrace: { // FlowTraceNodeActionEvent
121+
* // nodeName: "STRING_VALUE", // required
122+
* // timestamp: new Date("TIMESTAMP"), // required
123+
* // requestId: "STRING_VALUE", // required
124+
* // serviceName: "STRING_VALUE", // required
125+
* // operationName: "STRING_VALUE", // required
126+
* // },
120127
* // },
121128
* // },
122129
* // internalServerException: { // InternalServerException

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
ServiceOutputTypes,
1111
} from "../BedrockAgentRuntimeClient";
1212
import { commonParams } from "../endpoint/EndpointParameters";
13-
import { UpdateSessionRequest, UpdateSessionResponse } from "../models/models_0";
13+
import { UpdateSessionRequest } from "../models/models_0";
14+
import { UpdateSessionResponse } from "../models/models_1";
1415
import { de_UpdateSessionCommand, se_UpdateSessionCommand } from "../protocols/Aws_restJson1";
1516

1617
/**

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

+84-40
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,43 @@ export interface FlowTraceConditionNodeResultEvent {
17741774
satisfiedConditions: FlowTraceCondition[] | undefined;
17751775
}
17761776

1777+
/**
1778+
* <p>Contains information about an action (operation) called by a node in an Amazon Bedrock flow. The service generates action events for calls made by prompt nodes,
1779+
* agent nodes, and Amazon Web Services Lambda nodes. </p>
1780+
* @public
1781+
*/
1782+
export interface FlowTraceNodeActionEvent {
1783+
/**
1784+
* <p>The name of the node that called the operation.</p>
1785+
* @public
1786+
*/
1787+
nodeName: string | undefined;
1788+
1789+
/**
1790+
* <p>The date and time that the operation was called.</p>
1791+
* @public
1792+
*/
1793+
timestamp: Date | undefined;
1794+
1795+
/**
1796+
* <p>The ID of the request that the node made to the operation.</p>
1797+
* @public
1798+
*/
1799+
requestId: string | undefined;
1800+
1801+
/**
1802+
* <p>The name of the service that the node called.</p>
1803+
* @public
1804+
*/
1805+
serviceName: string | undefined;
1806+
1807+
/**
1808+
* <p>The name of the operation that the node called.</p>
1809+
* @public
1810+
*/
1811+
operationName: string | undefined;
1812+
}
1813+
17771814
/**
17781815
* <p>Contains the content of the node input. For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-trace.html">Track each step in your prompt flow by viewing its trace in Amazon Bedrock</a>.</p>
17791816
* @public
@@ -1944,6 +1981,7 @@ export interface FlowTraceNodeOutputEvent {
19441981
*/
19451982
export type FlowTrace =
19461983
| FlowTrace.ConditionNodeResultTraceMember
1984+
| FlowTrace.NodeActionTraceMember
19471985
| FlowTrace.NodeInputTraceMember
19481986
| FlowTrace.NodeOutputTraceMember
19491987
| FlowTrace.$UnknownMember;
@@ -1960,6 +1998,7 @@ export namespace FlowTrace {
19601998
nodeInputTrace: FlowTraceNodeInputEvent;
19611999
nodeOutputTrace?: never;
19622000
conditionNodeResultTrace?: never;
2001+
nodeActionTrace?: never;
19632002
$unknown?: never;
19642003
}
19652004

@@ -1971,6 +2010,7 @@ export namespace FlowTrace {
19712010
nodeInputTrace?: never;
19722011
nodeOutputTrace: FlowTraceNodeOutputEvent;
19732012
conditionNodeResultTrace?: never;
2013+
nodeActionTrace?: never;
19742014
$unknown?: never;
19752015
}
19762016

@@ -1982,6 +2022,20 @@ export namespace FlowTrace {
19822022
nodeInputTrace?: never;
19832023
nodeOutputTrace?: never;
19842024
conditionNodeResultTrace: FlowTraceConditionNodeResultEvent;
2025+
nodeActionTrace?: never;
2026+
$unknown?: never;
2027+
}
2028+
2029+
/**
2030+
* <p>Contains information about an action (operation) called by a node.
2031+
* For more information, see <a href="https://docs.aws.amazon.com/bedrock/latest/userguide/flows-trace.html">Track each step in your prompt flow by viewing its trace in Amazon Bedrock</a>.</p>
2032+
* @public
2033+
*/
2034+
export interface NodeActionTraceMember {
2035+
nodeInputTrace?: never;
2036+
nodeOutputTrace?: never;
2037+
conditionNodeResultTrace?: never;
2038+
nodeActionTrace: FlowTraceNodeActionEvent;
19852039
$unknown?: never;
19862040
}
19872041

@@ -1992,13 +2046,15 @@ export namespace FlowTrace {
19922046
nodeInputTrace?: never;
19932047
nodeOutputTrace?: never;
19942048
conditionNodeResultTrace?: never;
2049+
nodeActionTrace?: never;
19952050
$unknown: [string, any];
19962051
}
19972052

19982053
export interface Visitor<T> {
19992054
nodeInputTrace: (value: FlowTraceNodeInputEvent) => T;
20002055
nodeOutputTrace: (value: FlowTraceNodeOutputEvent) => T;
20012056
conditionNodeResultTrace: (value: FlowTraceConditionNodeResultEvent) => T;
2057+
nodeActionTrace: (value: FlowTraceNodeActionEvent) => T;
20022058
_: (name: string, value: any) => T;
20032059
}
20042060

@@ -2007,6 +2063,7 @@ export namespace FlowTrace {
20072063
if (value.nodeOutputTrace !== undefined) return visitor.nodeOutputTrace(value.nodeOutputTrace);
20082064
if (value.conditionNodeResultTrace !== undefined)
20092065
return visitor.conditionNodeResultTrace(value.conditionNodeResultTrace);
2066+
if (value.nodeActionTrace !== undefined) return visitor.nodeActionTrace(value.nodeActionTrace);
20102067
return visitor._(value.$unknown[0], value.$unknown[1]);
20112068
};
20122069
}
@@ -3114,8 +3171,7 @@ export interface VectorSearchRerankingConfiguration {
31143171
}
31153172

31163173
/**
3117-
* <p>
3118-
* Configurations for streaming.</p>
3174+
* <p>Configurations for streaming.</p>
31193175
* @public
31203176
*/
31213177
export interface StreamingConfigurations {
@@ -3128,9 +3184,24 @@ export interface StreamingConfigurations {
31283184
streamFinalResponse?: boolean | undefined;
31293185

31303186
/**
3131-
* <p>
3132-
* The guardrail interval to apply as response is generated.
3133-
* </p>
3187+
* <p> The guardrail interval to apply as response is generated. By default, the guardrail
3188+
* interval is set to 50 characters. If a larger interval is specified, the response will
3189+
* be generated in larger chunks with fewer <code>ApplyGuardrail</code> calls. The
3190+
* following examples show the response generated for <i>Hello, I am an
3191+
* agent</i> input string.</p>
3192+
* <p>
3193+
* <b>Example response in chunks: Interval set to 3 characters</b>
3194+
* </p>
3195+
* <p>
3196+
* <code>'Hel', 'lo, ','I am', ' an', ' Age', 'nt'</code>
3197+
* </p>
3198+
* <p>Each chunk has at least 3 characters except for the last chunk</p>
3199+
* <p>
3200+
* <b>Example response in chunks: Interval set to 20 or more characters</b>
3201+
* </p>
3202+
* <p>
3203+
* <code>Hello, I am an Agent</code>
3204+
* </p>
31343205
* @public
31353206
*/
31363207
applyGuardrailInterval?: number | undefined;
@@ -9123,41 +9194,6 @@ export interface UpdateSessionRequest {
91239194
sessionIdentifier: string | undefined;
91249195
}
91259196

9126-
/**
9127-
* @public
9128-
*/
9129-
export interface UpdateSessionResponse {
9130-
/**
9131-
* <p>The unique identifier of the session you updated.</p>
9132-
* @public
9133-
*/
9134-
sessionId: string | undefined;
9135-
9136-
/**
9137-
* <p>The Amazon Resource Name (ARN) of the session that was updated.</p>
9138-
* @public
9139-
*/
9140-
sessionArn: string | undefined;
9141-
9142-
/**
9143-
* <p>The status of the session you updated.</p>
9144-
* @public
9145-
*/
9146-
sessionStatus: SessionStatus | undefined;
9147-
9148-
/**
9149-
* <p>The timestamp for when the session was created.</p>
9150-
* @public
9151-
*/
9152-
createdAt: Date | undefined;
9153-
9154-
/**
9155-
* <p>The timestamp for when the session was last modified.</p>
9156-
* @public
9157-
*/
9158-
lastUpdatedAt: Date | undefined;
9159-
}
9160-
91619197
/**
91629198
* @internal
91639199
*/
@@ -9386,6 +9422,13 @@ export const FlowTraceConditionNodeResultEventFilterSensitiveLog = (obj: FlowTra
93869422
...(obj.satisfiedConditions && { satisfiedConditions: SENSITIVE_STRING }),
93879423
});
93889424

9425+
/**
9426+
* @internal
9427+
*/
9428+
export const FlowTraceNodeActionEventFilterSensitiveLog = (obj: FlowTraceNodeActionEvent): any => ({
9429+
...obj,
9430+
});
9431+
93899432
/**
93909433
* @internal
93919434
*/
@@ -9433,6 +9476,7 @@ export const FlowTraceFilterSensitiveLog = (obj: FlowTrace): any => {
94339476
if (obj.nodeInputTrace !== undefined) return { nodeInputTrace: SENSITIVE_STRING };
94349477
if (obj.nodeOutputTrace !== undefined) return { nodeOutputTrace: SENSITIVE_STRING };
94359478
if (obj.conditionNodeResultTrace !== undefined) return { conditionNodeResultTrace: SENSITIVE_STRING };
9479+
if (obj.nodeActionTrace !== undefined) return { nodeActionTrace: SENSITIVE_STRING };
94369480
if (obj.$unknown !== undefined) return { [obj.$unknown[0]]: "UNKNOWN" };
94379481
};
94389482

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

+36
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,47 @@ import {
3434
RetrieveAndGenerateSessionConfiguration,
3535
RetrieveAndGenerateType,
3636
SearchType,
37+
SessionStatus,
3738
StreamingConfigurations,
3839
VectorSearchRerankingConfiguration,
3940
VectorSearchRerankingConfigurationFilterSensitiveLog,
4041
} from "./models_0";
4142

43+
/**
44+
* @public
45+
*/
46+
export interface UpdateSessionResponse {
47+
/**
48+
* <p>The unique identifier of the session you updated.</p>
49+
* @public
50+
*/
51+
sessionId: string | undefined;
52+
53+
/**
54+
* <p>The Amazon Resource Name (ARN) of the session that was updated.</p>
55+
* @public
56+
*/
57+
sessionArn: string | undefined;
58+
59+
/**
60+
* <p>The status of the session you updated.</p>
61+
* @public
62+
*/
63+
sessionStatus: SessionStatus | undefined;
64+
65+
/**
66+
* <p>The timestamp for when the session was created.</p>
67+
* @public
68+
*/
69+
createdAt: Date | undefined;
70+
71+
/**
72+
* <p>The timestamp for when the session was last modified.</p>
73+
* @public
74+
*/
75+
lastUpdatedAt: Date | undefined;
76+
}
77+
4278
/**
4379
* @public
4480
*/

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

+19
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ import {
117117
FlowTrace,
118118
FlowTraceConditionNodeResultEvent,
119119
FlowTraceEvent,
120+
FlowTraceNodeActionEvent,
120121
FlowTraceNodeInputContent,
121122
FlowTraceNodeInputEvent,
122123
FlowTraceNodeInputField,
@@ -3260,6 +3261,11 @@ const de_FlowTrace = (output: any, context: __SerdeContext): FlowTrace => {
32603261
conditionNodeResultTrace: de_FlowTraceConditionNodeResultEvent(output.conditionNodeResultTrace, context),
32613262
};
32623263
}
3264+
if (output.nodeActionTrace != null) {
3265+
return {
3266+
nodeActionTrace: de_FlowTraceNodeActionEvent(output.nodeActionTrace, context),
3267+
};
3268+
}
32633269
if (output.nodeInputTrace != null) {
32643270
return {
32653271
nodeInputTrace: de_FlowTraceNodeInputEvent(output.nodeInputTrace, context),
@@ -3300,6 +3306,19 @@ const de_FlowTraceEvent = (output: any, context: __SerdeContext): FlowTraceEvent
33003306
}) as any;
33013307
};
33023308

3309+
/**
3310+
* deserializeAws_restJson1FlowTraceNodeActionEvent
3311+
*/
3312+
const de_FlowTraceNodeActionEvent = (output: any, context: __SerdeContext): FlowTraceNodeActionEvent => {
3313+
return take(output, {
3314+
nodeName: __expectString,
3315+
operationName: __expectString,
3316+
requestId: __expectString,
3317+
serviceName: __expectString,
3318+
timestamp: (_: any) => __expectNonNull(__parseRfc3339DateTimeWithOffset(_)),
3319+
}) as any;
3320+
};
3321+
33033322
/**
33043323
* deserializeAws_restJson1FlowTraceNodeInputContent
33053324
*/

0 commit comments

Comments
 (0)