mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
fix: improve autonomous mode comments per code review
This commit is contained in:
committed by
GitHub
Unverified
parent
a47da4de3d
commit
021d9f2dc4
@@ -316,8 +316,6 @@ internal sealed class HandoffAgentExecutor :
|
||||
// turn by injecting a synthetic user message instead of returning control to the user.
|
||||
if (this._options.AutonomousMode && !result.IsHandoffRequested && this._autonomousModeTurnCount < this._options.AutonomousModeTurnLimit)
|
||||
{
|
||||
this._autonomousModeTurnCount++;
|
||||
|
||||
ChatMessage autonomousMessage = new(ChatRole.User, this._options.AutonomousModePrompt)
|
||||
{
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
@@ -334,6 +332,10 @@ internal sealed class HandoffAgentExecutor :
|
||||
context,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Increment only after successfully adding the autonomous message to shared state.
|
||||
// This ensures the counter remains accurate if the state write throws an exception.
|
||||
this._autonomousModeTurnCount++;
|
||||
|
||||
return await this.ContinueTurnAsync(
|
||||
state with { ConversationBookmark = autonomousBookmark },
|
||||
[autonomousMessage],
|
||||
|
||||
Reference in New Issue
Block a user