Repository navigation
Is Retry Possible in SemanticKernelAgent Adapter #6199
Replies: 3 comments
|
I think this is actually similar to the discussion I brought up. I see the same problem with the |
|
Eric Zhu (@ekzhu) I'm using the Semantic Kernel Agent Adapter with Claude 3.7 Sonnet and occasionally getting empty responses at random. I'm working with the .NET version of AutoGen. Any ideas on how to fix this?" |
|
Thanks Yuva-raj-18 for the screenshot and Alex-Wenner-FHR (@Alex-Wenner-FHR) for linking #6176; that is the Python side of the same cause, so here is the .NET side, verified with Cause. Bedrock Converse can return an assistant turn with Retry. Yes, with static bool IsEmpty(IMessage m) => m switch
{
MultiModalMessage mm => !mm.Content.Any(), // what the connector emits for a Converse turn with content: []
_ => string.IsNullOrWhiteSpace(m.GetContent()),
};
var agent = new SemanticKernelAgent(kernel, "SupportAgent",
settings: new AmazonClaudeExecutionSettings { MaxTokensToSample = 1024 }) // default settings send maxTokens: 0, which Converse rejects
.RegisterMessageConnector()
.RegisterMiddleware(async (msgs, opt, next, ct) =>
{
var reply = await next.GenerateReplyAsync(msgs, opt, ct);
for (var attempt = 1; attempt <= 2 && IsEmpty(reply); attempt++)
reply = await next.GenerateReplyAsync(msgs, opt, ct);
return reply;
});
So the retry covers the random case; for a trailing self-message it re-sends the same prefill, and dropping or folding that message before the call is what fixes that one. Verification detailsConverse returning zero content blocks (aws cli, us-east-1,
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi Everyone,
I'm using the SemanticKernelAgentAdapter for creating new agents. Occasionally, the agent returns an empty response at random, even though we're maintaining the conversation history correctly. I have two questions:
FYI - I am using dotnet version of autogen.
What could be causing the agent to return an empty response, and how can I fix it?
Is it possible to implement a retry mechanism only when the agent returns an empty response?
All reactions