microsoft/semantic-kernel · error · TimeoutException

Orchestration did not complete within the allowed duration (

Error message

Orchestration did not complete within the allowed duration ({timeout}).

What it means

Thrown by GetValueAsync when a timeout is supplied and the orchestration does not complete within it. On .NET the method awaits _completion.Task.WaitAsync(timeout) which surfaces a TimeoutException; on other targets it races the completion task against Task.Delay and explicitly throws TimeoutException when the delay wins. This means the orchestration's agents did not all finish (or did not produce the result) in time.

Source

Thrown at dotnet/src/Agents/Orchestration/OrchestrationResult.cs:91

        if (timeout.HasValue)
        {
#if NET
            try
            {
                await this._completion.Task.WaitAsync(timeout.Value, cancellationToken).ConfigureAwait(false);
            }
            catch (TimeoutException)
            {
                this._logger.LogOrchestrationResultTimeout(this.Orchestration, this.Topic);
                throw;
            }
#else
            Task completedTask = await Task.WhenAny(this._completion.Task, Task.Delay(timeout.Value, cancellationToken)).ConfigureAwait(false);
            if (completedTask != this._completion.Task)
            {
                this._logger.LogOrchestrationResultTimeout(this.Orchestration, this.Topic);
                throw new TimeoutException($"Orchestration did not complete within the allowed duration ({timeout}).");
            }
#endif
        }

        this._logger.LogOrchestrationResultComplete(this.Orchestration, this.Topic);

        return await this._completion.Task.ConfigureAwait(false);
    }

    /// <summary>
    /// Cancel the orchestration associated with this result.
    /// </summary>
    /// <exception cref="ObjectDisposedException">Thrown if this instance has been disposed.</exception>
    /// <remarks>
    /// Cancellation is not expected to immediately halt the orchestration.  Messages that
    /// are already in-flight may still be processed.
    /// </remarks>
    public void Cancel()

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Increase the timeout to fit realistic model latency.
  2. Investigate why the orchestration did not complete: check agent logs, ensure every agent returns, ensure the terminal result is published.
  3. Catch TimeoutException and either retry with a larger budget or cancel via result.Cancel().

Example fix

// before
var value = await result.GetValueAsync(TimeSpan.FromSeconds(15)); // throws if slow

// after — size the budget to real latency and handle the timeout
try
{
    var value = await result.GetValueAsync(TimeSpan.FromMinutes(2));
}
catch (TimeoutException)
{
    result.Cancel();
    logger.LogWarning("orchestration timed out");
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Size the timeout to realistic model latency before invoking
var budget = TimeSpan.FromMinutes(2);
var value = await result.GetValueAsync(budget);

Try / catch

try
{
    var value = await result.GetValueAsync(TimeSpan.FromMinutes(2));
}
catch (TimeoutException)
{
    result.Cancel();
    logger.LogWarning("Orchestration did not complete within the timeout.");
}

Prevention

When it happens

Trigger: await result.GetValueAsync(TimeSpan.FromSeconds(30)) where the orchestration takes longer than 30s — slow model calls, a hung agent, a missing result publication, or simply an undersized timeout.

Common situations: Long-running model generations exceeding the budget; an agent error that prevents the result task from completing; a manager/actor that never publishes the final message; overly tight timeout in tests.

Understand the failure class

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/887341726887f805. Report an issue: GitHub.