microsoft/autogen · error · ValueError
Recorded call type mismatch at index {self._record_index}: e
Error message
Recorded call type mismatch at index {self._record_index}: expected 'create', got '{rec.get('mode')}'. What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/chat_completion_client_recorder.py:123
rec: RecordDict = {
"mode": "create",
"messages": current_messages,
"response": response.model_dump(),
"stream": [],
}
self.records.append(rec)
return response
elif self.mode == "replay":
if self._record_index >= len(self.records):
error_str = "\nNo more recorded turns to check."
self.logger.error(error_str)
raise ValueError(error_str)
rec = self.records[self._record_index]
if rec.get("mode") != "create":
error_str = f"\nRecorded call type mismatch at index {self._record_index}: expected 'create', got '{rec.get('mode')}'."
self.logger.error(error_str)
raise ValueError(error_str)
recorded_messages = rec.get("messages")
if recorded_messages != current_messages:
error_str = (
"\nCurrent message list doesn't match the recorded message list. See the pagelogs for details."
)
assert recorded_messages is not None
self.logger.log_dict_list(recorded_messages, "recorded message list")
assert current_messages is not None
self.logger.log_dict_list(current_messages, "current message list")
self.logger.error(error_str)
raise ValueError(error_str)
self._record_index += 1
self._num_checked_records += 1
data = rec.get("response")
# Populate a CreateResult from the data.
assert data is not None
result = CreateResult(View on GitHub (pinned to 027ecf0a37)
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).
Example fix
# before # session recorded with streaming agent, replayed with non-streaming call: resp = await client.create(messages) # ValueError: ... expected 'create', got 'create_stream' # after # re-record using the same call style you will replay, e.g. streaming: stream = await client.create_stream(messages) # or regenerate the session via mode="record"
Defensive patterns
Strategy: try-catch
Validate before calling
import json
from pathlib import Path
def next_record_mode(session_file: str, index: int) -> str | None:
records = json.loads(Path(session_file).read_text())
return records[index]["mode"] if index < len(records) else None
# before calling create(): assert next_record_mode(p, idx) == "create" Try / catch
try:
await client.create(messages)
except ValueError as e:
if "call type mismatch" in str(e):
pytest.fail("Streaming usage differs from recording - re-record or use create_stream")
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to load recorded session: '{self.session_file_path}':
- No more recorded turns to check.
- Current message list doesn't match the recorded message list
- Early termination. Only {self._num_checked_records} of the
- No more mock responses available
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/051095f579b87d77.
Report an issue: GitHub.