Repository navigation
Commit 1eaafd5
committed
feat(bedrock): send thinking blocks back with their signatures
This implements what Anthropic docs recommend.
Opus 5.5, Fable 5/5.1 and Mythos 5.1 on Bedrock now keep their earlier
reasoning across tool calls instead of starting over at each step.
Before, Zoo sent none of the thinking blocks back to the model.
Anthropic's guidance, from thinking#preserving-thinking-blocks:
> Required: within a tool-use turn, pass thinking blocks back.
> Recommended: across turns, pass everything back.
> Allowed: outside tool use, omit prior turns' thinking.
Zoo follows the recommended option and sends every stored block back,
across the whole history.
- Bedrock collects each reasoningContent block (text, signature,
redacted content) and emits it whole at contentBlockStop as a new
`thinking_block` chunk. Blocks with an empty text are kept too.
- Task stores those blocks in the assistant turn in the order the model
produced them, between text and tool_use blocks. It no longer stores
a separate copy of the same text.
- The Converse converter sends them back as reasoningContent for these
models. For other models it drops them, instead of turning unknown
blocks into "[Unknown Block Type]" text.
- The request sets thinking.block_binding.prefix_mismatch_behavior to
"drop_block" with the thinking-binding-controls-2026-08-01 beta.
These models bind each block to the prefix before it (system prompt,
tools, earlier messages), and Zoo edits that prefix (condensing, mode
switches, environment details). Accounts created on or after
2026-08-31 would otherwise get a 400 on the first such edit.
Checked live through AwsBedrockHandler (2026-09-27), with reasoning on
and off:
- Opus 5.5, Fable 5 and Fable 5.1: a tool round trip with the blocks
sent back works, and after a system-prompt edit it still works with
drop_block. Mythos 5.1 wasn't available to test; AWS says it
records the binding but doesn't check it.
- Opus 5.5 only:
- With "error", Bedrock returns the documented 400.
- Zoo's Bedrock prompt caching adds `cachePoint` markers to messages and
moves them between requests. A marker added to an earlier message
does not invalidate the thinking blocks after it, even with "error".
Otherwise every cached request would drop the model's reasoning.
Zoo can't tell which blocks were dropped, because it uses
ConverseStream. The API lists them in input_transformations, which it
puts in the message_start event of Anthropic's own streaming format
(what InvokeModelWithResponseStream returns unchanged).
AWS documents that ConverseStream returns any field requested in
additionalModelResponseFieldPaths, but we observe the opposite for this
field. In the live test ConverseStream only resolved paths into the
final message_delta event: /delta/stop_details and /usage came back,
/input_transformations and /message/input_transformations did not.
Non-streaming Converse and InvokeModelWithResponseStream did return
input_transformations. AWS doesn't document the message_delta
behaviour; Vercel's AI SDK hit it independently (commit afe9730,
"Fix bedrock ConverseStream undocumented /delta/stop_sequence").
- https://platform.claude.com/docs/en/build-with-claude/thinking#preserving-thinking-blocks
- https://platform.claude.com/docs/en/build-with-claude/preserved-thinking
- https://docs.aws.amazon.com/bedrock/latest/userguide/claude-messages-thinking-block-binding.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html#converse-additional-model-response-field-paths
- vercel/ai@afe9730
- https://repost.aws/questions/QUJqYEmLvUTSOCZ6FkRCiqjA (question we asked)
See also Zoo-Code-Org#1820.1 parent d76d4e4 commit 1eaafd5
9 files changed
Lines changed: 550 additions & 136 deletions
File tree
- src
- api
- providers
- __tests__
- transform
- __tests__
- core/task
- __tests__
- integrations/misc
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1862 | 1862 | | |
1863 | 1863 | | |
1864 | 1864 | | |
1865 | | - | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
1866 | 1870 | | |
| 1871 | + | |
1867 | 1872 | | |
1868 | 1873 | | |
1869 | 1874 | | |
1870 | 1875 | | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
1871 | 2009 | | |
1872 | 2010 | | |
1873 | 2011 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
122 | 167 | | |
123 | 168 | | |
124 | 169 | | |
| |||
132 | 177 | | |
133 | 178 | | |
134 | 179 | | |
| 180 | + | |
135 | 181 | | |
136 | 182 | | |
137 | 183 | | |
| |||
201 | 247 | | |
202 | 248 | | |
203 | 249 | | |
| 250 | + | |
| 251 | + | |
204 | 252 | | |
205 | 253 | | |
206 | 254 | | |
| |||
228 | 276 | | |
229 | 277 | | |
230 | 278 | | |
| 279 | + | |
231 | 280 | | |
232 | 281 | | |
233 | 282 | | |
| |||
421 | 470 | | |
422 | 471 | | |
423 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
424 | 478 | | |
425 | 479 | | |
426 | 480 | | |
| |||
518 | 572 | | |
519 | 573 | | |
520 | 574 | | |
| 575 | + | |
521 | 576 | | |
522 | 577 | | |
523 | 578 | | |
524 | 579 | | |
525 | 580 | | |
526 | 581 | | |
| 582 | + | |
527 | 583 | | |
528 | 584 | | |
529 | 585 | | |
| |||
639 | 695 | | |
640 | 696 | | |
641 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
642 | 705 | | |
643 | 706 | | |
644 | 707 | | |
| |||
883 | 946 | | |
884 | 947 | | |
885 | 948 | | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
886 | 961 | | |
887 | | - | |
888 | | - | |
| 962 | + | |
| 963 | + | |
889 | 964 | | |
890 | 965 | | |
891 | 966 | | |
| |||
913 | 988 | | |
914 | 989 | | |
915 | 990 | | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
916 | 1008 | | |
917 | 1009 | | |
918 | 1010 | | |
| |||
1118 | 1210 | | |
1119 | 1211 | | |
1120 | 1212 | | |
| 1213 | + | |
1121 | 1214 | | |
1122 | 1215 | | |
1123 | | - | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
1124 | 1219 | | |
1125 | 1220 | | |
1126 | 1221 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
8 | 51 | | |
9 | 52 | | |
10 | 53 | | |
| |||
0 commit comments