There was this small issue I was running into when trying to move a Semantic Kernel (SK) demo application from an older version to the most recent version 0.16.230615.1-preview.
The code just did not work as before. I did not change anything other than moving to the new code of SK (OF COURSE, I did not… famous last words, eh?).
The result was not an error. It also was not the correct result – rather, it was somehow repeating my question as the Q&A answer.
Something was really weird.
Enter a question or press enter to quit: What is SK?
🤖:What is SK?
Enter a question or press enter to quit:
Code language: Bash (bash)
So, what to do now?
Of course, the truth in distributed systems, especially with “REST” APIs, can be found on the wire.
Therefore, I took a debugging proxy to look at which data goes back and forth between my SK-based C# code and the OpenAI API.
As I am working on an Apple MBP, my choice for a debugging proxy is Charles.
I quickly wrote down a custom IWebProxy class and wired it up in my code with an appropriately configured HttpCient:
var httpClient = new HttpClient(new HttpClientHandler { Proxy = new LocalDebuggingProxy() });
var kernel = Kernel.Builder
.WithOpenAITextEmbeddingGenerationService("text-embedding-ada-002", config["OpenAi:ApiKey"], httpClient: httpClient)
.WithOpenAITextCompletionService("text-davinci-003", config["OpenAi:ApiKey"], httpClient: httpClient)
.WithMemoryStorage(store)
.Build();
Code language: C# (cs)
class LocalDebuggingProxy : IWebProxy
{
public ICredentials? Credentials { get; set; }
public Uri? GetProxy(Uri destination)
{
return new Uri("http://127.0.0.1:8081");
}
public bool IsBypassed(Uri host)
{
return false;
}
}
Code language: C# (cs)
Then, I started the application again and asked the same question… and this is what Charles showed me.

Aha! There we go… now I know where to continue to try to fix my sample.
(And yes, this is simply a bug in SK not properly propagating this kind of error.)
The truth is always on the wire!