mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
`SequenceNumber.Increment()` uses `this._sequenceNumber++` without synchronization. In concurrent streaming scenarios, this can produce race conditions and inconsistent sequencing, which may break event ordering guarantees and potentially allow response-mixing or state confusion. Affected files: SequenceNumber.cs Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com> Co-authored-by: Jacob Alber <jaalber@microsoft.com>
18 lines
497 B
C#
18 lines
497 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
namespace Microsoft.Agents.AI.Hosting.OpenAI.Responses.Streaming;
|
|
|
|
/// <summary>
|
|
/// Implements a sequence number generator.
|
|
/// </summary>
|
|
internal sealed class SequenceNumber
|
|
{
|
|
private int _sequenceNumber;
|
|
|
|
/// <summary>
|
|
/// Gets the next sequence number.
|
|
/// </summary>
|
|
/// <returns>The next sequence number.</returns>
|
|
public int Increment() => System.Threading.Interlocked.Increment(ref this._sequenceNumber) - 1;
|
|
}
|