fix: GooseMode changes applied to existing cached sessions#7606
fix: GooseMode changes applied to existing cached sessions#7606Abhijay007 wants to merge 5 commits intoblock:mainfrom
Conversation
There was a problem hiding this comment.
💡 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".
1040933 to
9b01af5
Compare
There was a problem hiding this comment.
💡 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".
9b01af5 to
0e82b42
Compare
There was a problem hiding this comment.
💡 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".
0e82b42 to
88103cd
Compare
| 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
bfec6ca to
bd29f7c
Compare
There was a problem hiding this comment.
💡 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".
b3b4755 to
fec1246
Compare
codefromthecrypt
left a comment
There was a problem hiding this comment.
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.
Signed-off-by: Abhijay007 <[email protected]>
Signed-off-by: Abhijay007 <[email protected]>
Signed-off-by: Abhijay007 <[email protected]>
Signed-off-by: Abhijay007 <[email protected]>
Signed-off-by: Abhijay007 <[email protected]>
fec1246 to
7ec11cb
Compare
|
@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 :) |
|
@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. |
|
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 |
|
#7801 takes over and fixes ACP too |
|
closing this in favor of #7801 |
closes #7603
Summary
Type of Change
AI Assistance
Testing
testing rn
Screenshots/Demos (for UX changes)
Before:
After: