mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
feat: add action timeout for StartToGoal
This commit is contained in:
+19
-2
@@ -119,8 +119,25 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
|
|||||||
planningResult.SubActions = append(planningResult.SubActions, subActionResult)
|
planningResult.SubActions = append(planningResult.SubActions, subActionResult)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Execute the tool call
|
// Create action context with timeout if specified
|
||||||
if err := dExt.invokeToolCall(ctx, toolCall, opts...); err != nil {
|
actionCtx := ctx
|
||||||
|
if options.Timeout > 0 {
|
||||||
|
var cancel context.CancelFunc
|
||||||
|
actionCtx, cancel = context.WithTimeout(ctx, time.Duration(options.Timeout)*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute the tool call with timeout
|
||||||
|
if err := dExt.invokeToolCall(actionCtx, toolCall, opts...); err != nil {
|
||||||
|
// Check if the error is due to timeout
|
||||||
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
|
log.Warn().
|
||||||
|
Str("action", toolCall.Function.Name).
|
||||||
|
Int("timeout_seconds", options.Timeout).
|
||||||
|
Msg("action timeout exceeded, continuing to next action")
|
||||||
|
subActionResult.Error = errors.New("action timeout exceeded")
|
||||||
|
return nil // Continue to next action instead of failing the entire StartToGoal
|
||||||
|
}
|
||||||
subActionResult.Error = err
|
subActionResult.Error = err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user