Skip to content

Commit a0347e2

Browse files
authored
Remove invalid error check from PersistentAgentsChatClient (Azure#53017)
The check is overly strict; it assumes all of the provided messages are in response to a previous conversation with this service, but the messages could be the history from a conversation with another service, as can happen in agent-based scenarios. In such cases, there may be function tool calls and results in the history; the rest of the implementation will properly ignore them, as the service doesn't provide any way to send those calls into the service, but this check was blowing up before then.
1 parent 7ac517b commit a0347e2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

sdk/ai/Azure.AI.Agents.Persistent/src/Custom/PersistentAgentsChatClient.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ public virtual async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAs
8181

8282
// Get the thread ID.
8383
string? threadId = options?.ConversationId ?? _defaultThreadId;
84-
if (threadId is null && toolResults is not null)
85-
{
86-
throw new ArgumentException("No thread ID was provided, but chat messages includes tool results.", nameof(messages));
87-
}
8884

8985
// Get any active run ID for this thread.
9086
ThreadRun? threadRun = null;
@@ -107,7 +103,7 @@ threadRun is not null &&
107103
ConvertFunctionResultsToToolOutput(toolResults, approvalResults, out List<ToolOutput> toolOutputs, out List<ToolApproval> toolApprovals) is { } toolRunId &&
108104
toolRunId == threadRun.Id)
109105
{
110-
// There's an active run and we have tool results to submit, so submit the results and continue streaming.
106+
// There's an active run and we have tool results to submit for that run, so submit the results and continue streaming.
111107
// This is going to ignore any additional messages in the run options, as we are only submitting tool outputs,
112108
// but there doesn't appear to be a way to submit additional messages, and having such additional messages is rare.
113109
updates = _client!.Runs.SubmitToolOutputsToStreamAsync(threadRun, toolOutputs, toolApprovals, cancellationToken);

0 commit comments

Comments
 (0)