{"record":{"id":"d96d204f0473a83f","repo":"github/copilot-sdk","slug":"no-user-input-handler-registered-d96d20","errorCode":null,"errorMessage":"no user input handler registered","messagePattern":"no user input handler registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/session.go","lineNumber":673,"sourceCode":"\ts.userInputMux.Lock()\n\tdefer s.userInputMux.Unlock()\n\ts.userInputHandler = handler\n}\n\n// getUserInputHandler returns the currently registered user input handler, or nil.\nfunc (s *Session) getUserInputHandler() UserInputHandler {\n\ts.userInputMux.RLock()\n\tdefer s.userInputMux.RUnlock()\n\treturn s.userInputHandler\n}\n\n// handleUserInputRequest handles a user input request from the Copilot CLI.\n// This is an internal method called by the SDK when the CLI requests user input.\nfunc (s *Session) handleUserInputRequest(request UserInputRequest) (UserInputResponse, error) {\n\thandler := s.getUserInputHandler()\n\n\tif handler == nil {\n\t\treturn UserInputResponse{}, fmt.Errorf(\"no user input handler registered\")\n\t}\n\n\tinvocation := UserInputInvocation{\n\t\tSessionID: s.SessionID,\n\t}\n\n\treturn handler(request, invocation)\n}\n\nfunc (s *Session) registerExitPlanModeHandler(handler ExitPlanModeRequestHandler) {\n\ts.exitPlanModeMu.Lock()\n\tdefer s.exitPlanModeMu.Unlock()\n\ts.exitPlanModeHandler = handler\n}\n\nfunc (s *Session) getExitPlanModeHandler() ExitPlanModeRequestHandler {\n\ts.exitPlanModeMu.RLock()\n\tdefer s.exitPlanModeMu.RUnlock()","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/go/session.go#L655-L691","documentation":"handleUserInputRequest is invoked when the Copilot CLI asks the client for user input (e.g. a tool needs an interactive answer). If no handler was registered on the session via SetUserInputHandler (or the equivalent option), the SDK cannot answer the request and returns this error immediately. The error is returned to the CLI as the handler result, failing the pending operation.","triggerScenarios":"The CLI emits a user-input request during a turn (e.g. an interactive tool or clarification prompt) while Session has no user input handler registered.","commonSituations":"Running a session programmatically without registering OnUserInput/SetUserInputHandler while the model invokes an interactive tool; CLI version update introducing interactive prompts; headless/CI usage where a prompt is requested but never wired up.","solutions":["Register a user input handler before sending prompts (SetUserInputHandler or the session option) that returns a UserInputResponse.","If interactive prompts are undesired, use a non-interactive configuration or tool allowlist so the CLI never requests input.","Upgrade the SDK/CLI pair if a new prompt type appeared that your registration path doesn't cover."],"exampleFix":"// before\nsession, _ := client.CreateSession(ctx, nil)\nsession.SendPromptAndWait(ctx, prompt)\n// after\nsession, _ := client.CreateSession(ctx, nil)\nsession.SetUserInputHandler(func(req copilot.UserInputRequest) (copilot.UserInputResponse, error) {\n    return copilot.UserInputResponse{Answer: \"yes\"}, nil\n})\nsession.SendPromptAndWait(ctx, prompt)","handlingStrategy":"validation","validationCode":"if session.GetUserInputHandler() == nil {\n    session.SetUserInputHandler(func(req copilot.UserInputRequest) (copilot.UserInputResponse, error) {\n        return copilot.UserInputResponse{Answer: \"\"}, nil\n    })\n}","typeGuard":null,"tryCatchPattern":"resp, err := session.SendPromptAndWait(ctx, prompt)\nif err != nil && strings.Contains(err.Error(), \"no user input handler registered\") {\n    // register a handler and retry\n}","preventionTips":["Always register a user input handler when creating interactive-capable sessions","Use non-interactive tool configuration in headless/CI environments","Wrap handler registration into your session factory helper so it's never forgotten"],"tags":["session","handler","configuration"],"backgroundTag":"missing-required-config","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}