Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class MessageTypeName
/// <summary>
/// A message that belongs to the conversation record but not to the conversation as the user
/// sees it -- what an agent said to itself on the way to an answer. Stored like any other
/// message and read back into the model's context; skipped when the dialog is rendered.
/// message and left out of later turns; skipped when the dialog is rendered.
/// </summary>
public const string Internal = "internal";
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ private async Task<bool> InvokeFunction(
}
else
{
// Save to memory dialogs
// Save to memory dialogs and to storage
var msg = RoleDialogModel.From(message,
role: AgentRole.Function,
content: message.Content);

dialogs.Add(msg);
Context.AddDialogs([msg]);
await Persist(msg);

// Send to Next LLM
var curAgentId = routing.Context.GetCurrentAgentId();
Expand All @@ -132,6 +133,12 @@ private async Task<bool> InvokeFunction(
}
else
{
// The function wrote the reply itself. The call is still worth a record, but kept out
// of context, since the assistant message that follows carries the same text.
var record = RoleDialogModel.From(message, role: AgentRole.Function);
record.ExcludeFromContext = true;
await Persist(record);

var msg = RoleDialogModel.From(message,
role: AgentRole.Assistant,
content: message.Content);
Expand All @@ -141,4 +148,16 @@ private async Task<bool> InvokeFunction(

return true;
}

private async Task Persist(RoleDialogModel message)
{
var conv = _services.GetRequiredService<IConversationService>();
if (!conv.IsConversationMode())
{
return;
}

var storage = _services.GetRequiredService<IConversationStorage>();
await storage.Append(conv.ConversationId, message);
}
}
Loading