{"record":{"id":"051095f579b87d77","repo":"microsoft/autogen","slug":"recorded-call-type-mismatch-at-index-self-record","errorCode":null,"errorMessage":"Recorded call type mismatch at index {self._record_index}: expected 'create', got '{rec.get('mode')}'.","messagePattern":"Recorded call type mismatch at index (.+?): expected 'create', got '(.+?)'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/chat_completion_client_recorder.py","lineNumber":123,"sourceCode":"\n            rec: RecordDict = {\n                \"mode\": \"create\",\n                \"messages\": current_messages,\n                \"response\": response.model_dump(),\n                \"stream\": [],\n            }\n            self.records.append(rec)\n            return response\n        elif self.mode == \"replay\":\n            if self._record_index >= len(self.records):\n                error_str = \"\\nNo more recorded turns to check.\"\n                self.logger.error(error_str)\n                raise ValueError(error_str)\n            rec = self.records[self._record_index]\n            if rec.get(\"mode\") != \"create\":\n                error_str = f\"\\nRecorded call type mismatch at index {self._record_index}: expected 'create', got '{rec.get('mode')}'.\"\n                self.logger.error(error_str)\n                raise ValueError(error_str)\n            recorded_messages = rec.get(\"messages\")\n            if recorded_messages != current_messages:\n                error_str = (\n                    \"\\nCurrent message list doesn't match the recorded message list. See the pagelogs for details.\"\n                )\n                assert recorded_messages is not None\n                self.logger.log_dict_list(recorded_messages, \"recorded message list\")\n                assert current_messages is not None\n                self.logger.log_dict_list(current_messages, \"current message list\")\n                self.logger.error(error_str)\n                raise ValueError(error_str)\n            self._record_index += 1\n            self._num_checked_records += 1\n\n            data = rec.get(\"response\")\n            # Populate a CreateResult from the data.\n            assert data is not None\n            result = CreateResult(","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/chat_completion_client_recorder.py#L105-L141","documentation":"Raised in replay mode when the record at the current index is not a 'create' record - typically because the current call is create() but the next recorded entry is 'create_stream'. The recorder requires the exact same sequence of call modes as recorded.","triggerScenarios":"The recorded session captured streaming calls (create_stream) but the replayed code now calls non-streaming create(), or an extra/missing call shifted the index so a stream record is read where a create record was expected.","commonSituations":"Switching a component between streaming and non-streaming usage after recording (changed agent config or model client settings), divergence earlier in the run misaligning indices, library version differences in default streaming behavior.","solutions":["If streaming usage changed, re-record the session with the current code path so modes align.","Inspect the session JSON at the reported index to see which mode was recorded and compare with the failing call; fix the divergence (usually an earlier extra or missing call).","Keep streaming settings identical between record and replay runs (same agents, same client wrappers)."],"exampleFix":"# before\n# session recorded with streaming agent, replayed with non-streaming call:\nresp = await client.create(messages)  # ValueError: ... expected 'create', got 'create_stream'\n\n# after\n# re-record using the same call style you will replay, e.g. streaming:\nstream = await client.create_stream(messages)  # or regenerate the session via mode=\"record\"","handlingStrategy":"try-catch","validationCode":"import json\nfrom pathlib import Path\n\ndef next_record_mode(session_file: str, index: int) -> str | None:\n    records = json.loads(Path(session_file).read_text())\n    return records[index][\"mode\"] if index < len(records) else None\n\n# before calling create(): assert next_record_mode(p, idx) == \"create\"","typeGuard":null,"tryCatchPattern":"try:\n    await client.create(messages)\nexcept ValueError as e:\n    if \"call type mismatch\" in str(e):\n        pytest.fail(\"Streaming usage differs from recording - re-record or use create_stream\")\n    raise","preventionTips":["Keep streaming configuration identical between record and replay runs.","Re-record after changing any model-client wrapper that switches streaming on/off.","Fix earlier divergences first - an index shift anywhere misaligns all later modes."],"tags":["replay","streaming","testing","sequence-mismatch"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}