Skip to content

🤖 refactor: resolve the workspace agent from metadata and an unsent pick - #5908

Closed
ibetitsmike wants to merge 7 commits into
mike/server-side-ai-seedingfrom
mike/server-side-ai-agent
Closed

ibetitsmike wants to merge 7 commits into
mike/server-side-ai-seedingfrom
mike/server-side-ai-agent

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A workspace's agent lived in a per-browser agentId:{scope} key, so two browsers could show different agents for one workspace. It is now read from workspace metadata (a child's locked agent type first, then agentId). A picker change stays in memory with the field picks' lifecycle: a send carries it, and it ends only once metadata reports that agent, so re-picking an agent while a send is in flight survives that send. Without a saved agent the workspace falls back to the project default agent, then the global default (before: Exec), and follows later changes to those defaults. The picker, AgentContext, the plan handoff, the VS Code webview and the pick store read it this way.

seedWorkspaceLocalStorageFromBackend is deleted: metadata loads and updates feed the resolver's store directly. The per-agent settings cache (workspaceAiSettingsByAgent:{workspace}) goes with it; the Auto routing sync reads saved per-agent settings from metadata, falling back to a legacy workspace's single aiSettings bucket (getSavedAiSettings). Both keys leave the storage registry, and startup cleanup (removeDroppedCacheKeys) now deletes leftover agentId: and workspaceAiSettingsByAgent: values. A fork also copies the source's unsent agent pick. Creation stops writing the new workspace's agent key; its first send carries the agent.

Stack

Milestone M4 of the server-side settings stack, on top of M3 (#5869 to #5879): per-workspace AI picks (model, thinking level, reasoning mode, agent and Auto routing) are stored in workspace metadata in config.json instead of per-browser localStorage keys, so every browser shows the same picks. An unsent picker change stays in memory in its tab until a send saves it, and a reload before sending drops it, as the plan accepts. Layer 15 of 20.

Testing

  • "keeps an unsent agent pick: %s" and "child workspace metadata resolves the locked backend agent" (WorkspaceContext.test.tsx): a pick survives unrelated metadata updates, and a child's agent type wins over its stored id. The AgentContext, ProposePlanToolCall and VS Code sub-agent tests use picks and metadata instead of the key.
  • "the workspace agent falls back to the project, then the global default agent" and "a sent agent pick lasts until the saved agent matches it; an unsent one outlasts it", "re-picking the saved agent while a send is outstanding survives that send" and "a sent agent pick the saved agent already holds ends at once" (aiSelectionIntent.test.ts).
  • "a workspace without a saved agent follows project default agent changes" (AgentContext.test.tsx), and "mount sync applies configured Auto only when the agent has no workspace bucket" (WorkspaceModeAISync.test.tsx) also covers a legacy workspace's single aiSettings bucket.
  • "removes only keys with a dropped cache prefix" now covers the two removed prefixes, and "keeps every key the app still registers" (legacyLocalStorageCleanup.test.ts) checks that no registered key is deleted.
  • "the fork keeps the source's unsent AI picks" (chatCommands.fork.test.ts) also checks the agent pick.
  • In useCreationWorkspace.test.tsx, "sends the global default agent when the project agent is unset" (renamed from "syncs ... to workspace ...") checks the first send's agent; the other creation tests drop their checks of the removed key.
  • make static-check and the touched test suites pass at the top of the stack; CI checks each layer on its own.

Review record

The agent pick lived in a per-browser agentId key seeded from metadata, so two
browsers could disagree. Workspace metadata is now the stored agent and an
unsent picker change stays in memory, read through the same resolver as model.

Stack-Layer: A3a
A fork now also copies the source composer's unsent agent pick. Startup cleanup removes
the retired agentId and workspaceAiSettingsByAgent keys. Adds tests for the project
default agent tier and for an unsent agent pick lasting until the saved agent matches it.
Merges the updated layer below.

Stack-Layer: A3a
@ibetitsmike
ibetitsmike added this pull request to stack #5868 October 8, 2026 21:03
@ibetitsmike ibetitsmike changed the title mike/server side ai agent 🤖 refactor: resolve the workspace agent from metadata and an unsent pick Oct 8, 2026
A fork now also copies the source composer's unsent agent pick. Startup cleanup removes
the retired agentId and workspaceAiSettingsByAgent keys. Adds tests for the project
default agent tier and for an unsent agent pick lasting until the saved agent matches it.
Merges the updated layer below.

Stack-Layer: A3a
@ibetitsmike
ibetitsmike marked this pull request as ready for review October 8, 2026 21:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T00:30:12.307138Z c9a7f22 New commits
🔒 Security Review ✅ Completed 2026-10-09T00:27:31.429232Z c9a7f22 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: ce56cef278

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/utils/aiSelectionIntent.ts Outdated
Comment thread src/browser/utils/scopedAiDefaults.ts
Comment thread src/browser/components/WorkspaceModeAISync/WorkspaceModeAISync.tsx Outdated
Picking the saved agent dropped the pick, so re-picking it while a send of another agent
was in flight lost the choice once that send's metadata arrived. The agent pick now follows
the field picks' token lifecycle: a send attaches it, and it ends once the saved agent holds
it. A workspace without a saved agent also follows project and global default changes, and
Auto routing reads a legacy workspace's single settings bucket, like the composer does.

Stack-Layer: A3a

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

Copy link
Copy Markdown

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: c9a7f22a28

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/utils/aiSelectionIntent.ts
Comment thread src/browser/utils/legacyLocalStorageCleanup.ts
@ibetitsmike
ibetitsmike removed this pull request from stack #5868 October 9, 2026 04:49
@ibetitsmike

Copy link
Copy Markdown
Contributor Author

Landed in #5916 (7b9899d), which collapsed this stack into one squash merge.

@ibetitsmike ibetitsmike closed this Oct 9, 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.

1 participant