Can you run B with timeout tB and A with timeout tA, where tA is greater tB? If tB times out, you cancel job/deferred A. If tB doesn't time out, then A will continue to run until tA times out.
If you want to time out A after a time depending on the response from B, then you could run B with timeout tB and run A without timeout. Then if B times out, you cancel A. If B returns, then you start a new coroutine with a delay for the remainder of time, after which A is cancelled. If A completes before this cancellation, then nothing happens.