@@ -408,6 +408,11 @@ func (r *Runner) start(callCtx engine.Context, state *State, monitor Monitor, en
408
408
Content : input ,
409
409
})
410
410
411
+ input , err := r .handleInput (callCtx , monitor , env , input )
412
+ if err != nil {
413
+ return nil , err
414
+ }
415
+
411
416
if len (callCtx .Tool .Credentials ) > 0 {
412
417
var err error
413
418
env , err = r .handleCredentials (callCtx , monitor , env )
@@ -417,7 +422,6 @@ func (r *Runner) start(callCtx engine.Context, state *State, monitor Monitor, en
417
422
}
418
423
419
424
var (
420
- err error
421
425
newState * State
422
426
)
423
427
callCtx .InputContext , newState , err = r .getContext (callCtx , state , monitor , env , input )
@@ -446,7 +450,10 @@ func (r *Runner) start(callCtx engine.Context, state *State, monitor Monitor, en
446
450
}
447
451
448
452
if ! authResp .Accept {
449
- msg := fmt .Sprintf ("[AUTHORIZATION ERROR]: %s" , authResp .Message )
453
+ msg := authResp .Message
454
+ if msg == "" {
455
+ msg = "Tool call request has been denied"
456
+ }
450
457
return & State {
451
458
Continuation : & engine.Return {
452
459
Result : & msg ,
@@ -631,8 +638,12 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s
631
638
}
632
639
633
640
if state .ResumeInput != nil {
641
+ input , err := r .handleInput (callCtx , monitor , env , * state .ResumeInput )
642
+ if err != nil {
643
+ return state , err
644
+ }
634
645
engineResults = append (engineResults , engine.CallResult {
635
- User : * state . ResumeInput ,
646
+ User : input ,
636
647
})
637
648
}
638
649
@@ -689,16 +700,22 @@ func streamProgress(callCtx *engine.Context, monitor Monitor) (chan<- types.Comp
689
700
}
690
701
691
702
func (r * Runner ) subCall (ctx context.Context , parentContext engine.Context , monitor Monitor , env []string , toolID , input , callID string , toolCategory engine.ToolCategory ) (* State , error ) {
692
- callCtx , err := parentContext .SubCall (ctx , input , toolID , callID , toolCategory )
703
+ callCtx , err := parentContext .SubCallContext (ctx , input , toolID , callID , toolCategory )
693
704
if err != nil {
694
705
return nil , err
695
706
}
696
707
708
+ if toolCategory == engine .ContextToolCategory && callCtx .Tool .IsNoop () {
709
+ return & State {
710
+ Result : new (string ),
711
+ }, nil
712
+ }
713
+
697
714
return r .call (callCtx , monitor , env , input )
698
715
}
699
716
700
717
func (r * Runner ) subCallResume (ctx context.Context , parentContext engine.Context , monitor Monitor , env []string , toolID , callID string , state * State , toolCategory engine.ToolCategory ) (* State , error ) {
701
- callCtx , err := parentContext .SubCall (ctx , "" , toolID , callID , toolCategory )
718
+ callCtx , err := parentContext .SubCallContext (ctx , "" , toolID , callID , toolCategory )
702
719
if err != nil {
703
720
return nil , err
704
721
}
@@ -882,12 +899,7 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
882
899
input = string (inputBytes )
883
900
}
884
901
885
- subCtx , err := callCtx .SubCall (callCtx .Ctx , input , credToolRefs [0 ].ToolID , "" , engine .CredentialToolCategory ) // leaving callID as "" will cause it to be set by the engine
886
- if err != nil {
887
- return nil , fmt .Errorf ("failed to create subcall context for tool %s: %w" , credToolName , err )
888
- }
889
-
890
- res , err := r .call (subCtx , monitor , env , input )
902
+ res , err := r .subCall (callCtx .Ctx , callCtx , monitor , env , credToolRefs [0 ].ToolID , input , "" , engine .CredentialToolCategory )
891
903
if err != nil {
892
904
return nil , fmt .Errorf ("failed to run credential tool %s: %w" , credToolName , err )
893
905
}
0 commit comments