Skip to content

[dotnet-port-fixes] Fall back when a restored agent mode is no longer configured - #1346

Merged
Quim Muntal (qmuntal) merged 1 commit into
mainfrom
dotnet-port-fixes/agentmode-restore-fallback-492fc1fc6ba06738
Nov 3, 2026
Merged

Quim Muntal (qmuntal) merged 1 commit into
mainfrom
dotnet-port-fixes/agentmode-restore-fallback-492fc1fc6ba06738

Conversation

@microsoft-agent-framework-for-go

Copy link
Copy Markdown
Contributor

Summary

When a session restored from persisted state holds an agentmode mode that the current agentmode.Provider no longer configures, the provider now resets to the configured default mode and persists the correction. This applies to Provider.Mode, context-provider invocation, and the mode_get tool, since all of them go through loadSessionState. A pending mode-change notification that would announce a default-to-default switch is cleared. Previously Go returned the stale mode and injected its instructions.

Ported .NET PRs

Breaking Changes

No. This corrects behavior for restored sessions whose stored mode is no longer valid.

Tests and Examples

  • Added TestRestoredUnconfiguredModeFallsBackToDefault in agent/harness/agentmode, adapted from the upstream test. It covers the fallback and the absence of a default-to-default notification.
  • gofmt was clean and go test ./agent/harness/... passed. No E2E or benchmark suites were run.

Notes

  • Excluded 8ab068b8 (reject duplicate tool approval request IDs, .NET: Reject duplicate tool approval request IDs agent-framework#9542). Go has the counterpart toolapproval package, but the issue duplicate search returned an integrity-filtered result. I assumed conservatively that the approach is not desired. This is not a confirmed maintainer rejection.
  • Fan-out dedupe (ee362838) is already satisfied in Go (workflow/internal/execution/edgerunner.go, around line 303).
  • Duplicate checks for the selected change (issue and PR queries on agentmode restored or stale mode fallback) returned no results, both before editing and again before publication.
  • Only the Go agentmode package and its test were changed; the catalog and guide were left untouched.

Generated by .NET to Go Fixes and Test Porting Agent · copilot · auto · 51.5 AIC · ⌖ 0.754 AIC · ⊞ 4.9K · ◷

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added area:agent Changes files in the agent area parity-approved Go API consistency review found no parity issues labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned user-visible behavior

Changed Go contract

No exported API changes. Observable behavior: a restored agentmode session state whose mode is no longer configured now falls back to the default mode and persists the correction. This applies to Provider.Mode, the context-provider invocation and mode_get. A pending PreviousMode equal to the default is cleared.

Upstream evidence reviewed

Implementation Source Contract checked
.NET AgentModeProvider.cs EnsureConfiguredMode / GetValidatedMode An invalid restored mode is reset to the default and saved. A pending notification equal to the default is cleared. The fallback is used by GetModeAsync, ProvideAIContextAsync and mode_get.

Assessment

The Go change matches the .NET semantics: same trigger, same default fallback, same persistence, same notification clearing, and the same entry points. There is no new option and no gate, and the .NET change is also unconditional. public-api-change is not needed. I did not separately review the Python get_agent_mode fallback that the .NET comment cites.

Generated by Go API Consistency Review Agent for #1346 · copilot · auto · 26.1 AIC · ⌖ 0.614 AIC · ⊞ 4.9K · ◷

@qmuntal
Quim Muntal (qmuntal) marked this pull request as ready for review November 3, 2026 06:25
Copilot AI balanced review requested due to automatic review settings November 3, 2026 06:25
@qmuntal
Quim Muntal (qmuntal) requested a review from a team as a code owner November 3, 2026 06:25
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test does not verify that the mode correction persists through serialization, so it could pass even if ensureConfiguredMode stopped saving the correction.

1 open issue
What changed in this PR

Updates agentmode to fall back to the configured default when a restored session references a mode that is no longer available, without changing the public API.

Changes:

  • Validates stored modes during state loading and persists the fallback.
  • Clears pending notifications that would announce a default-to-default switch.
  • Adds regression coverage for fallback behavior and notification suppression.
File Description
agent/​harness/​agentmode/​agentmode.go Repairs and persists unconfigured stored modes during state loading.
agent/​harness/​agentmode/​agentmode_test.go Tests fallback after mode configuration changes and suppresses redundant notifications.

Review effort: Balanced

Comment on lines +219 to +221
if mode := v2.Mode(session); mode != "draft" {
t.Fatalf("expected fallback to 'draft', got %q", mode)
}
Merged via the queue into main with commit af3268b Nov 3, 2026
24 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the dotnet-port-fixes/agentmode-restore-fallback-492fc1fc6ba06738 branch November 3, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area parity-approved Go API consistency review found no parity issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants