{"record":{"id":"729896822ce0262b","repo":"github/copilot-sdk","slug":"elicitation-is-not-supported-by-the-host-check-se-729896","errorCode":null,"errorMessage":"Elicitation is not supported by the host. Check session.Capabilities.Ui?.Elicitation before calling UI methods.","messagePattern":"Elicitation is not supported by the host\\. Check session\\.Capabilities\\.Ui\\?\\.Elicitation before calling UI methods\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Session.cs","lineNumber":1532,"sourceCode":"                {\n                    Action = UIElicitationResponseAction.Cancel\n                });\n            }\n            catch (Exception innerEx) when (innerEx is IOException or ObjectDisposedException)\n            {\n                // Connection lost — nothing we can do\n            }\n        }\n    }\n\n    /// <summary>\n    /// Throws if the host does not support elicitation.\n    /// </summary>\n    private void AssertElicitation()\n    {\n        if (Capabilities.Ui?.Elicitation != true)\n        {\n            throw new InvalidOperationException(\n                \"Elicitation is not supported by the host. \" +\n                \"Check session.Capabilities.Ui?.Elicitation before calling UI methods.\");\n        }\n    }\n\n    /// <summary>\n    /// Implements <see cref=\"ISessionUiApi\"/> backed by the session's RPC connection.\n    /// </summary>\n    private sealed class SessionUiApiImpl(CopilotSession session) : ISessionUiApi\n    {\n        // Parses a JSON string and returns a detached JsonElement. Using `using`\n        // ensures the pooled buffers backing the JsonDocument are released\n        // promptly; the cloned RootElement is independent of the document.\n        private static JsonElement ParseJsonElement(string json)\n        {\n            using var doc = JsonDocument.Parse(json);\n            return doc.RootElement.Clone();\n        }","sourceCodeStart":1514,"sourceCodeEnd":1550,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/dotnet/src/Session.cs#L1514-L1550","documentation":"AssertElicitation is a precondition check: it throws InvalidOperationException when the host did not advertise UI elicitation capability (Capabilities.Ui?.Elicitation != true) but an elicitation API (showing input dialogs to the user) was called. The message points you to verify the capability flag first.","triggerScenarios":"Calling session UI elicitation methods (e.g. RequestInput/ShowForm style APIs) against a host — CLI, CI runner, IDE — whose capabilities response lacks ui.elicitation or sets it false.","commonSituations":"Running a Copilot SDK app inside headless/CI environments; older CLI versions without elicitation support; embedding the session in a custom host that never declares the Ui capability.","solutions":["Check session.Capabilities.Ui?.Elicitation == true before calling any elicitation API.","Fall back to a non-UI flow (CLI prompts, defaults, or config values) when elicitation is unsupported.","Upgrade the host/CLI to a version that supports elicitation.","If you control the host, declare the ui.elicitation capability in its initialize response."],"exampleFix":"// before\nvar answer = await session.Ui.RequestInputAsync(new() { Message = \"Name?\" });\n\n// after\nif (session.Capabilities.Ui?.Elicitation == true)\n    var answer = await session.Ui.RequestInputAsync(new() { Message = \"Name?\" });\nelse\n    var answer = PromptFallback(\"Name?\");","handlingStrategy":"type-guard","validationCode":"if (session.Capabilities.Ui?.Elicitation != true)\n    return await FallbackPromptAsync(message);","typeGuard":"static bool SupportsElicitation(Session s) => s.Capabilities?.Ui?.Elicitation == true;","tryCatchPattern":"try { return await session.Ui.RequestInputAsync(req); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Elicitation is not supported\"))\n{ return await FallbackPromptAsync(req.Message); }","preventionTips":["Check Capabilities.Ui?.Elicitation before every elicitation call","Design non-UI fallbacks for headless/CI environments","Upgrade the host/CLI if elicitation support is required"],"tags":["capability","elicitation","unsupported-operation","dotnet"],"backgroundTag":"feature-not-enabled","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}