Skip to content

fix: GooseMode changes applied to existing cached sessions#7606

Closed
Abhijay007 wants to merge 5 commits intoblock:mainfrom
Abhijay007:fix/goosemodeFromConfig
Closed

fix: GooseMode changes applied to existing cached sessions#7606
Abhijay007 wants to merge 5 commits intoblock:mainfrom
Abhijay007:fix/goosemodeFromConfig

Conversation

@Abhijay007
Copy link
Copy Markdown
Collaborator

closes #7603

Summary

Type of Change

  • Bug fix

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

testing rn

Screenshots/Demos (for UX changes)

Before:

After:

@Abhijay007 Abhijay007 marked this pull request as draft March 2, 2026 18:14
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1040933c88

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Abhijay007 Abhijay007 force-pushed the fix/goosemodeFromConfig branch from 1040933 to 9b01af5 Compare March 4, 2026 14:11
@Abhijay007 Abhijay007 marked this pull request as ready for review March 4, 2026 14:11
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b01af5b60

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Abhijay007 Abhijay007 force-pushed the fix/goosemodeFromConfig branch from 9b01af5 to 0e82b42 Compare March 4, 2026 14:19
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e82b4263b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Abhijay007 Abhijay007 force-pushed the fix/goosemodeFromConfig branch from 0e82b42 to 88103cd Compare March 4, 2026 16:46
let mut sessions = self.sessions.write().await;
if let Some(existing) = sessions.get(&session_id) {
let mode = Config::global().get_goose_mode().unwrap_or(GooseMode::Auto);
existing.update_goose_mode(mode).await;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I suppose this is what we're doing now for loading an existing session, but we should probably also store this on the session. Then, to really be careful, only "downgrade" modes, but warn/ask before upgrading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The mode is already stored per-agent in current_goose_mode: Mutex<GooseMode> and updated on every request via update_goose_mode() , and regarding the the upgrade/downgrade guard, I thinnk we can held off on implementing that silently rn, since blocking a user's explicit settings change (e.g. Approve → Auto) without a UI prompt would be surprising ig.

maybe we can hanlde this as a follow-up PR once we have a proper confirmation flow in the UI flow ?

@Abhijay007 Abhijay007 force-pushed the fix/goosemodeFromConfig branch from bfec6ca to bd29f7c Compare March 6, 2026 15:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd29f7c3ed

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Abhijay007 Abhijay007 force-pushed the fix/goosemodeFromConfig branch from b3b4755 to fec1246 Compare March 6, 2026 15:49
Copy link
Copy Markdown
Collaborator

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

I've run into this before in ACP. mode is a mutable session config, and AgentConfig.mode really is the "initial value" of that session, as are any other config there that can change later.

There are tricks about this like some CLI providers cannot be changed without a reboot, so indeed you want to know for sure the best value before starting a provider. We currently have no metadata on a provider to say if it supports session config update and which (bitflag maybe) can be updated without a reboot of it.

so I think possibly if we are updating goose mode, maybe a callback is needed. probably best to look at providers.rs which has some tests in there and if you can recreate a scenario that can prove mode updated properly. e.g. switch auto to chat and try to invoke a tool.

About the code here, main thing is to try to limit the amount of calls in the codebase of get_goose_mode().unwrap_or(GooseMode::Auto) by looking for the same value somewhere higher in the stack. AgentConfig has it, and AgentManager probably should be changed to have it.

@Abhijay007 Abhijay007 force-pushed the fix/goosemodeFromConfig branch from fec1246 to 7ec11cb Compare March 8, 2026 18:07
@codefromthecrypt
Copy link
Copy Markdown
Collaborator

@Abhijay007 I think this is solving the issue per its suggestion, but the suggestion isn't really valid as global config can be not consistent with the session in play. This is especially the case in ACP where the mode is literally set and mutable in the session. We can't conflate the written config file with an arbitrary session, and even if we went to memory, it would be out-of-sync with the session (db) state. There are patterns where we bind config to the session, and I think that's the way forward. I'll draft a PR.

Sorry I didn't notice as I didn't look deeply at the problem and the solution, rather only the solution (here) and I think this was going the wrong path in hindsight. I made the summary comment about it here #7603 (comment)

@Abhijay007
Copy link
Copy Markdown
Collaborator Author

@Abhijay007 I think this is solving the issue per its suggestion, but the suggestion isn't really valid as global config can be not consistent with the session in play. This is especially the case in ACP where the mode is literally set and mutable in the session. We can't conflate the written config file with an arbitrary session, and even if we went to memory, it would be out-of-sync with the session (db) state. There are patterns where we bind config to the session, and I think that's the way forward. I'll draft a PR.

Sorry I didn't notice as I didn't look deeply at the problem and the solution, rather only the solution (here) and I think this was going the wrong path in hindsight. I made the summary comment about it here #7603 (comment)

Oh no problem, and thanks for the detailed review, will wait for you PR on the same and will continue it from there :)

@codefromthecrypt
Copy link
Copy Markdown
Collaborator

@Abhijay007 thanks.. and yeah doing the whole thing is a massive amount of work, vs the workaround. I'll take you up on the offer to review/iterate on the PR as often the velocity in goose is bounded by reviewal more than anything else.

@DOsinga
Copy link
Copy Markdown
Collaborator

DOsinga commented Mar 10, 2026

I think for now the workaround could be to just remove goose mode from the sessionconfig/agent and just always read it from the Config::global. that would not be perfect but would at least work predictable

@codefromthecrypt
Copy link
Copy Markdown
Collaborator

#7801 takes over and fixes ACP too

@DOsinga
Copy link
Copy Markdown
Collaborator

DOsinga commented Mar 26, 2026

closing this in favor of #7801

@DOsinga DOsinga closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: GooseMode changes not applied to existing cached sessions

5 participants