Repository navigation
Select CLI custom agents per thread (claude/opencode --agent) - #1566
Conversation
Discover .claude/agents and .opencode/agent(s) (plus user dirs and opencode builtins), add a per-thread agent setting gated on supportsAgents with a safe-name check, pass --agent in argv, and show an Agent picker in the composer. Closes #172 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 280601ff5f
ℹ️ 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".
| if (project) rows.push(...scanAgentDir(path.join(project, ".claude", "agents"), "project", true)); | ||
| rows.push(...scanAgentDir(path.join(home, ".claude", "agents"), "user", true)); |
There was a problem hiding this comment.
Discover agents on the remote project host
For an SSH project, ProjectInfo.remoteHost means the checkout and CLI run on that host (src/shared/ipc.ts:63-66), but these calls synchronously scan the desktop host's projectPath and home directory. Consequently, the picker omits agents installed remotely and may offer local user agents that do not exist when --agent is executed remotely, causing the run to fail or use a fallback agent. Remote projects need discovery through the existing SSH boundary using remotePath and the remote home.
Useful? React with 👍 / 👎.
| let rows = []; | ||
| if (opts.provider === "claude") { | ||
| if (project) rows.push(...scanAgentDir(path.join(project, ".claude", "agents"), "project", true)); | ||
| rows.push(...scanAgentDir(path.join(home, ".claude", "agents"), "user", true)); |
There was a problem hiding this comment.
Use the thread's provider-instance config directory
When a Claude thread uses a named provider instance, the runner supplies that instance's CLAUDE_CONFIG_DIR (electron/providerInstances.js:216-225), but discovery always scans $HOME/.claude/agents. The Agent picker therefore shows agents from the default account and hides agents from the selected instance; choosing one can pass a name unavailable to the spawned CLI. Claude documents CLAUDE_CONFIG_DIR as overriding the default ~/.claude configuration root in its environment-variable reference, so discovery needs the thread's instance environment rather than only the base provider ID.
Useful? React with 👍 / 👎.
| for (const file of files.sort()) { | ||
| if (!file.endsWith(".md")) continue; |
There was a problem hiding this comment.
Recursively discover nested OpenCode agents
For an OpenCode agent stored below a nested directory such as .opencode/agents/team/reviewer.md, this one-level scan sees only the team directory and skips it because it does not end in .md. OpenCode explicitly supports nested agents and derives IDs such as team/reviewer from their relative paths in its Agents documentation, so these valid agents never appear in the picker; discovery and name validation need to preserve safe relative-path IDs.
Useful? React with 👍 / 👎.
Closes #172.
electron/agents.js): claude reads.claude/agents/*.md+~/.claude/agents/*.md(frontmattername:wins); opencode lists builtinsbuild/plan+.opencode/agent(s)/*.md+ XDG user dirs, skippingmode: subagent. Project shadows user; files override builtins.supportsAgentsand emit--agent <name>only when set (opencode prompt stays last).threads.setAgentrejects unsupported providers and unsafe names (names reach ssh/WSL shells). Provider switch clears it.threads.listAgentsis read-scoped,setAgentsteer-scoped inwebScopes.<select>Agent pill in the composer, shown only when the provider supports agents and agents exist (a vanished selection shows as "(not found)" so it can be cleared).Not included: opencode.json inline agents,
--agentin the eject resume command, per-phase agents in workflows.Tests:
electron/test/cli-agents.test.js(discovery, argv, validation, provider switch), appWiring UI→channel test.claude --helpconfirms--agent <agent>; opencode not installed locally.🤖 Generated with Claude Code