fix 08
This commit is contained in:
parent
bb2ef2166f
commit
2241bd4ee4
|
|
@ -377,6 +377,17 @@ public class ConversationStateService : IConversationStateService
|
||||||
&& !string.IsNullOrEmpty(_curStates[name].Values.Last().Data);
|
&& !string.IsNullOrEmpty(_curStates[name].Values.Last().Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Argument names that must never be written as conversation state. They are BotSharp's own
|
||||||
|
/// LLM-routing keys (read back by <c>CompletionProvider.GetProviderAndModel</c>): a tool whose
|
||||||
|
/// arguments happen to use one of these names would otherwise silently retarget the model for
|
||||||
|
/// the next round. A board tool's <c>provider</c> argument, for example, replaced the resolved
|
||||||
|
/// LLM provider with "forgejo", so the re-invocation after the tool call resolved no completion
|
||||||
|
/// provider and threw a NullReferenceException in RoutingService.InvokeAgent.
|
||||||
|
/// </summary>
|
||||||
|
private static readonly HashSet<string> ReservedLlmStateKeys =
|
||||||
|
new(StringComparer.OrdinalIgnoreCase) { "provider", "model", "model_id" };
|
||||||
|
|
||||||
public void SaveStateByArgs(JsonDocument args)
|
public void SaveStateByArgs(JsonDocument args)
|
||||||
{
|
{
|
||||||
if (args == null)
|
if (args == null)
|
||||||
|
|
@ -388,6 +399,9 @@ public class ConversationStateService : IConversationStateService
|
||||||
{
|
{
|
||||||
foreach (JsonProperty property in root.EnumerateObject())
|
foreach (JsonProperty property in root.EnumerateObject())
|
||||||
{
|
{
|
||||||
|
// Never let a function argument shadow the LLM routing state.
|
||||||
|
if (ReservedLlmStateKeys.Contains(property.Name)) continue;
|
||||||
|
|
||||||
var propertyValue = property.Value;
|
var propertyValue = property.Value;
|
||||||
var stateValue = propertyValue.ToString();
|
var stateValue = propertyValue.ToString();
|
||||||
if (!string.IsNullOrEmpty(stateValue))
|
if (!string.IsNullOrEmpty(stateValue))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue