microsoft/autogen · error · ValueError
No more mock responses available
Error message
No more mock responses available
What it means
Thrown by ReplayChatCompletionClient.create when the replay buffer is exhausted: _current_index has advanced past the last entry in chat_completions. The replay client is a test double that returns pre-recorded responses in order; once consumed, there is nothing left to return and it raises rather than fabricating output.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/replay/_replay_chat_completion_client.py:176
return self._create_calls
async def create(
self,
messages: Sequence[LLMMessage],
*,
tools: Sequence[Tool | ToolSchema] = [],
tool_choice: Tool | Literal["auto", "required", "none"] = "auto",
json_output: Optional[bool | type[BaseModel]] = None,
extra_create_args: Mapping[str, Any] = {},
cancellation_token: Optional[CancellationToken] = None,
) -> CreateResult:
"""Return the next completion from the list."""
# Warn if tool_choice is specified since it's ignored in replay mode
if tool_choice != "auto":
logger.warning("tool_choice parameter specified but is ignored in replay mode")
if self._current_index >= len(self.chat_completions):
raise ValueError("No more mock responses available")
response = self.chat_completions[self._current_index]
_, prompt_token_count = self._tokenize(messages)
if isinstance(response, str):
_, output_token_count = self._tokenize(response)
self._cur_usage = RequestUsage(prompt_tokens=prompt_token_count, completion_tokens=output_token_count)
response = CreateResult(
finish_reason="stop", content=response, usage=self._cur_usage, cached=self._cached_bool_value
)
else:
self._cur_usage = RequestUsage(
prompt_tokens=prompt_token_count, completion_tokens=response.usage.completion_tokens
)
self._update_total_usage()
self._current_index += 1
self._create_calls.append(
{View on GitHub (pinned to 027ecf0a37)
Solutions
- Add more recorded responses to chat_completions covering every expected turn, including tool-call rounds
- Reduce the loop: set max_turns on the agent so it stops within the scripted budget
- Create a fresh ReplayChatCompletionClient per test (or reset _current_index) so state does not leak between cases
Example fix
# before replay = ReplayChatCompletionClient(["Hello", "How can I help?"]) # agent loop runs 3 LLM calls -> third raises # after replay = ReplayChatCompletionClient(["Hello", "How can I help?", "Anything else?"]) # or: await agent.run(task, max_turns=2)
Defensive patterns
Strategy: validation
Validate before calling
class CountingReplayClient(ReplayChatCompletionClient):
def remaining(self) -> int:
return len(self.chat_completions) - self._current_index
# before each agent run:
assert replay.remaining() >= expected_llm_calls, f"scripted responses exhausted: {replay.remaining()}" Type guard
def replay_has_responses(replay: ReplayChatCompletionClient, needed: int = 1) -> bool:
return replay._current_index + needed <= len(replay.chat_completions) Try / catch
try:
result = await replay.create(messages)
except ValueError as e:
if "No more mock responses" in str(e):
pytest.fail("replay buffer too small: add scripted completions or lower max_turns")
raise Prevention
- Count every LLM round-trip (including tool-call responses) when sizing the replay list
- Set max_turns on agents under test to bound consumption
- Build a fresh ReplayChatCompletionClient per test to avoid index bleed
When it happens
Trigger: Calling create (or letting an agent loop call it) more times than there are recorded completions passed to the constructor. Each create call consumes exactly one entry and increments _current_index.
Common situations: Agent loops in tests that iterate more turns than scripted (a tool-call round-trip adds an extra completion); sharing one replay client across multiple test cases without resetting; forgetting that every create counts, including intermediate tool-call responses.
Related errors
- Failed to load recorded session: '{self.session_file_path}':
- No more recorded turns to check.
- Recorded call type mismatch at index {self._record_index}: e
- Current message list doesn't match the recorded message list
- Early termination. Only {self._num_checked_records} of the
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/2185858268e35d5a.
Report an issue: GitHub.