@@ -21,7 +21,7 @@ type Deps struct {
2121}
2222
2323// 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 )
2525
2626type Tool [Arg ,Ret any ]struct {
2727aisdk.Tool
@@ -32,12 +32,12 @@ type Tool[Arg, Ret any] struct {
3232func (t Tool [Arg ,Ret ])Generic ()Tool [any ,any ] {
3333return Tool [any ,any ]{
3434Tool :t .Tool ,
35- Handler :func (tb Deps ,args any ) (any ,error ) {
35+ Handler :func (ctx context. Context , tb Deps ,args any ) (any ,error ) {
3636typedArg ,ok := args .(Arg )
3737if ! ok {
3838return nil ,xerrors .Errorf ("developer error: invalid argument type for tool %s" ,t .Tool .Name )
3939}
40- return t .Handler (tb ,typedArg )
40+ return t .Handler (ctx , tb ,typedArg )
4141},
4242}
4343}
@@ -165,7 +165,7 @@ func wrapAll(mw func(HandlerFunc[any, any]) HandlerFunc[any, any], tools ...Tool
165165var (
166166// All is a list of all tools that can be used in the Coder CLI.
167167// When you add a new tool, be sure to include it here!
168- All = wrapAll (WithRecover ,
168+ All = wrapAll (WithCleanContext , wrapAll ( WithRecover ,
169169CreateTemplate .Generic (),
170170CreateTemplateVersion .Generic (),
171171CreateWorkspace .Generic (),
@@ -182,7 +182,7 @@ var (
182182ReportTask .Generic (),
183183UploadTarFile .Generic (),
184184UpdateTemplateActiveVersion .Generic (),
185- )
185+ )... )
186186
187187ReportTask = Tool [ReportTaskArgs ,string ]{
188188Tool : aisdk.Tool {