Commit afe9730
authored
Fix bedrock ConverseStream undocumented
## background
PR #11286 attempted to expose the stop sequence from Bedrock's Converse
API, but had a bug: it was reading from the wrong response path. The AWS
Bedrock API actually returns the stop sequence nested under a `delta`
object: `additionalModelResponseFields.delta.stop_sequence`, not
directly at `additionalModelResponseFields.stop_sequence`.
## summary
**Fixed stop sequence extraction to read from correct API response
path**
- Changed extraction path from
`additionalModelResponseFields.stop_sequence` to
`additionalModelResponseFields.delta.stop_sequence`
- Updated TypeScript schema to include `delta` wrapper in
`BedrockAdditionalModelResponseFieldsSchema`
- Updated tests to match actual AWS Bedrock API response structure
- Verified fix works with both `generateText` and `streamText`
## implementation details
The AWS Bedrock Converse API returns additional model response fields
nested under a `delta` object when using
`additionalModelResponseFieldPaths: ['/delta/stop_sequence']`. The
previous implementation incorrectly assumed the field would be at the
top level of `additionalModelResponseFields`.
**Correct structure:**
```typescript
{
messageStop: {
stopReason: "stop_sequence",
additionalModelResponseFields: {
delta: {
stop_sequence: "END" // ← nested under delta
}
}
}
}
```
## verification
Tested with `streamText` using `stopSequences: ['END']`. Confirmed
`providerMetadata.bedrock.stopSequence` now correctly returns `"END"`
when the stop sequence is triggered (previously returned `undefined`).
---
**Fixes:** #11286/delta/stop_sequence (#11410)1 parent ea6609a commit afe9730
File tree
3 files changed
+110
-9
lines changed- .changeset
- packages/amazon-bedrock/src
3 files changed
+110
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 91 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
899 | | - | |
| 899 | + | |
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
| |||
1058 | 1058 | | |
1059 | 1059 | | |
1060 | 1060 | | |
1061 | | - | |
| 1061 | + | |
1062 | 1062 | | |
1063 | 1063 | | |
1064 | 1064 | | |
| |||
1108 | 1108 | | |
1109 | 1109 | | |
1110 | 1110 | | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
1111 | 1159 | | |
1112 | 1160 | | |
1113 | 1161 | | |
| |||
2718 | 2766 | | |
2719 | 2767 | | |
2720 | 2768 | | |
2721 | | - | |
| 2769 | + | |
2722 | 2770 | | |
2723 | 2771 | | |
2724 | 2772 | | |
| |||
2789 | 2837 | | |
2790 | 2838 | | |
2791 | 2839 | | |
2792 | | - | |
| 2840 | + | |
2793 | 2841 | | |
2794 | 2842 | | |
2795 | 2843 | | |
| |||
2833 | 2881 | | |
2834 | 2882 | | |
2835 | 2883 | | |
2836 | | - | |
| 2884 | + | |
2837 | 2885 | | |
2838 | 2886 | | |
2839 | 2887 | | |
| |||
2886 | 2934 | | |
2887 | 2935 | | |
2888 | 2936 | | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
2889 | 2975 | | |
2890 | 2976 | | |
2891 | 2977 | | |
| |||
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
314 | 318 | | |
315 | 319 | | |
316 | 320 | | |
317 | 321 | | |
318 | 322 | | |
319 | 323 | | |
320 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
321 | 327 | | |
322 | 328 | | |
323 | 329 | | |
| |||
435 | 441 | | |
436 | 442 | | |
437 | 443 | | |
438 | | - | |
| 444 | + | |
439 | 445 | | |
440 | 446 | | |
441 | 447 | | |
| |||
575 | 581 | | |
576 | 582 | | |
577 | 583 | | |
578 | | - | |
| 584 | + | |
579 | 585 | | |
580 | 586 | | |
581 | 587 | | |
| |||
849 | 855 | | |
850 | 856 | | |
851 | 857 | | |
852 | | - | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
853 | 863 | | |
854 | 864 | | |
855 | 865 | | |
| |||
0 commit comments