diff --git a/llama_stack/testing/api_recorder.py b/llama_stack/testing/api_recorder.py index 8964a28d2..b0d68fd8a 100644 --- a/llama_stack/testing/api_recorder.py +++ b/llama_stack/testing/api_recorder.py @@ -556,9 +556,9 @@ async def _patched_tool_invoke_method( return recording["response"]["body"] elif _current_mode == APIRecordingMode.REPLAY: raise RuntimeError( - f"No recorded tool result found for {provider_name}.{tool_name}\n" - f"Request: {kwargs}\n" - f"To record this response, run with LLAMA_STACK_TEST_INFERENCE_MODE=record" + f"Recording not found for {provider_name}.{tool_name} | Request: {kwargs}\n" + f"\n" + f"Run './scripts/integration-tests.sh --inference-mode record-if-missing' with required API keys to generate." ) # If RECORD_IF_MISSING and no recording found, fall through to record @@ -644,10 +644,10 @@ async def _patched_inference_method(original_method, self, client_type, endpoint elif mode == APIRecordingMode.REPLAY: # REPLAY mode requires recording to exist raise RuntimeError( - f"No recorded response found for request hash: {request_hash}\n" - f"Request: {method} {url} {body}\n" - f"Model: {body.get('model', 'unknown')}\n" - f"To record this response, run with LLAMA_STACK_TEST_INFERENCE_MODE=record" + f"Recording not found for request hash: {request_hash}\n" + f"Model: {body.get('model', 'unknown')} | Request: {method} {url}\n" + f"\n" + f"Run './scripts/integration-tests.sh --inference-mode record-if-missing' with required API keys to generate." ) if mode == APIRecordingMode.RECORD or (mode == APIRecordingMode.RECORD_IF_MISSING and not recording): diff --git a/tests/unit/distribution/test_api_recordings.py b/tests/unit/distribution/test_api_recordings.py index 2208ac506..2b7ce5c4e 100644 --- a/tests/unit/distribution/test_api_recordings.py +++ b/tests/unit/distribution/test_api_recordings.py @@ -261,7 +261,7 @@ class TestInferenceRecording: with api_recording(mode=APIRecordingMode.REPLAY, storage_dir=str(temp_storage_dir)): client = AsyncOpenAI(base_url="http://localhost:11434/v1", api_key="test") - with pytest.raises(RuntimeError, match="No recorded response found"): + with pytest.raises(RuntimeError, match="Recording not found"): await client.chat.completions.create( model="llama3.2:3b", messages=[{"role": "user", "content": "This was never recorded"}] )