{"record":{"id":"2185858268e35d5a","repo":"microsoft/autogen","slug":"no-more-mock-responses-available","errorCode":null,"errorMessage":"No more mock responses available","messagePattern":"No more mock responses available","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/replay/_replay_chat_completion_client.py","lineNumber":176,"sourceCode":"        return self._create_calls\n\n    async def create(\n        self,\n        messages: Sequence[LLMMessage],\n        *,\n        tools: Sequence[Tool | ToolSchema] = [],\n        tool_choice: Tool | Literal[\"auto\", \"required\", \"none\"] = \"auto\",\n        json_output: Optional[bool | type[BaseModel]] = None,\n        extra_create_args: Mapping[str, Any] = {},\n        cancellation_token: Optional[CancellationToken] = None,\n    ) -> CreateResult:\n        \"\"\"Return the next completion from the list.\"\"\"\n        # Warn if tool_choice is specified since it's ignored in replay mode\n        if tool_choice != \"auto\":\n            logger.warning(\"tool_choice parameter specified but is ignored in replay mode\")\n\n        if self._current_index >= len(self.chat_completions):\n            raise ValueError(\"No more mock responses available\")\n\n        response = self.chat_completions[self._current_index]\n        _, prompt_token_count = self._tokenize(messages)\n        if isinstance(response, str):\n            _, output_token_count = self._tokenize(response)\n            self._cur_usage = RequestUsage(prompt_tokens=prompt_token_count, completion_tokens=output_token_count)\n            response = CreateResult(\n                finish_reason=\"stop\", content=response, usage=self._cur_usage, cached=self._cached_bool_value\n            )\n        else:\n            self._cur_usage = RequestUsage(\n                prompt_tokens=prompt_token_count, completion_tokens=response.usage.completion_tokens\n            )\n\n        self._update_total_usage()\n        self._current_index += 1\n        self._create_calls.append(\n            {","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/replay/_replay_chat_completion_client.py#L158-L194","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nreplay = ReplayChatCompletionClient([\"Hello\", \"How can I help?\"])\n# agent loop runs 3 LLM calls -> third raises\n\n# after\nreplay = ReplayChatCompletionClient([\"Hello\", \"How can I help?\", \"Anything else?\"])\n# or: await agent.run(task, max_turns=2)","handlingStrategy":"validation","validationCode":"class CountingReplayClient(ReplayChatCompletionClient):\n    def remaining(self) -> int:\n        return len(self.chat_completions) - self._current_index\n\n# before each agent run:\nassert replay.remaining() >= expected_llm_calls, f\"scripted responses exhausted: {replay.remaining()}\"","typeGuard":"def replay_has_responses(replay: ReplayChatCompletionClient, needed: int = 1) -> bool:\n    return replay._current_index + needed <= len(replay.chat_completions)","tryCatchPattern":"try:\n    result = await replay.create(messages)\nexcept ValueError as e:\n    if \"No more mock responses\" in str(e):\n        pytest.fail(\"replay buffer too small: add scripted completions or lower max_turns\")\n    raise","preventionTips":["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"],"tags":["replay","testing","mock","fixture-exhaustion"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}