fix: improve autonomous mode comments per code review

This commit is contained in:
copilot-swe-agent[bot]
2026-05-12 00:38:26 +00:00
committed by GitHub
Unverified
parent a47da4de3d
commit 021d9f2dc4
2 changed files with 8 additions and 7 deletions
@@ -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],