github/copilot-sdk · error · RuntimeError
User input requested but no handler registered
Error message
User input requested but no handler registered
What it means
Raised by CopilotSession's user-input request dispatcher in python/copilot/session.py when the host sends a user-input request but no user-input handler was registered on the session (self._user_input_handler is None). The SDK cannot prompt the user, so it fails the request immediately with a RuntimeError.
Solutions
- Register a user-input handler on the session (the callback receiving UserInputRequest) before sending any prompt.
- Re-register the handler after resume_session — registrations are per-session and not persisted.
- If prompting is impossible in your environment, configure the session/agent to run without user questions (e.g. non-interactive mode) so no user-input request is issued.
- Inspect the request's question field in your handler and return a structured response dict; wrap handler code in try/except so handler bugs don't masquerade as missing-handler errors.
Example fix
# before
session = await client.create_session()
await session.send_and_wait("Deploy to prod?") # RuntimeError: no user-input handler
# after
session = await client.create_session()
session.register_user_input_handler(lambda req: {"answer": input(req.question)})
await session.send_and_wait("Deploy to prod?") Defensive patterns
Strategy: validation
Validate before calling
if getattr(session, "_user_input_handler", None) is None:
raise ValueError("register a user-input handler before sending prompts that may ask questions") Type guard
def has_user_input_handler(session) -> bool:
return callable(getattr(session, "_user_input_handler", None)) Try / catch
try:
message = await session.send_and_wait(prompt)
except RuntimeError as e:
if "no handler registered" in str(e):
session.register_user_input_handler(default_console_handler)
message = await session.send_and_wait(prompt)
else:
raise Prevention
- Register the user-input handler immediately after session creation, before any send.
- Re-register handlers after resume_session.
- Never pass None to clear the handler while the agent can still emit user-input requests.
- In non-interactive environments, configure the agent to avoid user questions instead of leaving the handler unset.
When it happens
Trigger: The agent issues a user-input request during a turn while the application never called the session's register/set user-input handler (or explicitly cleared it by passing None).
Common situations: Headless/embedded integrations that don't wire a user-input callback; registering handlers after the first prompt already triggered a request; accidentally passing None to clear handlers while the agent still asks questions.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- User input requested but no handler registered
- no user input handler registered
- No session found for sessionId
- Session not found
- canvas_action_no_handler
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/8a811b91d43092fb.
Report an issue: GitHub.
Appendix: source
Thrown at python/copilot/session.py:2829
async def _handle_user_input_request(self, request: dict) -> UserInputResponse:
"""
Handle a user input request from the Copilot CLI.
Note:
This method is internal and should not be called directly.
Args:
request: The user input request data from the CLI.
Returns:
A dictionary containing the user's response.
"""
with self._user_input_handler_lock:
handler = self._user_input_handler
if not handler:
raise RuntimeError("User input requested but no handler registered")
try:
handler_start = time.perf_counter()
result = handler(
UserInputRequest(
question=request.get("question", ""),
choices=request.get("choices") or [],
allowFreeform=request.get("allowFreeform", True),
),
{"session_id": self.session_id},
)
if inspect.isawaitable(result):
result = await result
log_timing(
logger,
logging.DEBUG,
"CopilotSession._handle_user_input_request dispatch",
handler_start,View on GitHub (pinned to cd8cf15dc3)