Skip to content

feat: persist GooseMode per-session via session DB#7854

Merged
codefromthecrypt merged 4 commits intomainfrom
adrian/persist-mode
Mar 16, 2026
Merged

feat: persist GooseMode per-session via session DB#7854
codefromthecrypt merged 4 commits intomainfrom
adrian/persist-mode

Conversation

@codefromthecrypt
Copy link
Collaborator

@codefromthecrypt codefromthecrypt commented Mar 13, 2026

Summary

GooseMode is read from global config everywhere: agents, providers, system prompts, get_tools. Switching mode in the UI writes config but nothing persists it to the session, so reloading a session loses the mode. Providers bake permission flags at spawn time and never update. The mode selector looks dynamic but the actual permission behavior is inconsistent.

This change makes mode per-session, mutable and persistent:

  • Session DB (schema v8): goose_mode column on sessions table. create_session accepts a mode; get_session restores it. SessionUpdateBuilder::goose_mode() for runtime changes.

  • Server: /agent/update_session accepts goose_mode, persists to DB, and calls Agent::update_goose_mode which propagates to the provider via Provider::update_mode().

  • Agent: current_goose_mode mutex replaces global config reads. update_goose_mode() updates the mutex, calls provider.update_mode(), and persists to DB. System prompts and tool listings read the session-scoped mode.

  • UI: BottomMenuModeSelection fetches mode from session API and writes only to session DB. It does not write global config. To change the default for new sessions, use settings or goose configure.

Providers

Provider::update_mode() propagates mode on initial attachment and runtime changes:

  • Claude Code: rejects mid-session mode changes (mode baked at subprocess spawn; claude-acp replaces this provider, feat(acp): add session/set_mode handler #7801).
  • Codex: fresh subprocess per turn. update_mode() stores session_id to mode in a map; apply_permission_flags reads from it.
  • Ollama: removed redundant Chat-mode tool filter. The agent already skips tool calls in Chat mode.
  • ACP: session/set_mode handler persists mode per-session. on_load_session restores it from DB.

Subagents beware

Subagents (summon.rs) must use Auto until get_agent_messages forwards ActionRequired messages to the parent.
Until then, any mode that requires approval will hang on the subagent's confirmation_rx.
This is the same as current, but should be refactored to work once this is merged.

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Tests

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Goose UI

Kill goose and clear session state:

$ pkill -f goose
$ rm -rf ~/.local/state/goose/logs ~/.local/share/goose/sessions

Run the UI

$ just run-ui

Test Mode durability:

  1. Start a new session, send any message (e.g. hello)
  2. Switch mode to "approve" via bottom bar mode selector
  3. Kill the goose process: pkill -f goose
  4. Restart: just run-ui
  5. Load the previous session from the session list
  6. Bottom bar mode selector should show "manual" (approve), not "autonomous" (auto)
  7. Prompt: what is in /tmp. The developer extension tries to run a shell command and a permission dialog appears (proves approve mode is enforced, not just displayed)
  8. Approve the permission; command executes and returns results

Test mode persistence across provider swap:

  1. Start a new session, send any message
  2. Switch mode to "approve" via bottom bar mode selector
  3. Open Settings and switch the provider/model (this calls /agent/update_provider)
  4. Bottom bar mode selector should still show "manual" (approve)
  5. Prompt: what is in /tmp. Permission dialog should appear (proves mode survived provider swap)

Test multi-session mode isolation:

  1. Start session A, switch mode to "approve"
  2. Open a new session B (should default to "auto")
  3. Switch back to session A
  4. Bottom bar should show "manual" (approve), not "autonomous" (auto)

Zed (ACP)

Kill goose and clear state:

$ pkill -f goose
$ rm -rf ~/.local/state/goose/logs ~/.local/share/goose/sessions
$ rm -rf ~/Library/Logs/Zed/ ~/Library/Application\ Support/Zed/threads/

Build and configure:

$ just release-binary

Add to ~/.config/zed/settings.json:

"agent_servers": {
"goose": {
"type": "custom",
"command": "/path/to/goose/target/release/goose",
"args": ["acp", "--with-builtin", "developer"],
"env": { "RUST_LOG": "debug" }
}
}

Mode selection:

Open Zed's agent panel. The mode selector (bottom bar, next to model selector) shows "auto" as the default.

  1. Click the mode selector
  2. Switch to "approve"
  3. Enter "hello" and send it.
  4. Close and reopen.
  5. Under Recent, click "User greeting"
  6. you should see the mode is still "approve"

Related Issues

Fixes #7603
Alternate to #7606

Screenshots

Goose UI

Screenshot 2026-03-13 at 4 32 11 PM Screenshot 2026-03-13 at 4 33 13 PM

Zed

Screenshot 2026-03-13 at 8 50 28 PM Screenshot 2026-03-13 at 8 49 17 PM Screenshot 2026-03-13 at 8 48 21 PM Screenshot 2026-03-13 at 8 47 37 PM

Copy link

@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: 9b6b359c24

ℹ️ 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".

@jh-block jh-block self-assigned this Mar 13, 2026
Copy link

@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: 9b1a294437

ℹ️ 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".

@codefromthecrypt
Copy link
Collaborator Author

going to wire in ACP now

Copy link

@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: 71132682cd

ℹ️ 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".

@codefromthecrypt codefromthecrypt force-pushed the adrian/persist-mode branch 2 times, most recently from dea3fa7 to ddf4b08 Compare March 13, 2026 12:53
@codefromthecrypt
Copy link
Collaborator Author

ACP is wired in and added screenshots of Zed. any pushes to this branch are welcome as needed @jh-block or you can tell me to follow-up but I am limited availability as in transit Monday

Copy link

@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: ddf4b08fe3

ℹ️ 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".

Copy link

@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: d529590a53

ℹ️ 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".

@codefromthecrypt
Copy link
Collaborator Author

ok done working on this, any new copilot things I don't have time for

Copy link

@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: fcd1c43159

ℹ️ 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".

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Propagate session mode to new provider after swap in
update_agent_provider. Remove BaseChat useEffect that wrote every
sessions mode to global config, causing multi-session stomping.
BottomMenuModeSelection now fetches mode from session API and writes
only to session DB.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Copy link

@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: 0485ef9310

ℹ️ 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".

Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt
Copy link
Collaborator Author

ok I had some time to feed the bot again, but I'm out of it again.

Copy link

@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: 586d668cf2

ℹ️ 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".

@codefromthecrypt codefromthecrypt added this pull request to the merge queue Mar 16, 2026
Merged via the queue into main with commit 94fdcdd Mar 16, 2026
23 checks passed
@codefromthecrypt codefromthecrypt deleted the adrian/persist-mode branch March 16, 2026 11:50
wpfleger96 added a commit that referenced this pull request Mar 16, 2026
…oken-retry

* origin/main: (21 commits)
  Remove java/.ai-usage-marker directory (#7925)
  test(acp): add terminal delegation fixtures and fix shell singleton (#7923)
  fix: bump pctx_code_mode to 0.3.0 for iterator type checking fix (#7892)
  feat: persist GooseMode per-session via session DB (#7854)
  feat(otel): propagate session.id to spans and log records (#7490)
  fix(test): add env_lock to is_openai_reasoning_model tests (#7917)
  fix(acp): pass session_id when loading extensions so skills are discovered (#7868)
  updated canonical models (#7920)
  feat(autovisualiser): Migrate the autovisualiser extension to MCP Apps  (#7852)
  fix: add tool_choice and parallel_tool_calls to chatgpt_codex provider (#7867)
  fix: tool confirmation handling for multiple requests (#7856)
  Remove dead OllamaSetup onboarding flow (#7861)
  fix: resolve tokio::sync::Mutex deadlock in recipe retry path (#7832)
  Upgrade Electron 40.6.0 → 41.0.0 (#7851)
  Only show up to 50 lines of source code (#7578)
  fix: stop writing without error when hitting broken pipe for goose session list (#7858)
  feat(acp): add session/set_mode handler (#7801)
  Keep messages in sync (#7850)
  More acp tools (#7843)
  fix: skip upgrade-insecure-requests CSP for external HTTP backends (#7714)
  ...
wpfleger96 added a commit that referenced this pull request Mar 16, 2026
* origin/main: (72 commits)
  No Check do Check (#7942)
  Log 500 errors and also show error for direct download (#7936)
  fix: retry on authentication failure with credential refresh (#7812)
  Remove java/.ai-usage-marker directory (#7925)
  test(acp): add terminal delegation fixtures and fix shell singleton (#7923)
  fix: bump pctx_code_mode to 0.3.0 for iterator type checking fix (#7892)
  feat: persist GooseMode per-session via session DB (#7854)
  feat(otel): propagate session.id to spans and log records (#7490)
  fix(test): add env_lock to is_openai_reasoning_model tests (#7917)
  fix(acp): pass session_id when loading extensions so skills are discovered (#7868)
  updated canonical models (#7920)
  feat(autovisualiser): Migrate the autovisualiser extension to MCP Apps  (#7852)
  fix: add tool_choice and parallel_tool_calls to chatgpt_codex provider (#7867)
  fix: tool confirmation handling for multiple requests (#7856)
  Remove dead OllamaSetup onboarding flow (#7861)
  fix: resolve tokio::sync::Mutex deadlock in recipe retry path (#7832)
  Upgrade Electron 40.6.0 → 41.0.0 (#7851)
  Only show up to 50 lines of source code (#7578)
  fix: stop writing without error when hitting broken pipe for goose session list (#7858)
  feat(acp): add session/set_mode handler (#7801)
  ...
lifeizhou-ap added a commit that referenced this pull request Mar 17, 2026
* main:
  Add DCO git commit command to AGENTS.md (#7945)
  fix(claude-code): remove incorrect agent_visible filter on user message (#7931)
  No Check do Check (#7942)
  Log 500 errors and also show error for direct download (#7936)
  fix: retry on authentication failure with credential refresh (#7812)
  Remove java/.ai-usage-marker directory (#7925)
  test(acp): add terminal delegation fixtures and fix shell singleton (#7923)
  fix: bump pctx_code_mode to 0.3.0 for iterator type checking fix (#7892)
  feat: persist GooseMode per-session via session DB (#7854)
  feat(otel): propagate session.id to spans and log records (#7490)
  fix(test): add env_lock to is_openai_reasoning_model tests (#7917)
  fix(acp): pass session_id when loading extensions so skills are discovered (#7868)
jh-block added a commit that referenced this pull request Mar 17, 2026
* origin/main:
  feat: adversarial agent for preventing leaking of info and more  (#7948)
  Update contributing.md (#7927)
  docs: add credit balance monitoring section (#7952)
  docs: add Cerebras provider to supported providers list (#7953)
  docs: add TUI client documentation to ACP clients guide (#7950)
  fix: removed double dash in pnpm command (#7951)
  docs: polish ACP docs (#7946)
  claude adaptive thinking (#7944)
  feat: new onboarding flow (#7266)
  Add DCO git commit command to AGENTS.md (#7945)
  fix(claude-code): remove incorrect agent_visible filter on user message (#7931)
  No Check do Check (#7942)
  Log 500 errors and also show error for direct download (#7936)
  fix: retry on authentication failure with credential refresh (#7812)
  Remove java/.ai-usage-marker directory (#7925)
  test(acp): add terminal delegation fixtures and fix shell singleton (#7923)
  fix: bump pctx_code_mode to 0.3.0 for iterator type checking fix (#7892)
  feat: persist GooseMode per-session via session DB (#7854)
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

2 participants