You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C1 - Two-phase streaming tool call pattern: buffer all function calls
during the stream, execute sequentially after stream completes, then
make ONE continuation with all outputs. Previously, N parallel tool
calls created N forked conversation branches.
C2 - Context length errors in streaming path: added RethrowContextLengthErrors
helper wrapper that puts try/catch only around MoveNextAsync, keeping
yield return outside. C# CS1626 prohibits yield inside try/catch, so
the wrapper is the only valid pattern for exception remapping in async
iterators.
H1 - Restore stream-write body in second catch in StreamMessage:
the SSE error event was lost in a prior edit.
H2 - Clone all relevant ResponseCreationOptions fields in
CloneOptionsWithPreviousResponseId: EndUserId, MaxOutputTokenCount,
TextOptions, TruncationMode, ParallelToolCallsEnabled,
StoredOutputEnabled, ToolChoice, Temperature, TopP, ServiceTier,
Metadata.
H3 - IsContextLengthError now parses structured JSON error code via
TryExtractErrorCode: handles status 413, code token_limit_exceeded,
and context_length_exceeded. Falls back to message substring match.
Bonus: wire EndUserId into CreateResponseOptionsAsync (SDK supports it).
Add LogMcpToolArgumentParseError logger message.
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
// Track this leg's response ID so tool-call continuations chain from it,
188
192
// ensuring the model's context includes the user's message + reasoning.
189
193
string?currentLegResponseId=null;
194
+
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
194
202
if(updateisStreamingResponseCreatedUpdatecreated)
195
203
{
196
204
// Emit the response ID early so the controller can record ownership
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
yieldreturnenumerator.Current;// yield return is outside try/catch — valid
278
+
}
279
+
}
241
280
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
242
-
McpClientmcpClient,
281
+
282
+
/// <summary>
283
+
/// Executes a single MCP tool call and returns the output item to include in the
284
+
/// continuation request. Handles allowlist validation and argument-parsing errors
285
+
/// so a single bad tool never aborts the entire continuation.
286
+
/// </summary>
287
+
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
// Feed a benign error back to the model so it can recover gracefully.
252
-
// The functionCallItem is in the stored response at PreviousResponseId — only send the output.
253
-
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
254
-
varerrorItems=newList<ResponseItem>
255
-
{
256
-
newFunctionCallOutputResponseItem(
257
-
functionCallItem.CallId,
258
-
$"Tool '{functionCallItem.FunctionName}' is not available.")
259
-
};
260
-
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
$"Error parsing arguments for '{functionCallItem.FunctionName}': invalid JSON.");
317
+
}
318
+
276
319
vartoolResult=awaitmcpClient.CallToolAsync(
277
320
functionCallItem.FunctionName,
278
321
arguments:arguments,
279
322
cancellationToken:cancellationToken);
280
323
281
-
// The functionCallItem is already stored in the server's context (referenced by
282
-
// responseOptions.PreviousResponseId). Only the tool output is new content.
283
-
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
289
-
290
-
// Stream the function call response using the same processing logic
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
301
329
302
330
/// <summary>
303
331
/// Creates response options with optional features
/// Used when chaining tool-call continuations from a specific response leg.
512
+
/// All behavior-affecting properties are copied so that tool-call continuation legs
513
+
/// produce identical generation behavior to the initial leg.
486
514
/// </summary>
487
515
#pragma warning disable OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning restore OPENAI001// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
0 commit comments