{"record":{"id":"142685dd5dc7cb86","repo":"fishaudio/fish-speech","slug":"expected-generateresponse-got-type-wrapped-resul","errorCode":null,"errorMessage":"Expected GenerateResponse, got {type(wrapped_result.response).__name__}","messagePattern":"Expected GenerateResponse, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"critical","filePath":"fish_speech/inference_engine/__init__.py","lineNumber":103,"sourceCode":"\n        while True:\n            # Get the response from the LLAMA model\n            wrapped_result: WrappedGenerateResponse = response_queue.get()\n            if wrapped_result.status == \"error\":\n                yield InferenceResult(\n                    code=\"error\",\n                    audio=None,\n                    error=(\n                        wrapped_result.response\n                        if isinstance(wrapped_result.response, Exception)\n                        else Exception(\"Unknown error\")\n                    ),\n                )\n                break\n\n            # Check the response type\n            if not isinstance(wrapped_result.response, GenerateResponse):\n                raise TypeError(\n                    f\"Expected GenerateResponse, got {type(wrapped_result.response).__name__}\"\n                )\n\n            result: GenerateResponse = wrapped_result.response\n            if result.action != \"next\":\n                segment = self.get_audio_segment(result)\n\n                if req.streaming:  # Used only by the API server\n                    yield InferenceResult(\n                        code=\"segment\",\n                        audio=(sample_rate, segment),\n                        error=None,\n                    )\n                segments.append(segment)\n            else:\n                break\n\n        # Clean up the memory","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/fish_speech/inference_engine/__init__.py#L85-L121","documentation":"InferenceEngine.inference wraps the underlying model's streaming responses and asserts each response is a GenerateResponse instance; any other type coming through the response channel is treated as a protocol violation between the engine layers and raises a TypeError.","triggerScenarios":"Calling engine.inference()/inference_async()/tts()/warm_up() when the wrapped backend (model server or local model) yields a response object of an unexpected type — e.g. after a version mismatch where the backend returns a raw dataclass/dict instead of GenerateResponse.","commonSituations":"Mixing incompatible versions of fish-speech client and server (schema drift in the RPC/message protocol), a mocked or custom backend not returning the expected class, or deserialization producing a different class with the same shape.","solutions":["Pin/align client and server to the same fish-speech version (reinstall both sides)","If using a custom or mocked backend, make it return GenerateResponse instances exactly","Update the code — this check exists precisely to catch protocol drift, so don't suppress it; fix the source of the wrong type"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from fish_speech import GenerateResponse  # adjust import to actual module\nresp = engine.inference(...)\n# pre-check versions before inferring\nimport fish_speech\nassert fish_speech.__version__ == SERVER_VERSION","typeGuard":"from fish_speech import GenerateResponse\n\ndef is_generate_response(r) -> bool:\n    return isinstance(r, GenerateResponse)","tryCatchPattern":"try:\n    for chunk in engine.inference(req):\n        ...\nexcept TypeError as e:\n    if \"Expected GenerateResponse\" in str(e):\n        raise RuntimeError(\"client/server version mismatch — align fish-speech versions\") from e\n    raise","preventionTips":["Pin identical fish-speech versions on client and server","Add a version/protocol handshake at connection setup","Don't mock backends with plain dicts; return real GenerateResponse objects"],"tags":["protocol-mismatch","version-mismatch","inference","python"],"backgroundTag":"api-version-mismatch","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}