{"record":{"id":"887341726887f805","repo":"microsoft/semantic-kernel","slug":"orchestration-did-not-complete-within-the-allowed","errorCode":null,"errorMessage":"Orchestration did not complete within the allowed duration ({timeout}).","messagePattern":"Orchestration did not complete within the allowed duration \\((.+?)\\)\\.","errorType":"exception","errorClass":"TimeoutException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Agents/Orchestration/OrchestrationResult.cs","lineNumber":91,"sourceCode":"\n        if (timeout.HasValue)\n        {\n#if NET\n            try\n            {\n                await this._completion.Task.WaitAsync(timeout.Value, cancellationToken).ConfigureAwait(false);\n            }\n            catch (TimeoutException)\n            {\n                this._logger.LogOrchestrationResultTimeout(this.Orchestration, this.Topic);\n                throw;\n            }\n#else\n            Task completedTask = await Task.WhenAny(this._completion.Task, Task.Delay(timeout.Value, cancellationToken)).ConfigureAwait(false);\n            if (completedTask != this._completion.Task)\n            {\n                this._logger.LogOrchestrationResultTimeout(this.Orchestration, this.Topic);\n                throw new TimeoutException($\"Orchestration did not complete within the allowed duration ({timeout}).\");\n            }\n#endif\n        }\n\n        this._logger.LogOrchestrationResultComplete(this.Orchestration, this.Topic);\n\n        return await this._completion.Task.ConfigureAwait(false);\n    }\n\n    /// <summary>\n    /// Cancel the orchestration associated with this result.\n    /// </summary>\n    /// <exception cref=\"ObjectDisposedException\">Thrown if this instance has been disposed.</exception>\n    /// <remarks>\n    /// Cancellation is not expected to immediately halt the orchestration.  Messages that\n    /// are already in-flight may still be processed.\n    /// </remarks>\n    public void Cancel()","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Agents/Orchestration/OrchestrationResult.cs#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Increase the timeout to fit realistic model latency.","Investigate why the orchestration did not complete: check agent logs, ensure every agent returns, ensure the terminal result is published.","Catch TimeoutException and either retry with a larger budget or cancel via result.Cancel()."],"exampleFix":"// before\nvar value = await result.GetValueAsync(TimeSpan.FromSeconds(15)); // throws if slow\n\n// after — size the budget to real latency and handle the timeout\ntry\n{\n    var value = await result.GetValueAsync(TimeSpan.FromMinutes(2));\n}\ncatch (TimeoutException)\n{\n    result.Cancel();\n    logger.LogWarning(\"orchestration timed out\");\n}","handlingStrategy":"try-catch","validationCode":"// Size the timeout to realistic model latency before invoking\nvar budget = TimeSpan.FromMinutes(2);\nvar value = await result.GetValueAsync(budget);","typeGuard":null,"tryCatchPattern":"try\n{\n    var value = await result.GetValueAsync(TimeSpan.FromMinutes(2));\n}\ncatch (TimeoutException)\n{\n    result.Cancel();\n    logger.LogWarning(\"Orchestration did not complete within the timeout.\");\n}","preventionTips":["Set the timeout above expected model/agent latency (including function-call rounds).","Verify every agent publishes its result so the completion task is set.","Catch TimeoutException to cancel cleanly and log diagnostics."],"tags":["orchestration","timeout","async","agents","configuration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}