Commit d1a6fe9 1 parent 6514498 commit d1a6fe9 Copy full SHA for d1a6fe9
File tree 1 file changed +23
-1
lines changed
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,28 @@ export class AnthropicProvider implements Provider {
105
105
} ;
106
106
} ) ;
107
107
108
+ const tools : Anthropic . Tool [ ] = ToolManager . TOOL_SPECS . map (
109
+ ( t , idx ) : Anthropic . Tool => {
110
+ if ( idx == ToolManager . TOOL_SPECS . length - 1 ) {
111
+ /** Assuming that the ordering when the prompt is sent to anthropic will be:
112
+ * system
113
+ * tools
114
+ *
115
+ * So marking the last tool with cache_control should use the first cache breakpoint to tag the end of this opening section.
116
+ */
117
+ return {
118
+ ...t ,
119
+ input_schema : t . input_schema as Anthropic . Messages . Tool . InputSchema ,
120
+ cache_control : { type : "ephemeral" } ,
121
+ } ;
122
+ }
123
+ return {
124
+ ...t ,
125
+ input_schema : t . input_schema as Anthropic . Messages . Tool . InputSchema ,
126
+ } ;
127
+ } ,
128
+ ) ;
129
+
108
130
try {
109
131
this . request = this . client . messages
110
132
. stream ( {
@@ -116,7 +138,7 @@ export class AnthropicProvider implements Provider {
116
138
type : "auto" ,
117
139
disable_parallel_tool_use : false ,
118
140
} ,
119
- tools : ToolManager . TOOL_SPECS as Anthropic . Tool [ ] ,
141
+ tools,
120
142
} )
121
143
. on ( "text" , ( text : string ) => {
122
144
buf . push ( text ) ;
You can’t perform that action at this time.
0 commit comments