Skip to content

Commit 37d2a02

Browse files
author
aden.chen
committed
Revert "Add retry for missing FunctionName in agent invocation"
This reverts commit f8f4f38.
1 parent f8f4f38 commit 37d2a02

2 files changed

Lines changed: 1 addition & 48 deletions

File tree

src/Infrastructure/BotSharp.Abstraction/Routing/Models/InvokeOptions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ public abstract class InvokeOptions
88
public class InvokeAgentOptions : InvokeOptions
99
{
1010
public bool UseStream { get; set; }
11-
public bool IsRetry { get; set; }
1211

1312
public static InvokeAgentOptions Default()
1413
{
1514
return new()
1615
{
1716
From = InvokeSource.Manual,
18-
UseStream = false,
19-
IsRetry = false
17+
UseStream = false
2018
};
2119
}
2220
}

src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ public async Task<bool> InvokeAgent(
6262
message.IsStreaming = response.IsStreaming;
6363
message.MessageLabel = response.MessageLabel;
6464

65-
// Handle case when FunctionName is null or whitespace - retry once
66-
var retryResult = await HandleEmptyFunctionNameRetry(agentId, message, dialogs, options);
67-
if (retryResult.HasValue)
68-
{
69-
return retryResult.Value;
70-
}
71-
7265
await InvokeFunction(message, dialogs, options);
7366
}
7467
else
@@ -147,42 +140,4 @@ private async Task<bool> InvokeFunction(
147140

148141
return true;
149142
}
150-
151-
/// <summary>
152-
/// Handles the case when FunctionName is null or whitespace by retrying once.
153-
/// Returns null if FunctionName is valid (no action needed),
154-
/// otherwise returns the result of handling (retry result or true if error was set).
155-
/// </summary>
156-
private async Task<bool?> HandleEmptyFunctionNameRetry(
157-
string agentId,
158-
RoleDialogModel message,
159-
List<RoleDialogModel> dialogs,
160-
InvokeAgentOptions? options)
161-
{
162-
if (string.IsNullOrWhiteSpace(message.FunctionName))
163-
{
164-
if (!(options?.IsRetry ?? false))
165-
{
166-
// Retry once by recursively calling InvokeAgent
167-
_logger.LogWarning($"Function name is empty, retrying InvokeAgent for agent {agentId}");
168-
options ??= InvokeAgentOptions.Default();
169-
options.IsRetry = true;
170-
var retryResult = await InvokeAgent(agentId, dialogs, options);
171-
return retryResult;
172-
}
173-
else
174-
{
175-
// Already retried once, avoid infinite loop
176-
_logger.LogError($"Function name is still empty after retry for agent {agentId}, stopping to avoid infinite loop");
177-
message.StopCompletion = true;
178-
message.Content = "I received a function call request but the function name is missing. Please try again.";
179-
message.Role = AgentRole.Assistant;
180-
dialogs.Add(message);
181-
Context.AddDialogs([message]);
182-
return true;
183-
}
184-
}
185-
186-
return null;
187-
}
188143
}

0 commit comments

Comments
 (0)