@@ -21,7 +21,7 @@ type Deps struct {
21
21
}
22
22
23
23
// HandlerFunc is a function that handles a tool call.
24
- type HandlerFunc [Arg , Ret any ] func (tb Deps , args Arg ) (Ret , error )
24
+ type HandlerFunc [Arg , Ret any ] func (context. Context , Deps , Arg ) (Ret , error )
25
25
26
26
type Tool [Arg , Ret any ] struct {
27
27
aisdk.Tool
@@ -32,12 +32,12 @@ type Tool[Arg, Ret any] struct {
32
32
func (t Tool [Arg , Ret ]) Generic () Tool [any , any ] {
33
33
return Tool [any , any ]{
34
34
Tool : t .Tool ,
35
- Handler : func (tb Deps , args any ) (any , error ) {
35
+ Handler : func (ctx context. Context , tb Deps , args any ) (any , error ) {
36
36
typedArg , ok := args .(Arg )
37
37
if ! ok {
38
38
return nil , xerrors .Errorf ("developer error: invalid argument type for tool %s" , t .Tool .Name )
39
39
}
40
- return t .Handler (tb , typedArg )
40
+ return t .Handler (ctx , tb , typedArg )
41
41
},
42
42
}
43
43
}
@@ -165,7 +165,7 @@ func wrapAll(mw func(HandlerFunc[any, any]) HandlerFunc[any, any], tools ...Tool
165
165
var (
166
166
// All is a list of all tools that can be used in the Coder CLI.
167
167
// When you add a new tool, be sure to include it here!
168
- All = wrapAll (WithRecover ,
168
+ All = wrapAll (WithCleanContext , wrapAll ( WithRecover ,
169
169
CreateTemplate .Generic (),
170
170
CreateTemplateVersion .Generic (),
171
171
CreateWorkspace .Generic (),
@@ -182,7 +182,7 @@ var (
182
182
ReportTask .Generic (),
183
183
UploadTarFile .Generic (),
184
184
UpdateTemplateActiveVersion .Generic (),
185
- )
185
+ )... )
186
186
187
187
ReportTask = Tool [ReportTaskArgs , string ]{
188
188
Tool : aisdk.Tool {
0 commit comments