Catalysis of the reaction: tryptophan + O2 = N-formylkynurenine. The product of the reaction depends on the substrate; D-tryptophan produces N-formyl-D-kynurenine, and L-tryptophan produces N-formyl-L-kynurenine.
D-tryptophan:oxygen 2,3-oxidoreductase (decyclizing) activity