rohitg00/ai-engineering-from-scratch · error · RuntimeError
expected input_required result
Error message
expected input_required result
What it means
Raised in call_with_mrtr when the first server's tools/call reply lacks resultType == 'input_required'. The MRTR flow depends on the first instance pausing for more input; any other result (success, error, wrong stop reason) means the flow cannot continue to the retry-server stage.
Solutions
- Verify the first MCPServer is configured to return an input_required elicit result for the tool being called
- Check the tool's halt-on-input configuration so it stops and returns requestState instead of completing
- Ensure the response parsing preserves resultType rather than stripping it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at certifications/claude/lessons/11-mcp-server-design-and-integration/code/main.py:551 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/0af9ec5430924b3c.
Report an issue: GitHub.
Appendix: source
Thrown at certifications/claude/lessons/11-mcp-server-design-and-integration/code/main.py:551
params: dict[str, Any] | None = None,
*,
server: MCPServer | None = None,
) -> dict[str, Any]:
_request, result = self.send(method, params, server=server)
return result
def call_with_mrtr(
self,
params: dict[str, Any],
*,
first_server: MCPServer,
retry_server: MCPServer,
) -> dict[str, Any]:
first_request, input_required = self.send(
"tools/call", params, server=first_server
)
if input_required.get("resultType") != "input_required":
raise RuntimeError("expected input_required result")
responses = self.fulfill(input_required["inputRequests"])
retry_params = {
**params,
"inputResponses": responses,
"requestState": input_required["requestState"],
}
retry_request, complete = self.send(
"tools/call", retry_params, server=retry_server
)
return {
"initialRequestId": first_request["id"],
"retryRequestId": retry_request["id"],
"inputRequired": input_required,
"complete": complete,
}
@staticmethod
def fulfill(input_requests: dict[str, Any]) -> dict[str, Any]:View on GitHub (pinned to 39ea8a1c6d)