Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

revert(agent): remove per-agent local skill toggle (MUL-2603) (#3286)

Multica Eve744b474199f9
diff --git a/apps/docs/content/docs/guides/agents.zh.mdx b/apps/docs/content/docs/guides/agents.zh.mdx
index 8a71c4bed9..b489d64450 100644
--- a/apps/docs/content/docs/guides/agents.zh.mdx
+++ b/apps/docs/content/docs/guides/agents.zh.mdx
@@ -40,7 +40,7 @@ The daemon auto-detects which CLIs are available on your PATH and registers them
Multica supports two layers of skills:
-- **Local skills** — Skills already installed in your local runtime (e.g., `.claude/skills/`, `.opencode/skills/`). For Claude Code and Codex, host-machine skills under `~/.claude/skills/` and `~/.codex/skills/` are **merged by default** for each agent (so existing personal workflows keep working) — toggle the per-agent **Allow host-machine Skills** switch off to isolate a shared agent against a broken local skill on one operator's machine (GitHub #3052). Other runtimes ignore this setting — the daemon does not actively manage user-level skill discovery for them today.
+- **Local skills** — Skills already installed in your local runtime (e.g., `.claude/skills/`, `.opencode/skills/`) are automatically discovered and used by agents. You do **not** need to upload them to Multica.
- **Workspace skills** — Skills created or imported in the Multica Skills page are shared across the workspace. They are automatically injected into agent runs as supplementary context, so every team member's agents benefit from them.
Workspace skills are designed for team-wide sharing and collaboration — codify your team's best practices once, and every agent can leverage them:
diff --git a/apps/docs/content/docs/skills.mdx b/apps/docs/content/docs/skills.mdx
index d6535de88e..1971a56e9e 100644
--- a/apps/docs/content/docs/skills.mdx
+++ b/apps/docs/content/docs/skills.mdx
@@ -16,24 +16,6 @@ Multica supports two skill sources:
Most of the time you want **workspace skills**: import once, every teammate's agent can use it. Local skills are a fit when you want to test locally first, or when the content involves sensitive local material.
-### Per-agent host-skill merge toggle
-
-By default Multica **merges** the host machine's user-global skill directory into the agent (so existing personal workflows that rely on locally installed Claude skills keep working out of the box). You can flip the toggle to **ignore** when a shared agent should be hardened against a broken local skill on one operator's machine — that scenario crashes the Claude CLI before it ever reads a prompt (silent `broken pipe` exits, see GitHub #3052).
-
-Each agent carries a `skills_local` switch you can change from the **Create Agent** dialog or the agent's **Skills** tab:
-
-- **On — Merge (default)**: the runtime inherits the full `~/.claude/` directory, including its `skills/`. Matches the pre-MUL-2603 behavior — recommended for personal agents that intentionally rely on locally installed skills.
-- **Off — Ignore**: the runtime launches against a per-task config directory that mirrors the host's effective Claude config dir *except* for `skills/`. The source is resolved with precedence agent `custom_env` `CLAUDE_CONFIG_DIR` > parent process `CLAUDE_CONFIG_DIR` > `~/.claude/`, so an operator who pinned Claude at a managed install keeps the right credentials and settings. Login credentials (`.credentials.json`), global settings, plugins, and agents pass through, so Claude Code authentication keeps working — only the user-global skills directory is hidden from the CLI. On Windows hosts without Developer Mode the mirror falls back to directory junctions and hardlink/copy for files, so the passthrough still works without elevated privileges. Recommended for any shared agent where host-skill safety matters.
-
-Workspace skills under `{workDir}/.claude/skills/` (and the equivalent workdir-scoped paths for other runtimes) are loaded regardless of the toggle — this switch only governs the host's user-global skills directory.
-
-**Which runtimes the toggle covers today:** Claude Code and Codex are the two runtimes where the daemon actively manages user-skill discovery, so they are the two that honor the toggle:
-
-- **Claude Code** — when set to **Off**, `CLAUDE_CONFIG_DIR` points at a per-task scratch dir that mirrors the host's effective Claude config dir *except* for `skills/` (see above).
-- **Codex** — Codex always runs inside a per-task `CODEX_HOME`. When set to **On (default)** the daemon seeds that `CODEX_HOME` with user-installed skills from the shared `~/.codex/skills/`; when set to **Off** the seed step is skipped, so the Codex CLI sees only workspace skills.
-
-For every other runtime (Hermes / Kimi / Kiro / Copilot / Cursor / Gemini / Pi / OpenCode / OpenClaw) the daemon leaves the user's `$HOME` untouched and does not actively manage user-level skill discovery — whether that runtime reads any user-level skill directory is entirely up to its own CLI. **The toggle is hidden in the Create Agent dialog and the Skills tab for these runtimes** to avoid implying behavior the daemon won't deliver today; a future change can extend per-runtime isolation as upstream CLIs ship the necessary knobs.
-
## Importing a skill
Workspace skills come from four sources:
diff --git a/apps/docs/content/docs/skills.zh.mdx b/apps/docs/content/docs/skills.zh.mdx
index d003366fbe..47578371ab 100644
--- a/apps/docs/content/docs/skills.zh.mdx
+++ b/apps/docs/content/docs/skills.zh.mdx
@@ -16,24 +16,6 @@ Multica 支持两种 Skill 来源:
大多数情况用**工作区 Skill**:导入一次,团队所有成员的智能体都能用。本机 Skill 适合先在本地测试、或涉及敏感本地内容的场景。
-### 按智能体维度的"合并本机 Skill"开关
-
-默认情况下 Multica **会**把本机用户级 skill 目录合并进智能体(保持 MUL-2603 之前的"继承本机"行为,避免误伤依赖本机 skill 的个人智能体)。如果某个共享智能体需要防御"某台机器上有问题的本机 skill"——这种情况会让 Claude CLI 还没读到 prompt 就崩(典型表现是 `broken pipe`,参见 GitHub #3052)——你可以把开关切到 ignore。
-
-每个智能体都带有一个 `skills_local` 开关,可在 **创建 Agent** 弹窗或智能体的 **Skills** 标签页里切换:
-
-- **开启 —— Merge(默认)**:运行时直接继承完整的 `~/.claude/`,包括 `skills/`。沿用 MUL-2603 之前的行为,适合个人智能体或明确依赖本机 skill 的场景。
-- **关闭 —— Ignore**:运行时使用按任务隔离的配置目录,目录里通过软链镜像了主机实际生效的 Claude 配置目录中除 `skills/` 之外的全部内容。源目录的解析顺序为:agent `custom_env` 中的 `CLAUDE_CONFIG_DIR` > 父进程 `CLAUDE_CONFIG_DIR` > `~/.claude/`,因此把 Claude 固定到托管安装目录的运维者仍能拿到正确的凭据和设置。登录凭据(`.credentials.json`)、全局设置、插件、本地 agent 仍会被 CLI 看到,Claude Code 登录态不受影响,只屏蔽用户级 skill 目录。在未开启开发者模式的 Windows 主机上,软链失败时会自动回退为目录联结(junction)以及文件的硬链接/拷贝,保证无管理员权限时镜像仍然可用。**推荐在需要防御本机 skill 风险的共享智能体上启用**。
-
-无论开关如何,工作区目录下的 `{workDir}/.claude/skills/`(以及其他 runtime 在工作目录下对应的路径)都会照常加载——这个开关只控制本机用户级 skill 目录。
-
-**目前哪些运行时实际受开关影响:** 守护进程主动管理用户级 skill 发现的运行时是 Claude Code 和 Codex,所以开关对它们都生效:
-
-- **Claude Code** —— 关闭时把 `CLAUDE_CONFIG_DIR` 指向按任务隔离的目录,里面镜像了主机有效的 Claude 配置目录中除 `skills/` 之外的内容(见上)。
-- **Codex** —— Codex 一向运行在按任务隔离的 `CODEX_HOME` 下。开启(默认)时守护进程会把共享的 `~/.codex/skills/` seed 到该目录;关闭时跳过这一步,Codex CLI 只能看到工作区 skill。
-
-对其它运行时(Hermes / Kimi / Kiro / Copilot / Cursor / Gemini / Pi / OpenCode / OpenClaw),守护进程既不改写用户的 `$HOME`,也不主动管理用户级 skill 发现——这些运行时是否读取任何用户级 skill 目录,完全由各自的 CLI 决定。**在创建 Agent 弹窗和 Skills 标签页里,这些运行时下不会展示该开关**,避免让用户误以为守护进程会替它们做隔离;待上游 CLI 提供必要的隔离开关后,可以再补齐。
-
## 导入 Skill
工作区 Skill 有四种来源:
diff --git a/packages/core/agents/index.ts b/packages/core/agents/index.ts
index 1ea4cd4558..924c31494e 100644
--- a/packages/core/agents/index.ts
+++ b/packages/core/agents/index.ts
@@ -7,4 +7,3 @@ export * from "./use-workspace-presence-prefetch";
export * from "./constants";
export * from "./visibility-label";
export * from "./use-workspace-agent-availability";
-export * from "./skills-local-support";
diff --git a/packages/core/agents/skills-local-support.test.ts b/packages/core/agents/skills-local-support.test.ts
deleted file mode 100644
index c69c87b12b..0000000000
--- a/packages/core/agents/skills-local-support.test.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { isSkillsLocalSupportedProvider } from "./skills-local-support";
-
-describe("isSkillsLocalSupportedProvider", () => {
- it("returns true for the providers whose runtime honours skills_local", () => {
- expect(isSkillsLocalSupportedProvider("claude")).toBe(true);
- expect(isSkillsLocalSupportedProvider("codex")).toBe(true);
- });
-
- it("returns false for every other provider in the daemon catalog", () => {
- // Snapshot of the providers daemon recognises today (MUL-2603 thread).
- // None of them currently enforce skills_local at exec time, so the UI
- // hides the toggle for all of them.
- for (const p of [
- "copilot",
- "opencode",
- "openclaw",
- "pi",
- "cursor",
- "kimi",
- "kiro",
- "gemini",
- "hermes",
- ]) {
- expect(isSkillsLocalSupportedProvider(p)).toBe(false);
- }
- });
-
- it("returns false for missing / unknown provider values", () => {
- expect(isSkillsLocalSupportedProvider(null)).toBe(false);
- expect(isSkillsLocalSupportedProvider(undefined)).toBe(false);
- expect(isSkillsLocalSupportedProvider("")).toBe(false);
- expect(isSkillsLocalSupportedProvider("not-a-real-provider")).toBe(false);
- });
-});
diff --git a/packages/core/agents/skills-local-support.ts b/packages/core/agents/skills-local-support.ts
deleted file mode 100644
index aba870d040..0000000000
--- a/packages/core/agents/skills-local-support.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-// Providers whose runtime actually honours the per-agent `skills_local`
-// toggle today. Claude isolates `~/.claude/skills` via `CLAUDE_CONFIG_DIR`;
-// Codex isolates `~/.codex/skills` via per-task `CODEX_HOME`. Every other
-// provider currently stores the field but treats it as a no-op at exec
-// time, so surfacing the toggle in their agent pages would mislead users
-// into thinking it gates host-skill access for them. See MUL-2603 discussion.
-export const SKILLS_LOCAL_SUPPORTED_PROVIDERS = ["claude", "codex"] as const;
-
-export function isSkillsLocalSupportedProvider(
- provider: string | null | undefined,
-): boolean {
- if (!provider) return false;
- return (SKILLS_LOCAL_SUPPORTED_PROVIDERS as readonly string[]).includes(
- provider,
- );
-}
diff --git a/packages/core/types/agent.ts b/packages/core/types/agent.ts
index 4e9b7354c9..61a7d880d2 100644
--- a/packages/core/types/agent.ts
+++ b/packages/core/types/agent.ts
@@ -4,19 +4,6 @@ export type AgentRuntimeMode = "local" | "cloud";
export type AgentVisibility = "workspace" | "private";
-/**
- * Per-agent toggle controlling whether the runtime merges the host machine's
- * user-global skill directory into the agent. "merge" (default) preserves the
- * inherit-from-machine behavior; "ignore" isolates the runtime so a broken
- * local skill on one operator's machine cannot crash a shared agent (#3052).
- * Only the Claude and Codex runtimes honour the switch (Claude via
- * CLAUDE_CONFIG_DIR, Codex via CODEX_HOME); the UI hides the toggle for
- * other runtimes so users don't get a false sense of isolation. Older
- * backends omit the field; clients MUST treat undefined as "merge" so the
- * documented default wins on drift.
- */
-export type AgentSkillsLocal = "ignore" | "merge";
-
// Runtime visibility is a separate axis from agent visibility — different
// vocabulary because it gates a different action. "private" (default) means
// only the runtime owner and workspace admins can bind agents to it;
@@ -169,14 +156,6 @@ export interface Agent {
* (MUL-2339).
*/
thinking_level?: string;
- /**
- * Per-agent toggle for merging the host machine's user-global skill
- * directory (e.g. Claude's `~/.claude/skills/`) into the agent. Older
- * backends that predate the column omit this field; consumers MUST
- * default to `"merge"` on drift to match the documented platform
- * default (#3052 hardening is opt-in via `"ignore"`).
- */
- skills_local?: AgentSkillsLocal;
owner_id: string | null;
skills: AgentSkillSummary[];
created_at: string;
@@ -212,10 +191,6 @@ export interface CreateAgentRequest {
model?: string;
/** Optional runtime-native reasoning/effort token. See `Agent.thinking_level`. */
thinking_level?: string;
- /** Per-agent host-skill merge toggle. Defaults to `"merge"` server-side
- * when omitted (inherit-from-machine behavior); pass `"ignore"` to
- * isolate the agent from the host's user-global skill directory. */
- skills_local?: AgentSkillsLocal;
/** Optional template slug used by the onboarding agent picker. Surfaced
* as the `template` property on the `agent_created` PostHog event. */
template?: string;
@@ -321,8 +296,6 @@ export interface UpdateAgentRequest {
* runtime's provider enum, rejected with 400 if not recognised
*/
thinking_level?: string;
- /** Update the host-skill merge toggle. Omit to leave unchanged. */
- skills_local?: AgentSkillsLocal;
}
/**
diff --git a/packages/core/types/index.ts b/packages/core/types/index.ts
index 2c74fdd4c6..5d09cb2d81 100644
--- a/packages/core/types/index.ts
+++ b/packages/core/types/index.ts
@@ -4,7 +4,6 @@ export type {
AgentStatus,
AgentRuntimeMode,
AgentVisibility,
- AgentSkillsLocal,
AgentTask,
AgentActivityBucket,
AgentRunCount,
diff --git a/packages/views/agents/components/agent-overview-pane.tsx b/packages/views/agents/components/agent-overview-pane.tsx
index 0d06231bb2..611a27b24e 100644
--- a/packages/views/agents/components/agent-overview-pane.tsx
+++ b/packages/views/agents/components/agent-overview-pane.tsx
@@ -164,7 +164,7 @@ export function AgentOverviewPane({
)}
{activeTab === "skills" && (
<TabContent>
- <SkillsTab agent={agent} runtime={runtime} />
+ <SkillsTab agent={agent} />
</TabContent>
)}
{activeTab === "env" && (
diff --git a/packages/views/agents/components/create-agent-dialog.test.tsx b/packages/views/agents/components/create-agent-dialog.test.tsx
index bf0c156df0..4117049063 100644
--- a/packages/views/agents/components/create-agent-dialog.test.tsx
+++ b/packages/views/agents/components/create-agent-dialog.test.tsx
@@ -261,49 +261,6 @@ describe("CreateAgentDialog runtime visibility gate", () => {
expect(onCreate.mock.calls[0]?.[0].runtime_id).toBe("rt-mine");
});
- it("renders the skills_local toggle when the selected runtime is claude", () => {
- const mine = makeRuntime({
- id: "rt-mine",
- name: "My Runtime",
- owner_id: ME,
- provider: "claude",
- });
- renderDialog([mine]);
-
- expect(
- screen.getByRole("switch", { name: /Allow locally installed skills/i }),
- ).toBeInTheDocument();
- });
-
- it("hides the skills_local toggle for runtimes that don't honour it", async () => {
- // Other providers either already isolate (no need for the toggle) or
- // currently ignore the field at exec time. Showing the toggle there
- // would mislead users into thinking it gates host-skill access for
- // their runtime. MUL-2603 follow-up.
- const copilot = makeRuntime({
- id: "rt-copilot",
- name: "Copilot Runtime",
- owner_id: ME,
- provider: "copilot",
- });
- const { onCreate } = renderDialog([copilot]);
-
- expect(
- screen.queryByRole("switch", {
- name: /Allow locally installed skills/i,
- }),
- ).not.toBeInTheDocument();
-
- // The payload must never carry skills_local for unsupported runtimes.
- fireEvent.change(screen.getByPlaceholderText(/Deep Research Agent/i), {
- target: { value: "Test" },
- });
- fireEvent.click(screen.getByText("Create"));
- await new Promise((r) => setTimeout(r, 0));
- expect(onCreate).toHaveBeenCalledTimes(1);
- expect(onCreate.mock.calls[0]?.[0].skills_local).toBeUndefined();
- });
-
it("disables Create when the selected runtime is locked (template + no usable fallback)", () => {
// Edge case: template points at a locked runtime AND the workspace
// has no usable alternatives in scope. The defense-in-depth gate on
diff --git a/packages/views/agents/components/create-agent-dialog.tsx b/packages/views/agents/components/create-agent-dialog.tsx
index 3ffadf5667..0b636993c4 100644
--- a/packages/views/agents/components/create-agent-dialog.tsx
+++ b/packages/views/agents/components/create-agent-dialog.tsx
@@ -7,14 +7,12 @@ import { ModelDropdown } from "./model-dropdown";
import { RuntimePicker, isRuntimeUsableForUser } from "./runtime-picker";
import { InstructionsEditor } from "./instructions-editor";
import { SkillMultiSelect } from "./skill-multi-select";
-import { SkillsLocalToggle } from "./skills-local-toggle";
import { AvatarPicker } from "./avatar-picker";
import { api } from "@multica/core/api";
import { useWorkspaceId } from "@multica/core/hooks";
import { workspaceKeys } from "@multica/core/workspace/queries";
import type {
Agent,
- AgentSkillsLocal,
AgentVisibility,
RuntimeDevice,
MemberWithUser,
@@ -36,7 +34,6 @@ import {
AGENT_DESCRIPTION_MAX_LENGTH,
VISIBILITY_DESCRIPTION,
VISIBILITY_LABEL,
- isSkillsLocalSupportedProvider,
} from "@multica/core/agents";
import { CharCounter } from "./char-counter";
import { useT } from "../../i18n";
@@ -95,13 +92,6 @@ export function CreateAgentDialog({
const [selectedSkillIds, setSelectedSkillIds] = useState<Set<string>>(
() => new Set(template?.skills.map((s) => s.id) ?? []),
);
- // Default to "merge" for new agents (matches the server-side default —
- // inherit-from-machine behavior preserved). Duplicate mode carries the
- // source agent's explicit "ignore" through so a hardened agent stays
- // hardened.
- const [skillsLocal, setSkillsLocal] = useState<AgentSkillsLocal>(
- () => (template?.skills_local === "ignore" ? "ignore" : "merge"),
- );
const [creating, setCreating] = useState(false);
// Duplicate-mode pre-fill: clone lands on the source agent's runtime so
@@ -127,13 +117,6 @@ export function CreateAgentDialog({
const selectedRuntimeLocked =
selectedRuntime != null &&
!isRuntimeUsableForUser(selectedRuntime, currentUserId);
- // The skills_local switch only has runtime support on claude / codex
- // today — everywhere else the field would be stored but ignored at
- // exec time, so the toggle is hidden to avoid implying behavior the
- // backend won't deliver. See MUL-2603.
- const skillsLocalApplies = isSkillsLocalSupportedProvider(
- selectedRuntime?.provider,
- );
// Shared squad-join follow-up. Returns nothing — the caller has
// already shown its create-success toast; we only need to surface a
@@ -179,15 +162,6 @@ export function CreateAgentDialog({
model: model.trim() || undefined,
instructions: trimmedInstructions || undefined,
avatar_url: avatarUrl ?? undefined,
- // Only send the toggle when the user opted into isolation AND the
- // selected runtime actually honours it (claude / codex today).
- // "merge" is the server-side default; omitting the field keeps the
- // request body small and prevents older backends without the
- // column from rejecting the request. Provider gating mirrors the
- // toggle visibility — we never persist a value the runtime would
- // ignore at exec time.
- skills_local:
- skillsLocalApplies && skillsLocal === "ignore" ? "ignore" : undefined,
};
if (template) {
// Duplicate path: forward the hidden config fields the source
@@ -385,14 +359,6 @@ export function CreateAgentDialog({
selectedIds={selectedSkillIds}
onChange={setSelectedSkillIds}
/>
-
- {skillsLocalApplies && (
- <SkillsLocalToggle
- value={skillsLocal}
- onChange={setSkillsLocal}
- hintScope="create"
- />
- )}
</div>
</div>
diff --git a/packages/views/agents/components/skills-local-toggle.tsx b/packages/views/agents/components/skills-local-toggle.tsx
deleted file mode 100644
index f5a02aa302..0000000000
--- a/packages/views/agents/components/skills-local-toggle.tsx
+++ /dev/null
@@ -1,67 +0,0 @@
-"use client";
-
-import type { AgentSkillsLocal } from "@multica/core/types";
-import { Label } from "@multica/ui/components/ui/label";
-import { Switch } from "@multica/ui/components/ui/switch";
-import { useT } from "../../i18n";
-
-// SkillsLocalToggle renders the per-agent "merge host-machine skills" switch
-// shared between the Create dialog (uncontrolled-by-network, only emits the
-// new value) and the edit tab (which immediately persists). The component
-// stays headless about save behavior — the parent decides what to do on
-// change. Section labels follow the create dialog `skills_section` keys so
-// both surfaces share identical copy.
-export function SkillsLocalToggle({
- value,
- onChange,
- disabled,
- hintScope = "create",
-}: {
- value: AgentSkillsLocal;
- onChange: (next: AgentSkillsLocal) => void;
- disabled?: boolean;
- /**
- * Picks the i18n namespace for the secondary hint copy. The create dialog
- * lives under `create_dialog.skills_section.local_*` while the edit tab
- * uses `tab_body.skills.local_*` — wording is intentionally identical
- * today but kept in two places so each surface can evolve independently.
- */
- hintScope?: "create" | "tab";
-}) {
- const { t } = useT("agents");
- const checked = value === "merge";
-
- const label =
- hintScope === "create"
- ? t(($) => $.create_dialog.skills_section.local_label)
- : t(($) => $.tab_body.skills.local_label);
- const hint = checked
- ? hintScope === "create"
- ? t(($) => $.create_dialog.skills_section.local_hint_on)
- : t(($) => $.tab_body.skills.local_hint_on)
- : hintScope === "create"
- ? t(($) => $.create_dialog.skills_section.local_hint_off)
- : t(($) => $.tab_body.skills.local_hint_off);
-
- return (
- <div className="rounded-md border border-border bg-muted/30 px-3 py-2.5">
- <div className="flex items-start justify-between gap-3">
- <Label
- htmlFor="skills-local-toggle"
- className="cursor-pointer text-sm font-medium leading-tight"
- >
- {label}
- </Label>
- <Switch
- id="skills-local-toggle"
- checked={checked}
- onCheckedChange={(next: boolean) => onChange(next ? "merge" : "ignore")}
- disabled={disabled}
- />
- </div>
- <p className="mt-1.5 text-xs leading-relaxed text-muted-foreground">
- {hint}
- </p>
- </div>
- );
-}
diff --git a/packages/views/agents/components/tabs/skills-tab.test.tsx b/packages/views/agents/components/tabs/skills-tab.test.tsx
index 8c216093fd..7e3eda8997 100644
--- a/packages/views/agents/components/tabs/skills-tab.test.tsx
+++ b/packages/views/agents/components/tabs/skills-tab.test.tsx
@@ -3,7 +3,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { render, screen } from "@testing-library/react";
-import type { Agent, AgentRuntime } from "@multica/core/types";
+import type { Agent } from "@multica/core/types";
import { I18nProvider } from "@multica/core/i18n/react";
import enCommon from "../../../locales/en/common.json";
import enAgents from "../../../locales/en/agents.json";
@@ -11,7 +11,6 @@ import enAgents from "../../../locales/en/agents.json";
const TEST_RESOURCES = { en: { common: enCommon, agents: enAgents } };
const mockListSkills = vi.hoisted(() => vi.fn());
-const mockUpdateAgent = vi.hoisted(() => vi.fn());
vi.mock("@multica/core/hooks", () => ({
useWorkspaceId: () => "ws-1",
@@ -21,7 +20,6 @@ vi.mock("@multica/core/api", () => ({
api: {
listSkills: (...args: unknown[]) => mockListSkills(...args),
setAgentSkills: vi.fn(),
- updateAgent: (...args: unknown[]) => mockUpdateAgent(...args),
},
}));
@@ -57,31 +55,7 @@ const agent: Agent = {
archived_by: null,
};
-function makeRuntime(overrides: Partial<AgentRuntime> = {}): AgentRuntime {
- return {
- id: "runtime-1",
- workspace_id: "ws-1",
- daemon_id: null,
- name: "Runtime",
- runtime_mode: "local",
- provider: "claude",
- launch_header: "",
- status: "online",
- device_info: "",
- metadata: {},
- owner_id: null,
- visibility: "public",
- last_seen_at: null,
- created_at: "2026-04-16T00:00:00Z",
- updated_at: "2026-04-16T00:00:00Z",
- ...overrides,
- };
-}
-
-function renderSkillsTab(
- overrides: Partial<Agent> = {},
- runtime: AgentRuntime | null = makeRuntime(),
-) {
+function renderSkillsTab() {
const queryClient = new QueryClient({
defaultOptions: {
queries: {
@@ -93,7 +67,7 @@ function renderSkillsTab(
return render(
<I18nProvider locale="en" resources={TEST_RESOURCES}>
<QueryClientProvider client={queryClient}>
- <SkillsTab agent={{ ...agent, ...overrides }} runtime={runtime} />
+ <SkillsTab agent={agent} />
</QueryClientProvider>
</I18nProvider>,
);
@@ -103,7 +77,6 @@ describe("SkillsTab", () => {
beforeEach(() => {
vi.clearAllMocks();
mockListSkills.mockResolvedValue([]);
- mockUpdateAgent.mockResolvedValue({});
});
it("does not render the inline Local Runtime Skills section even for local-runtime agents", async () => {
@@ -115,13 +88,9 @@ describe("SkillsTab", () => {
renderSkillsTab();
// Top informational callout should still render; that's how we know
- // the tab body itself rendered (not stuck in a loading state). The
- // toggle hint also includes the same phrase, so anchor on the intro
- // copy specifically.
+ // the tab body itself rendered (not stuck in a loading state).
expect(
- await screen.findByText(
- /Workspace skills assigned to this agent/i,
- ),
+ await screen.findByText(/Local runtime skills are always available/i),
).toBeInTheDocument();
// The removed section's heading and its trigger button must be gone.
@@ -129,70 +98,13 @@ describe("SkillsTab", () => {
expect(
screen.queryByRole("button", { name: /Import to Workspace/i }),
).not.toBeInTheDocument();
- });
-
- it("renders the local-skill toggle ON by default (merge — preserves inherit-from-machine behavior)", async () => {
- // Bohan's MUL-2603 product decision: keep the legacy "merge" default so
- // personal workflows that rely on locally installed Claude Skills keep
- // working unchanged. Owners flip the toggle off ("ignore") when they
- // explicitly need to harden a shared agent.
- renderSkillsTab();
-
- const toggle = await screen.findByRole("switch", {
- name: /Allow locally installed skills/i,
- });
- // Base UI Switch reflects state via data-state; aria-checked is the
- // accessible read.
- expect(toggle.getAttribute("aria-checked")).toBe("true");
- });
- it("reflects ignore mode when the agent opted into isolation", async () => {
- renderSkillsTab({ skills_local: "ignore" });
-
- const toggle = await screen.findByRole("switch", {
- name: /Allow locally installed skills/i,
- });
- expect(toggle.getAttribute("aria-checked")).toBe("false");
- });
-
- it("renders the toggle for Codex runtimes too", async () => {
- renderSkillsTab({}, makeRuntime({ provider: "codex" }));
-
- expect(
- await screen.findByRole("switch", {
- name: /Allow locally installed skills/i,
- }),
- ).toBeInTheDocument();
- });
-
- it("hides the toggle for runtimes that don't honour skills_local", async () => {
- // Only Claude and Codex runtimes actually enforce skills_local at exec
- // time today (MUL-2603); on every other provider the field would be
- // stored but ignored, so the toggle is suppressed to avoid implying
- // behaviour the runtime won't deliver.
- renderSkillsTab({}, makeRuntime({ provider: "copilot" }));
-
- // The rest of the tab still renders.
- expect(
- await screen.findByText(/Workspace skills assigned to this agent/i),
- ).toBeInTheDocument();
- expect(
- screen.queryByRole("switch", {
- name: /Allow locally installed skills/i,
- }),
- ).not.toBeInTheDocument();
- });
-
- it("hides the toggle when the runtime cannot be resolved", async () => {
- renderSkillsTab({}, null);
-
- expect(
- await screen.findByText(/Workspace skills assigned to this agent/i),
- ).toBeInTheDocument();
- expect(
- screen.queryByRole("switch", {
- name: /Allow locally installed skills/i,
- }),
- ).not.toBeInTheDocument();
+ // No runtime list / local-skills query should be wired up either —
+ // we removed @multica/core/runtimes from this file's imports.
+ // Surface it via behaviour: the `agent` here has runtime_id but the
+ // tab must not invoke any runtime-list mock to render. (Both are
+ // already deleted from the mock setup above; this assertion is
+ // implicit — the test file would fail to import if the component
+ // still referenced runtimeListOptions / runtimeLocalSkillsOptions.)
});
});
diff --git a/packages/views/agents/components/tabs/skills-tab.tsx b/packages/views/agents/components/tabs/skills-tab.tsx
index 4f8a6f7cad..8edcb6a45c 100644
--- a/packages/views/agents/components/tabs/skills-tab.tsx
+++ b/packages/views/agents/components/tabs/skills-tab.tsx
@@ -1,16 +1,11 @@
"use client";
import { useState } from "react";
-import { FileText, Plus, Trash2 } from "lucide-react";
+import { FileText, Info, Plus, Trash2 } from "lucide-react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { toast } from "sonner";
-import type {
- Agent,
- AgentRuntime,
- AgentSkillsLocal,
-} from "@multica/core/types";
+import type { Agent } from "@multica/core/types";
import { api } from "@multica/core/api";
-import { isSkillsLocalSupportedProvider } from "@multica/core/agents";
import { useWorkspaceId } from "@multica/core/hooks";
import {
skillListOptions,
@@ -18,33 +13,16 @@ import {
} from "@multica/core/workspace/queries";
import { Button } from "@multica/ui/components/ui/button";
import { SkillAddDialog } from "../skill-add-dialog";
-import { SkillsLocalToggle } from "../skills-local-toggle";
import { useT } from "../../../i18n";
export function SkillsTab({
agent,
- runtime,
}: {
agent: Agent;
- /**
- * The runtime this agent is bound to, if known. Used to decide whether
- * the host-skill merge toggle is meaningful for this agent — only Claude
- * and Codex runtimes honour `skills_local` today (MUL-2603). When the
- * runtime is missing (parent couldn't resolve it, e.g. it was deleted)
- * the toggle is hidden — there is no usable provider context to gate on.
- */
- runtime?: AgentRuntime | null;
}) {
const { t } = useT("agents");
const qc = useQueryClient();
const wsId = useWorkspaceId();
- // Default missing values to "merge". Older backends omit the field
- // entirely; the documented platform default wins on drift (see
- // AgentSkillsLocal — "ignore" is the explicit hardening opt-in).
- const currentSkillsLocal: AgentSkillsLocal =
- agent.skills_local === "ignore" ? "ignore" : "merge";
- const [skillsLocalSaving, setSkillsLocalSaving] = useState(false);
- const skillsLocalApplies = isSkillsLocalSupportedProvider(runtime?.provider);
// Same query the SkillAddDialog uses (TanStack Query dedupes by key, so
// this isn't an extra request) — used here only to grey out the "Add
// skill" button when the workspace has zero skills total. When skills
@@ -56,24 +34,6 @@ export function SkillsTab({
const [removing, setRemoving] = useState(false);
const [showAdd, setShowAdd] = useState(false);
- const handleSkillsLocalChange = async (next: AgentSkillsLocal) => {
- if (next === currentSkillsLocal || skillsLocalSaving) return;
- setSkillsLocalSaving(true);
- try {
- await api.updateAgent(agent.id, { skills_local: next });
- qc.invalidateQueries({ queryKey: workspaceKeys.agents(wsId) });
- toast.success(t(($) => $.tab_body.skills.local_saved_toast));
- } catch (e) {
- toast.error(
- e instanceof Error
- ? e.message
- : t(($) => $.tab_body.skills.local_save_failed_toast),
- );
- } finally {
- setSkillsLocalSaving(false);
- }
- };
-
const handleRemove = async (skillId: string) => {
setRemoving(true);
try {
@@ -91,7 +51,7 @@ export function SkillsTab({
return (
<div className="space-y-4">
- <div className="flex items-center justify-between gap-3">
+ <div className="flex items-start justify-between gap-3">
<p className="text-xs text-muted-foreground">
{t(($) => $.tab_body.skills.intro)}
</p>
@@ -107,15 +67,12 @@ export function SkillsTab({
</Button>
</div>
- {skillsLocalApplies && (
- <SkillsLocalToggle
- value={currentSkillsLocal}
- onChange={handleSkillsLocalChange}
- disabled={skillsLocalSaving}
- hintScope="tab"
- />
- )}
-
+ <div className="flex items-start gap-2 rounded-md border border-info/20 bg-info/5 px-3 py-2.5">
+ <Info className="mt-0.5 h-3.5 w-3.5 shrink-0 text-info" />
+ <p className="text-xs text-muted-foreground">
+ {t(($) => $.tab_body.skills.import_hint)}
+ </p>
+ </div>
{agent.skills.length === 0 ? (
<div className="flex flex-col items-center justify-center rounded-lg border border-dashed py-12">
diff --git a/packages/views/locales/en/agents.json b/packages/views/locales/en/agents.json
index 177c85376a..8587b3edbb 100644
--- a/packages/views/locales/en/agents.json
+++ b/packages/views/locales/en/agents.json
@@ -242,10 +242,7 @@
"list_loading": "Loading…",
"list_empty_default": "No skills available.",
"list_no_match": "No skills match.",
- "search_placeholder": "Search skills…",
- "local_label": "Allow locally installed skills",
- "local_hint_off": "Off — the agent ignores the host machine's user-global skill directory (~/.claude/skills/, ~/.codex/skills/). Recommended for shared agents — a broken local skill on one operator's machine cannot crash this agent. This control is shown only for Claude Code and Codex.",
- "local_hint_on": "On (default) — the host machine's user-global skill directory is merged alongside workspace skills. This control is shown only for Claude Code and Codex."
+ "search_placeholder": "Search skills…"
},
"avatar": {
"change_aria": "Change avatar",
@@ -298,13 +295,9 @@
"save_failed_toast": "Failed to save custom arguments"
},
"skills": {
- "intro": "Workspace skills assigned to this agent. Every runtime loads them.",
+ "intro": "Workspace skills assigned to this agent. Local runtime skills are always available automatically.",
"add_action": "Add skill",
- "local_label": "Allow locally installed skills",
- "local_hint_off": "Off — the agent ignores the host machine's user-global skill directory (~/.claude/skills/, ~/.codex/skills/). Recommended for shared agents — a broken local skill on one operator's machine cannot crash this agent. This control is shown only for Claude Code and Codex.",
- "local_hint_on": "On (default) — the host machine's user-global skill directory is merged alongside workspace skills. This control is shown only for Claude Code and Codex.",
- "local_saved_toast": "Skill merge setting saved",
- "local_save_failed_toast": "Failed to save skill merge setting",
+ "import_hint": "Importing creates a workspace copy that your team can edit and reuse.",
"empty_title": "No skills assigned",
"empty_hint": "Add workspace skills to share team knowledge with this agent.",
"remove_failed_toast": "Failed to remove skill",
diff --git a/packages/views/locales/zh-Hans/agents.json b/packages/views/locales/zh-Hans/agents.json
index 6db5e5249c..4b94e5a059 100644
--- a/packages/views/locales/zh-Hans/agents.json
+++ b/packages/views/locales/zh-Hans/agents.json
@@ -237,10 +237,7 @@
"list_loading": "加载中…",
"list_empty_default": "暂无 skill。",
"list_no_match": "没有匹配的 skill。",
- "search_placeholder": "搜索 skill…",
- "local_label": "允许使用本机已安装的 Skill",
- "local_hint_off": "关闭 —— 智能体会忽略本机用户级 skill 目录(~/.claude/skills/、~/.codex/skills/)。推荐用于共享智能体 —— 团队成员机器上有问题的本机 skill 不会拖崩这个智能体。该开关仅对 Claude Code 与 Codex 显示。",
- "local_hint_on": "开启(默认)—— 运行时会同时合并本机用户级 skill 目录。该开关仅对 Claude Code 与 Codex 显示。"
+ "search_placeholder": "搜索 skill…"
},
"avatar": {
"change_aria": "更换头像",
@@ -292,13 +289,9 @@
"save_failed_toast": "保存自定义参数失败"
},
"skills": {
- "intro": "分配给该智能体的工作区 skill。所有运行时都会加载。",
+ "intro": "分配给该智能体的工作区 skill。本地运行时 skill 会自动可用。",
"add_action": "添加 skill",
- "local_label": "允许使用本机已安装的 Skill",
- "local_hint_off": "关闭 —— 智能体会忽略本机用户级 skill 目录(~/.claude/skills/、~/.codex/skills/)。推荐用于共享智能体 —— 团队成员机器上有问题的本机 skill 不会拖崩这个智能体。该开关仅对 Claude Code 与 Codex 显示。",
- "local_hint_on": "开启(默认)—— 运行时会同时合并本机用户级 skill 目录。该开关仅对 Claude Code 与 Codex 显示。",
- "local_saved_toast": "已保存 Skill 合并设置",
- "local_save_failed_toast": "保存 Skill 合并设置失败",
+ "import_hint": "导入会在工作区创建一份副本,团队可以编辑和复用。",
"empty_title": "尚未分配 skill",
"empty_hint": "添加工作区 skill,把团队知识共享给这个智能体。",
"remove_failed_toast": "移除 skill 失败",
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index 848aa2f64e..0d8db5e63a 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -2285,17 +2285,12 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i
if provider == "openclaw" {
openclawBin = entry.Path
}
- envSkillsLocal := ""
- if task.Agent != nil {
- envSkillsLocal = task.Agent.SkillsLocal
- }
if task.PriorWorkDir != "" {
env = execenv.Reuse(execenv.ReuseParams{
WorkDir: task.PriorWorkDir,
Provider: provider,
CodexVersion: codexVersion,
OpenclawBin: openclawBin,
- SkillsLocal: envSkillsLocal,
Task: taskCtx,
}, d.logger)
}
@@ -2309,7 +2304,6 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i
Provider: provider,
CodexVersion: codexVersion,
OpenclawBin: openclawBin,
- SkillsLocal: envSkillsLocal,
Task: taskCtx,
}, d.logger)
if err != nil {
@@ -2496,10 +2490,6 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i
thinkingLevel = ""
}
}
- skillsLocal := ""
- if task.Agent != nil {
- skillsLocal = task.Agent.SkillsLocal
- }
execOpts := agent.ExecOptions{
Cwd: env.WorkDir,
Model: model,
@@ -2510,7 +2500,6 @@ func (d *Daemon) runTask(ctx context.Context, task Task, provider string, slot i
CustomArgs: customArgs,
McpConfig: mcpConfig,
ThinkingLevel: thinkingLevel,
- SkillsLocal: skillsLocal,
}
// Some providers do not reliably load the per-task runtime config files we
// write into the task workdir:
diff --git a/server/internal/daemon/execenv/execenv.go b/server/internal/daemon/execenv/execenv.go
index 89bcb50ea8..2e50921434 100644
--- a/server/internal/daemon/execenv/execenv.go
+++ b/server/internal/daemon/execenv/execenv.go
@@ -32,21 +32,14 @@ type ProjectResourceForEnv struct {
// PrepareParams holds all inputs needed to set up an execution environment.
type PrepareParams struct {
- WorkspacesRoot string // base path for all envs (e.g., ~/multica_workspaces)
- WorkspaceID string // workspace UUID — tasks are grouped under this
- TaskID string // task UUID — used for directory name
- AgentName string // for git branch naming only
- Provider string // agent provider (determines runtime config and skill injection paths)
- CodexVersion string // detected Codex CLI version (only used when Provider == "codex")
- OpenclawBin string // resolved openclaw CLI path (only used when Provider == "openclaw"); empty = look up on PATH
- // SkillsLocal mirrors agent.SkillsLocal. "ignore" instructs runtime
- // setup steps that the daemon controls (currently Codex's user-skill
- // seed) to skip injecting the host machine's user-global skills into
- // the per-task environment. Any other value — including "merge" and
- // the empty string from older servers / clients — preserves the
- // inherit-from-host behavior.
- SkillsLocal string
- Task TaskContextForEnv // context data for writing files
+ WorkspacesRoot string // base path for all envs (e.g., ~/multica_workspaces)
+ WorkspaceID string // workspace UUID — tasks are grouped under this
+ TaskID string // task UUID — used for directory name
+ AgentName string // for git branch naming only
+ Provider string // agent provider (determines runtime config and skill injection paths)
+ CodexVersion string // detected Codex CLI version (only used when Provider == "codex")
+ OpenclawBin string // resolved openclaw CLI path (only used when Provider == "openclaw"); empty = look up on PATH
+ Task TaskContextForEnv // context data for writing files
}
// TaskContextForEnv is the subset of task context used for writing context files.
@@ -182,7 +175,7 @@ func Prepare(params PrepareParams, logger *slog.Logger) (*Environment, error) {
if err := prepareCodexHomeWithOpts(codexHome, CodexHomeOptions{CodexVersion: params.CodexVersion}, logger); err != nil {
return nil, fmt.Errorf("execenv: prepare codex-home: %w", err)
}
- if err := hydrateCodexSkills(codexHome, params.Task.AgentSkills, params.SkillsLocal, logger); err != nil {
+ if err := hydrateCodexSkills(codexHome, params.Task.AgentSkills, logger); err != nil {
return nil, fmt.Errorf("execenv: hydrate codex skills: %w", err)
}
env.CodexHome = codexHome
@@ -213,14 +206,9 @@ func Prepare(params PrepareParams, logger *slog.Logger) (*Environment, error) {
type ReuseParams struct {
WorkDir string
Provider string
- CodexVersion string // only used when Provider == "codex"
- OpenclawBin string // only used when Provider == "openclaw"; empty = PATH lookup
- // SkillsLocal mirrors PrepareParams.SkillsLocal. Reuse must respect
- // the same gate so a workdir resurrected on a later task picks up the
- // current agent setting (the user may have flipped the toggle between
- // runs).
- SkillsLocal string
- Task TaskContextForEnv // refreshed context files / skills
+ CodexVersion string // only used when Provider == "codex"
+ OpenclawBin string // only used when Provider == "openclaw"; empty = PATH lookup
+ Task TaskContextForEnv // refreshed context files / skills
}
// Reuse wraps an existing workdir into an Environment and refreshes context files.
@@ -250,7 +238,7 @@ func Reuse(params ReuseParams, logger *slog.Logger) *Environment {
logger.Warn("execenv: refresh codex-home failed", "error", err)
} else {
env.CodexHome = codexHome
- if err := hydrateCodexSkills(codexHome, params.Task.AgentSkills, params.SkillsLocal, logger); err != nil {
+ if err := hydrateCodexSkills(codexHome, params.Task.AgentSkills, logger); err != nil {
logger.Warn("execenv: refresh codex skills failed", "error", err)
}
}
@@ -291,26 +279,17 @@ func Reuse(params ReuseParams, logger *slog.Logger) *Environment {
// run — its old contents would otherwise remain visible to the codex
// CLI.
//
-// When skillsLocal == "ignore" the user-skill seed is skipped, so the
-// per-task CODEX_HOME exposes only workspace skills to the codex CLI. This
-// is the Codex-side enforcement of the per-agent `skills_local` toggle —
-// the Claude backend enforces the same contract by mirroring `~/.claude/`
-// minus `skills/` (see server/pkg/agent/claude.go).
-//
-// Codex is the only runtime besides Claude where the daemon actively
-// manages user-skill discovery: Codex via CODEX_HOME and the seed step
-// here, Claude via CLAUDE_CONFIG_DIR scratch mirroring. Other runtimes
-// leave HOME untouched and discover user-level skills natively (see
-// context.go for the workdir-local paths they use for workspace skills),
-// so `skills_local` is a no-op for them today.
-func hydrateCodexSkills(codexHome string, workspaceSkills []SkillContextForEnv, skillsLocal string, logger *slog.Logger) error {
+// Codex is the only runtime that needs this two-stage hydration because the
+// daemon sets CODEX_HOME to a per-task directory, isolating the CLI from the
+// user's real ~/.codex/. Other runtimes leave HOME untouched and discover
+// user-level skills natively (see context.go for the workdir-local paths
+// they use for workspace skills).
+func hydrateCodexSkills(codexHome string, workspaceSkills []SkillContextForEnv, logger *slog.Logger) error {
skillsDir := filepath.Join(codexHome, "skills")
if err := os.RemoveAll(skillsDir); err != nil {
return fmt.Errorf("clear codex skills dir: %w", err)
}
- if skillsLocal == "ignore" {
- logger.Info("execenv: codex user-skill seed skipped (skills_local=ignore)")
- } else if err := seedUserCodexSkills(codexHome, workspaceSkills, logger); err != nil {
+ if err := seedUserCodexSkills(codexHome, workspaceSkills, logger); err != nil {
logger.Warn("execenv: seed user codex skills failed", "error", err)
}
if len(workspaceSkills) == 0 {
diff --git a/server/internal/daemon/execenv/execenv_test.go b/server/internal/daemon/execenv/execenv_test.go
index 332b946b31..d6f5fcccdf 100644
--- a/server/internal/daemon/execenv/execenv_test.go
+++ b/server/internal/daemon/execenv/execenv_test.go
@@ -2650,145 +2650,6 @@ func TestPrepareCodexResolvesUserSkillSymlinks(t *testing.T) {
}
}
-// TestPrepareCodexSkillsLocalIgnoreSkipsUserSeed covers the per-agent
-// `skills_local=ignore` contract on the Codex side (MUL-2603): when the
-// agent opts out of host-machine skills, the daemon must not seed
-// `~/.codex/skills/` into the per-task CODEX_HOME, so a broken local skill
-// cannot crash a shared Codex agent. The default (`merge`) preserves the
-// pre-existing seed-from-shared behavior — covered by
-// TestPrepareCodexSeedsUserSkills above.
-func TestPrepareCodexSkillsLocalIgnoreSkipsUserSeed(t *testing.T) {
- // Cannot use t.Parallel() with t.Setenv.
-
- sharedHome := t.TempDir()
- t.Setenv("CODEX_HOME", sharedHome)
-
- userSkills := filepath.Join(sharedHome, "skills")
- if err := os.MkdirAll(filepath.Join(userSkills, "summarize"), 0o755); err != nil {
- t.Fatalf("seed user skill dir: %v", err)
- }
- if err := os.WriteFile(filepath.Join(userSkills, "summarize", "SKILL.md"), []byte("user summarize"), 0o644); err != nil {
- t.Fatalf("seed user SKILL.md: %v", err)
- }
-
- env, err := Prepare(PrepareParams{
- WorkspacesRoot: t.TempDir(),
- WorkspaceID: "ws-codex-skills-local-ignore",
- TaskID: "c1d2e3f4-a5b6-7890-cdef-123456789012",
- AgentName: "Codex Agent",
- Provider: "codex",
- SkillsLocal: "ignore",
- Task: TaskContextForEnv{
- IssueID: "codex-skills-local-ignore-test",
- AgentSkills: []SkillContextForEnv{
- {Name: "Writing", Content: "workspace writing"},
- },
- },
- }, testLogger())
- if err != nil {
- t.Fatalf("Prepare failed: %v", err)
- }
- defer env.Cleanup(true)
-
- if _, err := os.Stat(filepath.Join(env.CodexHome, "skills", "summarize")); !os.IsNotExist(err) {
- t.Errorf("user skill seeded despite skills_local=ignore: err=%v", err)
- }
- if _, err := os.Stat(filepath.Join(env.CodexHome, "skills", "writing", "SKILL.md")); err != nil {
- t.Errorf("workspace skill not written under skills_local=ignore: %v", err)
- }
-}
-
-// TestPrepareCodexSkillsLocalMergeSeedsUserSkills locks in the default
-// `merge` semantics on the Codex side: anything other than the literal
-// "ignore" (including empty from older servers) preserves the seed-from-
-// shared behavior so existing personal workflows continue working.
-func TestPrepareCodexSkillsLocalMergeSeedsUserSkills(t *testing.T) {
- // Cannot use t.Parallel() with t.Setenv.
-
- sharedHome := t.TempDir()
- t.Setenv("CODEX_HOME", sharedHome)
-
- userSkills := filepath.Join(sharedHome, "skills")
- if err := os.MkdirAll(filepath.Join(userSkills, "translate"), 0o755); err != nil {
- t.Fatalf("seed user skill dir: %v", err)
- }
- if err := os.WriteFile(filepath.Join(userSkills, "translate", "SKILL.md"), []byte("user translate"), 0o644); err != nil {
- t.Fatalf("seed user SKILL.md: %v", err)
- }
-
- env, err := Prepare(PrepareParams{
- WorkspacesRoot: t.TempDir(),
- WorkspaceID: "ws-codex-skills-local-merge",
- TaskID: "d2e3f4a5-b6c7-8901-cdef-234567890123",
- AgentName: "Codex Agent",
- Provider: "codex",
- SkillsLocal: "merge",
- Task: TaskContextForEnv{IssueID: "codex-skills-local-merge-test"},
- }, testLogger())
- if err != nil {
- t.Fatalf("Prepare failed: %v", err)
- }
- defer env.Cleanup(true)
-
- data, err := os.ReadFile(filepath.Join(env.CodexHome, "skills", "translate", "SKILL.md"))
- if err != nil {
- t.Fatalf("user skill not seeded under skills_local=merge: %v", err)
- }
- if string(data) != "user translate" {
- t.Errorf("seeded user SKILL.md = %q, want %q", data, "user translate")
- }
-}
-
-// TestReuseCodexSkillsLocalIgnoreSkipsUserSeed mirrors the Prepare path on
-// the Reuse branch: if a user flips the agent toggle to `ignore` between
-// runs, the next task on the reused workdir must drop the previously-seeded
-// user skill rather than leak it through.
-func TestReuseCodexSkillsLocalIgnoreSkipsUserSeed(t *testing.T) {
- // Cannot use t.Parallel() with t.Setenv.
-
- sharedHome := t.TempDir()
- t.Setenv("CODEX_HOME", sharedHome)
-
- userSkills := filepath.Join(sharedHome, "skills")
- if err := os.MkdirAll(filepath.Join(userSkills, "summarize"), 0o755); err != nil {
- t.Fatalf("seed user skill dir: %v", err)
- }
- if err := os.WriteFile(filepath.Join(userSkills, "summarize", "SKILL.md"), []byte("user summarize"), 0o644); err != nil {
- t.Fatalf("seed user SKILL.md: %v", err)
- }
-
- env, err := Prepare(PrepareParams{
- WorkspacesRoot: t.TempDir(),
- WorkspaceID: "ws-codex-reuse-toggle",
- TaskID: "e3f4a5b6-c7d8-9012-cdef-345678901234",
- AgentName: "Codex Agent",
- Provider: "codex",
- SkillsLocal: "merge",
- Task: TaskContextForEnv{IssueID: "codex-reuse-toggle-test"},
- }, testLogger())
- if err != nil {
- t.Fatalf("Prepare failed: %v", err)
- }
- defer env.Cleanup(true)
-
- if _, err := os.Stat(filepath.Join(env.CodexHome, "skills", "summarize", "SKILL.md")); err != nil {
- t.Fatalf("Prepare(merge) did not seed user skill: %v", err)
- }
-
- reused := Reuse(ReuseParams{
- WorkDir: env.WorkDir,
- Provider: "codex",
- SkillsLocal: "ignore",
- Task: TaskContextForEnv{IssueID: "codex-reuse-toggle-test"},
- }, testLogger())
- if reused == nil {
- t.Fatal("Reuse returned nil")
- }
- if _, err := os.Stat(filepath.Join(reused.CodexHome, "skills", "summarize")); !os.IsNotExist(err) {
- t.Errorf("user skill survived Reuse(skills_local=ignore): err=%v", err)
- }
-}
-
// TestReuseSeedsUserSkillUpdates ensures that user-skill edits between two
// runs of the same task (the Reuse path) propagate into the per-task home.
func TestReuseSeedsUserSkillUpdates(t *testing.T) {
diff --git a/server/internal/daemon/types.go b/server/internal/daemon/types.go
index 75202d2155..897576dc71 100644
--- a/server/internal/daemon/types.go
+++ b/server/internal/daemon/types.go
@@ -105,18 +105,6 @@ type AgentData struct {
McpConfig json.RawMessage `json:"mcp_config,omitempty"`
Model string `json:"model,omitempty"`
ThinkingLevel string `json:"thinking_level,omitempty"`
- // SkillsLocal controls whether the runtime merges the host machine's
- // user-global skill directory into the agent. "merge" (default)
- // preserves the inherit-from-machine behavior; "ignore" hides the
- // directory from the runtime so a broken local skill cannot crash a
- // shared agent (#3052). Old servers that predate the column omit this
- // field entirely; the daemon treats empty as "merge". Currently
- // honoured by Claude (via CLAUDE_CONFIG_DIR scratch mirroring in
- // server/pkg/agent/claude.go) and Codex (via the user-skill seed gate
- // in server/internal/daemon/execenv/execenv.go); other runtimes leave
- // HOME untouched and natively discover user-level skills, so the
- // toggle is a no-op for them.
- SkillsLocal string `json:"skills_local,omitempty"`
}
// SkillData represents a structured skill for task execution.
diff --git a/server/internal/handler/agent.go b/server/internal/handler/agent.go
index 09e546d6b1..9b7f96a1b3 100644
--- a/server/internal/handler/agent.go
+++ b/server/internal/handler/agent.go
@@ -56,15 +56,8 @@ type AgentResponse struct {
// ThinkingLevel is the runtime-native reasoning/effort token persisted
// for this agent (empty = use runtime default). The picker is per-runtime
// per-model; the API never normalizes across providers. See MUL-2339.
- ThinkingLevel string `json:"thinking_level"`
- // SkillsLocal controls whether the runtime merges the host machine's
- // user-global skill directory (e.g. Claude's `~/.claude/skills/`) into
- // the agent's skill set. "merge" (default) preserves the pre-existing
- // inherit-from-machine behavior; "ignore" isolates the runtime so a
- // broken local skill cannot crash a shared agent (#3052). Workspace
- // skills (`{workDir}/.claude/skills/`) are always loaded regardless.
- SkillsLocal string `json:"skills_local"`
- OwnerID *string `json:"owner_id"`
+ ThinkingLevel string `json:"thinking_level"`
+ OwnerID *string `json:"owner_id"`
Skills []AgentSkillSummary `json:"skills"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
@@ -129,7 +122,6 @@ func agentToResponse(a db.Agent) AgentResponse {
MaxConcurrentTasks: a.MaxConcurrentTasks,
Model: a.Model.String,
ThinkingLevel: a.ThinkingLevel.String,
- SkillsLocal: normalizeSkillsLocal(a.SkillsLocal),
OwnerID: uuidToPtr(a.OwnerID),
Skills: []AgentSkillSummary{},
CreatedAt: timestampToString(a.CreatedAt),
@@ -253,11 +245,6 @@ type TaskAgentData struct {
McpConfig json.RawMessage `json:"mcp_config,omitempty"`
Model string `json:"model,omitempty"`
ThinkingLevel string `json:"thinking_level,omitempty"`
- // SkillsLocal mirrors the agent column of the same name. Daemon reads
- // it to decide whether to isolate the Claude runtime from the host's
- // user-global `~/.claude/skills/`. Empty string is treated as the
- // platform default ("merge") by the daemon — see normalizeSkillsLocal.
- SkillsLocal string `json:"skills_local,omitempty"`
}
func taskToResponse(t db.AgentTaskQueue) AgentTaskResponse {
@@ -475,11 +462,6 @@ type CreateAgentRequest struct {
MaxConcurrentTasks int32 `json:"max_concurrent_tasks"`
Model string `json:"model"`
ThinkingLevel string `json:"thinking_level"`
- // SkillsLocal opts the agent into ("merge") or out of ("ignore") the
- // runtime's user-global skill discovery. Empty / missing defaults to
- // "merge". Validated in CreateAgent / UpdateAgent against the
- // recognised set; anything else returns 400.
- SkillsLocal string `json:"skills_local"`
// Template records which template slug was used to seed this agent
// (e.g. "coding" / "planning" / "writing" / "assistant"). Empty when
// the caller didn't come from a template picker — the `agent_created`
@@ -579,21 +561,6 @@ func (h *Handler) CreateAgent(w http.ResponseWriter, r *http.Request) {
return
}
- // Request validation is strict: a missing field defaults to "merge" (the
- // pre-MUL-2603 inherit-from-machine behavior), but a present-but-bogus
- // value must 400 rather than silently normalize. The drift-safe normalize
- // is only for on-read coercion of stored values (normalizeSkillsLocal) —
- // applying it to request input would mask client typos as a successful
- // create.
- skillsLocal := "merge"
- if req.SkillsLocal != "" {
- if !isValidSkillsLocal(req.SkillsLocal) {
- writeError(w, http.StatusBadRequest, fmt.Sprintf("skills_local %q is invalid (expected \"ignore\" or \"merge\")", req.SkillsLocal))
- return
- }
- skillsLocal = req.SkillsLocal
- }
-
// Probe workspace agent count BEFORE the insert so the funnel has a
// clean "first agent ever in this workspace" signal — Step 4 of
// onboarding always lands in this branch. A non-fatal read: if the
@@ -641,7 +608,6 @@ func (h *Handler) CreateAgent(w http.ResponseWriter, r *http.Request) {
McpConfig: mc,
Model: pgtype.Text{String: req.Model, Valid: req.Model != ""},
ThinkingLevel: pgtype.Text{String: req.ThinkingLevel, Valid: req.ThinkingLevel != ""},
- SkillsLocal: skillsLocal,
})
if err != nil {
// Unique constraint on (workspace_id, name) — return a clear conflict error
@@ -709,31 +675,6 @@ type UpdateAgentRequest struct {
// Distinguishing those modes is why this is a pointer; the raw-fields
// map captured at decode time tells us whether the key was sent.
ThinkingLevel *string `json:"thinking_level"`
- // SkillsLocal: nil means "no change"; non-nil overrides the stored
- // value after validation. We use a pointer (rather than the empty
- // string sentinel ThinkingLevel uses) because there is no "clear"
- // state — the column has a NOT NULL default and the toggle is binary.
- SkillsLocal *string `json:"skills_local"`
-}
-
-// normalizeSkillsLocal coerces empty / unknown stored values to the platform
-// default "merge" — the pre-MUL-2603 inherit-from-machine behavior. Older
-// rows written before the column existed get a NOT NULL default at migration
-// time, but the helper still guards against any future schema drift or
-// hand-edited rows so we never surface an in-between state to clients or the
-// daemon.
-func normalizeSkillsLocal(stored string) string {
- if stored == "ignore" {
- return "ignore"
- }
- return "merge"
-}
-
-// isValidSkillsLocal mirrors the CHECK constraint on agent.skills_local.
-// The DB would reject a write with a 23514 violation anyway, but pre-flight
-// validation lets the API return a clean 400 with the offending value.
-func isValidSkillsLocal(v string) bool {
- return v == "ignore" || v == "merge"
}
// workspaceAlwaysRedactSecrets reports whether the workspace has opted
@@ -935,17 +876,6 @@ func (h *Handler) UpdateAgent(w http.ResponseWriter, r *http.Request) {
if req.Model != nil {
params.Model = pgtype.Text{String: *req.Model, Valid: true}
}
- if req.SkillsLocal != nil {
- // PATCH is strictly opt-in: nil means no change. A non-nil value must
- // validate as-is — normalizing here would let garbage silently land as
- // "merge" and hide a client bug. The drift-safe coercion lives in
- // normalizeSkillsLocal for on-read use only.
- if !isValidSkillsLocal(*req.SkillsLocal) {
- writeError(w, http.StatusBadRequest, fmt.Sprintf("skills_local %q is invalid (expected \"ignore\" or \"merge\")", *req.SkillsLocal))
- return
- }
- params.SkillsLocal = pgtype.Text{String: *req.SkillsLocal, Valid: true}
- }
// thinking_level handling (MUL-2339). Tri-state semantics:
// - field omitted → leave column alone (COALESCE narg), but if a
diff --git a/server/internal/handler/agent_skills_local_test.go b/server/internal/handler/agent_skills_local_test.go
deleted file mode 100644
index fbaa8f3441..0000000000
--- a/server/internal/handler/agent_skills_local_test.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package handler
-
-import (
- "context"
- "encoding/json"
- "net/http"
- "net/http/httptest"
- "testing"
-)
-
-// TestCreateAgent_SkillsLocal_Validation pins the contract for the
-// per-agent host-skill merge switch added with MUL-2603 / GitHub #3052:
-//
-// - Field omitted → platform default "merge" is persisted (preserves the
-// pre-MUL-2603 inherit-from-machine behavior so existing personal
-// workflows that rely on locally installed skills keep working).
-// - "ignore" / "merge" → accepted and round-tripped.
-// - Any other value → 400 BadRequest. The DB CHECK would catch it as a
-// 500 fallback, but we want a clean error for clients.
-func TestCreateAgent_SkillsLocal_Validation(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- claudeRuntimeID := createClaudeProviderRuntime(t)
-
- t.Cleanup(func() {
- testPool.Exec(ctx,
- `DELETE FROM agent WHERE workspace_id = $1 AND name LIKE 'skills-local-test-%'`,
- testWorkspaceID,
- )
- })
-
- t.Run("omitted defaults to merge", func(t *testing.T) {
- body := map[string]any{
- "name": "skills-local-test-default",
- "runtime_id": claudeRuntimeID,
- "visibility": "private",
- "max_concurrent_tasks": 1,
- }
- w := httptest.NewRecorder()
- testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
- if w.Code != http.StatusCreated {
- t.Fatalf("default skills_local: expected 201, got %d: %s", w.Code, w.Body.String())
- }
- var resp map[string]any
- _ = json.NewDecoder(w.Body).Decode(&resp)
- if resp["skills_local"] != "merge" {
- t.Errorf("expected skills_local=merge (platform default), got %v", resp["skills_local"])
- }
- })
-
- t.Run("explicit ignore round-trips", func(t *testing.T) {
- body := map[string]any{
- "name": "skills-local-test-ignore",
- "runtime_id": claudeRuntimeID,
- "visibility": "private",
- "max_concurrent_tasks": 1,
- "skills_local": "ignore",
- }
- w := httptest.NewRecorder()
- testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
- if w.Code != http.StatusCreated {
- t.Fatalf("skills_local=ignore: expected 201, got %d: %s", w.Code, w.Body.String())
- }
- var resp map[string]any
- _ = json.NewDecoder(w.Body).Decode(&resp)
- if resp["skills_local"] != "ignore" {
- t.Errorf("expected skills_local=ignore, got %v", resp["skills_local"])
- }
- })
-
- t.Run("garbage value rejected with 400", func(t *testing.T) {
- body := map[string]any{
- "name": "skills-local-test-garbage",
- "runtime_id": claudeRuntimeID,
- "visibility": "private",
- "max_concurrent_tasks": 1,
- "skills_local": "yes-please",
- }
- w := httptest.NewRecorder()
- testHandler.CreateAgent(w, newRequest(http.MethodPost, "/api/agents", body))
- if w.Code != http.StatusBadRequest {
- t.Fatalf("garbage skills_local: expected 400, got %d: %s", w.Code, w.Body.String())
- }
- })
-}
-
-// TestUpdateAgent_SkillsLocal_Tristate covers PATCH semantics: nil
-// pointer means "no change", non-nil overrides after validation. Unlike
-// thinking_level there is no "clear" mode — the column is NOT NULL.
-func TestUpdateAgent_SkillsLocal_Tristate(t *testing.T) {
- if testHandler == nil {
- t.Skip("database not available")
- }
-
- ctx := context.Background()
- claudeRuntimeID := createClaudeProviderRuntime(t)
- agentID := createAgentOnRuntime(t, "skills-local-update-test", claudeRuntimeID, "")
- // Demote the seed row to "ignore" so we can verify both omit (preserve
- // ignore) and explicit-flip-back (set merge) paths.
- if _, err := testPool.Exec(ctx, `UPDATE agent SET skills_local = 'ignore' WHERE id = $1`, agentID); err != nil {
- t.Fatalf("seed skills_local=ignore: %v", err)
- }
-
- t.Cleanup(func() {
- testPool.Exec(ctx, `DELETE FROM agent WHERE id = $1`, agentID)
- })
-
- t.Run("omitted preserves existing value", func(t *testing.T) {
- body := map[string]any{
- "name": "skills-local-update-test-renamed",
- }
- w := httptest.NewRecorder()
- req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
- testHandler.UpdateAgent(w, req)
- if w.Code != http.StatusOK {
- t.Fatalf("name-only update: expected 200, got %d: %s", w.Code, w.Body.String())
- }
- var resp map[string]any
- _ = json.NewDecoder(w.Body).Decode(&resp)
- if resp["skills_local"] != "ignore" {
- t.Errorf("name-only update silently changed skills_local: got %v, want ignore", resp["skills_local"])
- }
- })
-
- t.Run("explicit merge flips back", func(t *testing.T) {
- body := map[string]any{
- "skills_local": "merge",
- }
- w := httptest.NewRecorder()
- req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
- testHandler.UpdateAgent(w, req)
- if w.Code != http.StatusOK {
- t.Fatalf("update skills_local=merge: expected 200, got %d: %s", w.Code, w.Body.String())
- }
- var resp map[string]any
- _ = json.NewDecoder(w.Body).Decode(&resp)
- if resp["skills_local"] != "merge" {
- t.Errorf("expected skills_local=merge after update, got %v", resp["skills_local"])
- }
- })
-
- t.Run("garbage value is 400 not silent default", func(t *testing.T) {
- body := map[string]any{
- "skills_local": "all-of-them",
- }
- w := httptest.NewRecorder()
- req := withURLParam(newRequest(http.MethodPatch, "/api/agents/"+agentID, body), "id", agentID)
- testHandler.UpdateAgent(w, req)
- if w.Code != http.StatusBadRequest {
- t.Fatalf("garbage skills_local: expected 400, got %d: %s", w.Code, w.Body.String())
- }
- })
-}
-
-// TestNormalizeSkillsLocal_DriftStaysSafe is a unit-level safety net for
-// the on-read coercion: if a row gets written with anything other than
-// the two recognised values (hand edits, future schema drift, older
-// daemons sending up garbage), the API must surface "merge" — the
-// platform default — never leak an indeterminate value to clients or the
-// daemon. Only the exact literal "ignore" maps to ignore; anything else
-// coerces to the documented default.
-func TestNormalizeSkillsLocal_DriftStaysSafe(t *testing.T) {
- cases := []struct {
- stored string
- want string
- }{
- {"", "merge"},
- {"ignore", "ignore"},
- {"merge", "merge"},
- {"IGNORE", "merge"}, // case-sensitive — drift falls back to platform default
- {"yes", "merge"},
- {"true", "merge"},
- }
- for _, c := range cases {
- if got := normalizeSkillsLocal(c.stored); got != c.want {
- t.Errorf("normalizeSkillsLocal(%q) = %q, want %q", c.stored, got, c.want)
- }
- }
-}
diff --git a/server/internal/handler/agent_template.go b/server/internal/handler/agent_template.go
index d82ee1ebb5..68a82a20d0 100644
--- a/server/internal/handler/agent_template.go
+++ b/server/internal/handler/agent_template.go
@@ -446,10 +446,6 @@ func (h *Handler) CreateAgentFromTemplate(w http.ResponseWriter, r *http.Request
CustomArgs: ca,
McpConfig: nil,
Model: pgtype.Text{String: req.Model, Valid: req.Model != ""},
- // skills_local has a NOT NULL CHECK ('ignore' | 'merge'); the Go zero
- // value "" would fail the constraint instead of falling back to the
- // column default. Match the public CreateAgent default explicitly.
- SkillsLocal: "merge",
})
if err != nil {
// Mirror handler/agent.go:CreateAgent: when the duplicate is the
diff --git a/server/internal/handler/daemon.go b/server/internal/handler/daemon.go
index d97ae8e674..6883ff1bcd 100644
--- a/server/internal/handler/daemon.go
+++ b/server/internal/handler/daemon.go
@@ -1124,7 +1124,6 @@ func (h *Handler) ClaimTaskByRuntime(w http.ResponseWriter, r *http.Request) {
McpConfig: mcpConfig,
Model: agent.Model.String,
ThinkingLevel: agent.ThinkingLevel.String,
- SkillsLocal: normalizeSkillsLocal(agent.SkillsLocal),
}
}
diff --git a/server/internal/handler/onboarding_shim.go b/server/internal/handler/onboarding_shim.go
index 31e8b35461..fc075bf978 100644
--- a/server/internal/handler/onboarding_shim.go
+++ b/server/internal/handler/onboarding_shim.go
@@ -227,10 +227,6 @@ func (h *Handler) BootstrapOnboardingRuntime(w http.ResponseWriter, r *http.Requ
CustomArgs: []byte("[]"),
McpConfig: nil,
Model: pgtype.Text{},
- // skills_local has a NOT NULL CHECK ('ignore' | 'merge'); the Go
- // zero value "" would trip the constraint rather than fall back to
- // the column default. Match the public CreateAgent default.
- SkillsLocal: "merge",
})
if err != nil {
slog.Warn("bootstrap onboarding (shim): create assistant failed", append(logger.RequestAttrs(r), "error", err, "workspace_id", req.WorkspaceID)...)
diff --git a/server/migrations/108_agent_skills_local.down.sql b/server/migrations/108_agent_skills_local.down.sql
deleted file mode 100644
index 2e023a3a7d..0000000000
--- a/server/migrations/108_agent_skills_local.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE agent DROP COLUMN skills_local;
diff --git a/server/migrations/108_agent_skills_local.up.sql b/server/migrations/108_agent_skills_local.up.sql
deleted file mode 100644
index d1ca4d7b42..0000000000
--- a/server/migrations/108_agent_skills_local.up.sql
+++ /dev/null
@@ -1,12 +0,0 @@
--- Per-agent switch controlling whether the Claude runtime merges the host
--- machine's `~/.claude/skills/` into the agent's skill set. 'merge' (default)
--- preserves the pre-existing inherit-from-machine behavior so existing
--- workflows that rely on locally installed skills keep working. 'ignore'
--- isolates the runtime so a broken local skill on one operator's machine
--- cannot silently crash a shared agent (GitHub #3052 — Claude exits before
--- reading stdin, leaving the daemon with "broken pipe"). Workspace skills
--- (`{workDir}/.claude/skills/`) are always loaded — the toggle only governs
--- the user-global directory.
-ALTER TABLE agent
- ADD COLUMN skills_local TEXT NOT NULL DEFAULT 'merge'
- CHECK (skills_local IN ('ignore', 'merge'));
diff --git a/server/migrations/109_drop_agent_skills_local.down.sql b/server/migrations/109_drop_agent_skills_local.down.sql
new file mode 100644
index 0000000000..67e0e24e3f
--- /dev/null
+++ b/server/migrations/109_drop_agent_skills_local.down.sql
@@ -0,0 +1,3 @@
+-- Intentionally empty. The local skill toggle was reverted before release, so
+-- rolling this cleanup back should only remove the schema_migrations row; it
+-- should not recreate an unused column or invent values for it.
diff --git a/server/migrations/109_drop_agent_skills_local.up.sql b/server/migrations/109_drop_agent_skills_local.up.sql
new file mode 100644
index 0000000000..5b45707484
--- /dev/null
+++ b/server/migrations/109_drop_agent_skills_local.up.sql
@@ -0,0 +1,4 @@
+-- Clean up the unreleased per-agent local skill toggle. Fresh/prod databases
+-- that never applied 108_agent_skills_local are unchanged, while dev/staging
+-- databases that tested it converge back to the reverted schema.
+ALTER TABLE agent DROP COLUMN IF EXISTS skills_local;
diff --git a/server/pkg/agent/agent.go b/server/pkg/agent/agent.go
index f07bc95e1c..9a08ea1bd6 100644
--- a/server/pkg/agent/agent.go
+++ b/server/pkg/agent/agent.go
@@ -44,19 +44,6 @@ type ExecOptions struct {
// field rather than fail (so MUL-2339 can grow runtime support
// incrementally without breaking unrelated agents).
ThinkingLevel string
- // SkillsLocal opts the runtime into ("merge") or out of ("ignore") the
- // host machine's user-global skill directory. Honoured by the Claude
- // backend in this package — "merge" (platform default; anything other
- // than "ignore") preserves the inherit-from-machine behavior so the
- // CLI walks `~/.claude/` directly, and "ignore" redirects
- // CLAUDE_CONFIG_DIR to an isolated per-task scratch dir so the CLI
- // never reads `~/.claude/skills/` (used to harden shared agents
- // against broken host skills — GitHub #3052). Codex enforces the same
- // contract one layer up in the daemon: `execenv.hydrateCodexSkills`
- // skips the `~/.codex/skills/` seed when this value is "ignore", so
- // the per-task CODEX_HOME exposes only workspace skills. Other
- // backends ignore this option today (no-op).
- SkillsLocal string
}
// Session represents a running agent execution.
diff --git a/server/pkg/agent/claude.go b/server/pkg/agent/claude.go
index 7f4046a1b9..2a73ef2545 100644
--- a/server/pkg/agent/claude.go
+++ b/server/pkg/agent/claude.go
@@ -10,7 +10,6 @@ import (
"log/slog"
"os"
"os/exec"
- "path/filepath"
"strings"
"time"
)
@@ -67,57 +66,7 @@ func (b *claudeBackend) Execute(ctx context.Context, prompt string, opts ExecOpt
if opts.Cwd != "" {
cmd.Dir = opts.Cwd
}
-
- // Skill isolation. The platform default is "merge" — the CLI walks
- // `~/.claude/` directly, including its `skills/`, so existing personal
- // workflows that rely on locally installed Claude skills keep working
- // out of the box. The agent owner can opt into "ignore" when a shared
- // agent must be hardened against a broken local skill on one operator's
- // machine, which otherwise crashes the CLI before it reads stdin
- // (GitHub #3052: silent "broken pipe" exits).
- //
- // In "ignore" mode we point CLAUDE_CONFIG_DIR at a per-run scratch dir
- // that mirrors `~/.claude/` as symlinks — except for `skills/`, which
- // is omitted so the CLI cannot discover the host user's
- // `~/.claude/skills/`. Everything else under `~/.claude/` — including
- // the Linux/Windows `.credentials.json` login token, `settings.json`,
- // `agents/`, `commands/`, `plugins/`, etc. — is symlinked through so
- // Claude authentication and global config keep working without an
- // `ANTHROPIC_API_KEY`. Workspace skills (`{cwd}/.claude/skills/`) load
- // from cwd regardless and are not affected by either mode.
- isolateClaudeConfig := opts.SkillsLocal == "ignore"
- var claudeConfigDir string
- var hostConfigDir string
- var claudeConfigCleanup func()
- if isolateClaudeConfig {
- // Resolve the *effective* Claude config source before we strip
- // CLAUDE_CONFIG_DIR from the child env in buildClaudeEnv.
- // Precedence: agent custom_env > parent process env > `~/.claude`.
- // Mirroring `~/.claude` blindly when the operator has explicitly
- // pointed Claude at a different config dir (e.g. a managed install)
- // would copy the wrong credentials into the scratch dir and break
- // auth — see the second Must Fix in MUL-2603 review. The same
- // value is threaded through to buildClaudeEnv so the macOS keychain
- // passthrough can refuse to inject the default OAuth token into a
- // custom-dir isolated child (the unsuffixed keychain entry does not
- // match the suffixed entry a custom CLAUDE_CONFIG_DIR would resolve
- // to, so reading it would inject a different account's token).
- hostConfigDir = resolveHostClaudeConfigDir(b.cfg.Env)
- dir, cleanup, err := newIsolatedClaudeConfigDir(opts.Cwd, hostConfigDir, b.cfg.Logger)
- if err != nil {
- cancel()
- return nil, fmt.Errorf("isolate claude config dir: %w", err)
- }
- claudeConfigDir = dir
- claudeConfigCleanup = cleanup
- }
- defer func() {
- if claudeConfigCleanup != nil {
- claudeConfigCleanup()
- }
- }()
-
- cmd.Env = buildClaudeEnv(b.cfg.Env, claudeConfigDir, hostConfigDir, b.cfg.Logger)
+ cmd.Env = buildEnv(b.cfg.Env)
stdout, err := cmd.StdoutPipe()
if err != nil {
@@ -162,14 +111,10 @@ func (b *claudeBackend) Execute(ctx context.Context, prompt string, opts ExecOpt
}
closeStdin()
- b.cfg.Logger.Info("claude started", "pid", cmd.Process.Pid, "cwd", opts.Cwd, "model", opts.Model, "skills_local", opts.SkillsLocal, "claude_config_dir", claudeConfigDir)
+ b.cfg.Logger.Info("claude started", "pid", cmd.Process.Pid, "cwd", opts.Cwd, "model", opts.Model)
// cmd.Start() succeeded — transfer temp file ownership to the goroutine.
mcpFileCleanup = nil
- // Transfer isolated-config cleanup the same way: the goroutine outlives
- // this function, so it owns removal of the scratch dir.
- isolatedConfigCleanup := claudeConfigCleanup
- claudeConfigCleanup = nil
msgCh := make(chan Message, 256)
resCh := make(chan Result, 1)
@@ -181,9 +126,6 @@ func (b *claudeBackend) Execute(ctx context.Context, prompt string, opts ExecOpt
if mcpConfigPath != "" {
defer os.Remove(mcpConfigPath)
}
- if isolatedConfigCleanup != nil {
- defer isolatedConfigCleanup()
- }
startTime := time.Now()
var output strings.Builder
@@ -625,170 +567,6 @@ func buildEnv(extra map[string]string) []string {
return mergeEnv(os.Environ(), extra)
}
-// buildClaudeEnv builds the env slice for the claude subprocess. When
-// claudeConfigDir is non-empty (isolated-skills mode), it overrides
-// CLAUDE_CONFIG_DIR for the child so the CLI looks at the per-task
-// scratch dir instead of `~/.claude/`. We also strip the parent's
-// CLAUDE_CONFIG_DIR so a daemon-host env var cannot accidentally win
-// the override race. Callers in "merge" mode pass "" and behaviour
-// matches the pre-MUL-2603 buildEnv path.
-//
-// hostConfigDir is the *effective* host Claude config source the scratch
-// dir was mirrored from (see resolveHostClaudeConfigDir). It is used as
-// the gate for the macOS keychain OAuth passthrough: only the default
-// `$HOME/.claude` host source matches the unsuffixed
-// `Claude Code-credentials` keychain entry, so for custom dirs we
-// deliberately skip the passthrough rather than inject the daemon
-// user's default account into a managed/custom-dir agent.
-func buildClaudeEnv(extra map[string]string, claudeConfigDir, hostConfigDir string, logger *slog.Logger) []string {
- return buildClaudeEnvWith(extra, claudeConfigDir, hostConfigDir, logger, os.UserHomeDir, readHostClaudeOAuthToken)
-}
-
-// buildClaudeEnvWith is the testable seam behind buildClaudeEnv. Tests
-// inject a homeDir resolver and readOAuthToken closure so they can
-// exercise the auth passthrough — including the default-vs-custom
-// hostConfigDir gate — without touching the real macOS keychain or
-// mutating $HOME.
-func buildClaudeEnvWith(
- extra map[string]string,
- claudeConfigDir, hostConfigDir string,
- logger *slog.Logger,
- homeDir func() (string, error),
- readOAuthToken func() (string, error),
-) []string {
- env := mergeEnv(os.Environ(), extra)
- if claudeConfigDir == "" {
- return env
- }
- // Drop any CLAUDE_CONFIG_DIR already in the slice (from os.Environ or
- // from custom_env) before appending the isolated override so the last
- // entry wins deterministically. Track whether the operator already
- // pinned OAuth / API-key auth via env so we know whether to add a
- // keychain-sourced token below. "Pinned" means the value is non-empty:
- // an empty `ANTHROPIC_API_KEY=` / `CLAUDE_CODE_OAUTH_TOKEN=` leaks in
- // from `os.Environ()` on hosts whose login shell unsets it that way,
- // and treating that as an explicit auth choice would silently strand
- // the isolated child at "Not logged in" (MUL-2603 review follow-up).
- filtered := env[:0]
- hasOAuthToken := false
- hasAnthropicKey := false
- for _, entry := range env {
- if strings.HasPrefix(entry, "CLAUDE_CONFIG_DIR=") {
- continue
- }
- if v, ok := strings.CutPrefix(entry, "CLAUDE_CODE_OAUTH_TOKEN="); ok {
- if v == "" {
- // Empty `CLAUDE_CODE_OAUTH_TOKEN=` is noise (login-shell
- // quirk, stale custom_env entry) — drop so it cannot shadow
- // a keychain-injected token later in the slice on platforms
- // where the libc env lookup picks the first match.
- continue
- }
- hasOAuthToken = true
- }
- if v, ok := strings.CutPrefix(entry, "ANTHROPIC_API_KEY="); ok {
- if v == "" {
- // Same treatment as the OAuth token: empty `ANTHROPIC_API_KEY=`
- // must not pose as a pinned API-key auth choice. Drop so the
- // child does not see a confusing empty value either.
- continue
- }
- hasAnthropicKey = true
- }
- filtered = append(filtered, entry)
- }
- filtered = append(filtered, "CLAUDE_CONFIG_DIR="+claudeConfigDir)
-
- // Auth passthrough — only meaningful in isolation mode, and only on
- // platforms where the child CLI cannot follow the host's auth on its
- // own. On Linux/Windows the OAuth token lives in
- // `$CLAUDE_CONFIG_DIR/.credentials.json` and is already symlinked via
- // mirrorHostClaudeExceptSkills, so readHostClaudeOAuthToken is a
- // no-op there. On macOS Claude Code 2.x scopes the keychain entry by
- // SHA-256(CLAUDE_CONFIG_DIR)[:8]; isolating the config dir changes
- // that suffix, so the child cannot find the host token even though it
- // is sitting in the default `Claude Code-credentials` entry. Surface
- // the access token via CLAUDE_CODE_OAUTH_TOKEN so the child skips
- // keychain lookup entirely (MUL-2603 follow-up regression).
- //
- // Host-dir gate: the reader returns the *unsuffixed*
- // `Claude Code-credentials` entry, which is only correct when the
- // host config source is the default `$HOME/.claude`. A custom
- // CLAUDE_CONFIG_DIR (set via agent custom_env or daemon-host env)
- // maps to `Claude Code-credentials-<hash>` for a *different* account.
- // Injecting the unsuffixed entry there would cross-pollute the
- // managed/custom agent with the daemon user's default OAuth account
- // — the same "do not cross accounts" boundary mirrorHostClaudeJSONIfMissing
- // already enforces for `.claude.json`. So for custom/parent dirs we
- // deliberately skip the passthrough and let the child rely on
- // whatever auth lives inside the custom dir (`.credentials.json`,
- // `apiKeyHelper`, etc.) or fall through to ANTHROPIC_API_KEY.
- //
- // Security boundary (Bash subprocess only): CLAUDE_CODE_OAUTH_TOKEN
- // is the host's claude.ai OAuth access token. We rely on Claude
- // Code itself scrubbing it from the env it passes to the
- // model-driven Bash tool subprocess — the property is locked in by
- // TestClaudeCLIScrubsOAuthTokenFromBashSubprocess, which boots the
- // real CLI with a canary OAuth token + a non-secret control var,
- // plus two per-run random nonces passed *only* via env vars (never
- // in the prompt text). The assertions are: the canary is absent
- // from the transcript, the unset-nonce appears (proving a real Bash
- // subprocess ran AND saw CLAUDE_CODE_OAUTH_TOKEN as empty), and the
- // control-nonce appears (proving the scrub is targeted, not a
- // side-effect of "Bash gets no env"). Using nonces — instead of
- // hard-coded markers that could be paraphrased back from the
- // prompt — is what makes the proof actually pin a real subprocess.
- // Hook subprocesses are NOT covered by this assertion: we have not
- // reproduced the env shape they receive, so the contract here
- // intentionally narrows to Bash; if a future hook-using feature
- // matters we must add a hook-side regression before relying on the
- // same env-scrub there. If the existing test ever flips (upstream
- // CLI change), this passthrough must move off env vars (e.g. a
- // short-lived `apiKeyHelper` script) before merging.
- //
- // Precedence (highest wins): operator-pinned CLAUDE_CODE_OAUTH_TOKEN
- // in custom_env, then ANTHROPIC_API_KEY (the user explicitly chose
- // API-key auth — do not silently override with OAuth), then the
- // keychain token. "Pinned" is gated on a non-empty value above so an
- // empty `KEY=` inherited from os.Environ does not pose as an explicit
- // choice and disable the keychain reader.
- if !hasOAuthToken && !hasAnthropicKey && readOAuthToken != nil &&
- isDefaultHostClaudeConfigDir(hostConfigDir, homeDir) {
- token, err := readOAuthToken()
- if err != nil && logger != nil {
- logger.Warn("claude: read host oauth token failed",
- "error", err,
- )
- }
- if token != "" {
- filtered = append(filtered, "CLAUDE_CODE_OAUTH_TOKEN="+token)
- }
- }
- return filtered
-}
-
-// isDefaultHostClaudeConfigDir reports whether hostConfigDir refers to the
-// default per-user Claude config path `$HOME/.claude`. The macOS keychain
-// passthrough relies on this gate because the unsuffixed
-// `Claude Code-credentials` entry only matches that default; custom
-// CLAUDE_CONFIG_DIR values map to suffixed entries for different accounts,
-// so reading the unsuffixed entry into a custom-dir isolated child would
-// cross-pollute accounts (see buildClaudeEnvWith for the full reasoning).
-//
-// Returns false when hostConfigDir is empty (merge mode) or when the home
-// directory cannot be resolved — both translate to "do not pull the
-// default keychain token", which is the safe default.
-func isDefaultHostClaudeConfigDir(hostConfigDir string, homeDir func() (string, error)) bool {
- if hostConfigDir == "" || homeDir == nil {
- return false
- }
- home, err := homeDir()
- if err != nil || home == "" {
- return false
- }
- return hostConfigDir == filepath.Join(home, ".claude")
-}
-
func mergeEnv(base []string, extra map[string]string) []string {
env := make([]string, 0, len(base)+len(extra))
for _, entry := range base {
@@ -810,237 +588,6 @@ func isFilteredChildEnvKey(key string) bool {
strings.HasPrefix(key, "CLAUDE_CODE_")
}
-// resolveHostClaudeConfigDir picks the directory we mirror into the per-task
-// scratch CLAUDE_CONFIG_DIR. Precedence:
-//
-// 1. Agent custom_env CLAUDE_CONFIG_DIR (operator pinned this agent at a
-// specific install — e.g. a managed shared profile).
-// 2. Parent process CLAUDE_CONFIG_DIR (daemon-host env var; some self-host
-// deployments set this globally so `claude login` writes there instead
-// of `~/.claude`).
-// 3. `~/.claude/` (the documented default for Linux/Windows; macOS keeps
-// credentials in Keychain so the dir still holds settings/agents/etc.).
-//
-// Returns "" when none of the above are usable (no env, no home dir). The
-// caller treats that as "host has no Claude config to mirror" — the scratch
-// dir stays empty and the CLI relies on `ANTHROPIC_API_KEY` auth.
-func resolveHostClaudeConfigDir(extraEnv map[string]string) string {
- if v, ok := extraEnv["CLAUDE_CONFIG_DIR"]; ok && v != "" {
- return v
- }
- if v := os.Getenv("CLAUDE_CONFIG_DIR"); v != "" {
- return v
- }
- home, err := os.UserHomeDir()
- if err != nil {
- return ""
- }
- return filepath.Join(home, ".claude")
-}
-
-// newIsolatedClaudeConfigDir creates a per-run scratch directory used as
-// CLAUDE_CONFIG_DIR when the agent opted out of host-machine skill merging.
-// The dir is placed under the task workdir when available so it lives and
-// dies with the task's storage allocation; otherwise it falls back to the
-// OS temp dir.
-//
-// The dir is NOT empty: every entry from the effective host Claude config
-// (resolveHostClaudeConfigDir) is mirrored through *except* `skills/`. That
-// preserves Claude Code's login state (`.credentials.json` on Linux/Windows),
-// global settings, plugins, agents, commands, output styles, todos, etc. —
-// which all live in this directory and would otherwise be invisible to the
-// isolated child — while still keeping the user-global skills directory off
-// the CLI's discovery path. Without this passthrough, opting into "ignore"
-// mode on a non-API-key host would force the Claude agent to re-authenticate,
-// breaking the documented "run `claude` once to log in" install flow.
-//
-// Each entry uses createDirLink / createFileLink, which try symlink first
-// and fall back to a directory junction (Windows `mklink /J`) for dirs or a
-// hardlink/copy for files when the platform rejects the symlink (Windows
-// without Developer Mode / admin). Failing silently to symlink-only would
-// leave Windows hosts with an empty scratch dir, defeating the auth
-// passthrough — see MUL-2603 review.
-//
-// The returned cleanup removes the scratch directory; symlinks, junctions,
-// and hardlinks are unlinked without touching the real host file. Safe to
-// call from any goroutine exactly once.
-func newIsolatedClaudeConfigDir(taskCwd, hostConfigDir string, logger *slog.Logger) (string, func(), error) {
- parent := taskCwd
- if parent == "" {
- parent = os.TempDir()
- }
- dir, err := os.MkdirTemp(parent, "multica-claude-config-*")
- if err != nil {
- // Fall back to the OS temp dir if the cwd refused us (read-only
- // volume, missing parent, etc.). A scratch dir somewhere on the
- // host is still strictly better than letting the CLI auto-discover
- // `~/.claude/skills/`.
- if parent != os.TempDir() {
- dir, err = os.MkdirTemp(os.TempDir(), "multica-claude-config-*")
- }
- if err != nil {
- return "", nil, err
- }
- }
-
- if hostConfigDir != "" {
- // Best effort. If the host config dir is missing entirely (env-var-
- // auth-only setup) we just leave the scratch dir empty. If individual
- // entries fail to mirror — even after fallback — we log so operators
- // can correlate Claude Code auth failures with the missing mirror,
- // but we do not abort: a partial mirror is still better than letting
- // the CLI discover `~/.claude/skills/` directly.
- if err := mirrorHostClaudeExceptSkills(hostConfigDir, dir); err != nil && logger != nil {
- logger.Warn("claude: mirror host config dir failed",
- "source", hostConfigDir,
- "dest", dir,
- "error", err,
- )
- }
- // Claude Code's default layout (no CLAUDE_CONFIG_DIR set) stores the
- // main config — login state, projects history, recent sessions — at
- // `$HOME/.claude.json`, a *sibling* of `~/.claude/` rather than
- // inside it. The mirror above only walks entries under
- // `hostConfigDir`, so on default hosts the scratch dir never gets
- // `.claude.json` and the CLI exits with `Claude configuration file
- // not found … Not logged in · Please run /login` (MUL-2661).
- if err := mirrorHostClaudeJSONIfMissing(hostConfigDir, dir); err != nil && logger != nil {
- logger.Warn("claude: mirror host .claude.json failed",
- "source", hostConfigDir,
- "dest", dir,
- "error", err,
- )
- }
- }
-
- cleanup := func() {
- // Best effort — caller logs through normal channels if cleanup fails
- // (a leftover scratch dir is non-fatal; the GC sweeper that reclaims
- // orphaned task workdirs will catch it too). RemoveAll unlinks
- // symlinks / junctions without following them, so the real host
- // `~/.claude/` is not touched. Hardlinks share inodes so unlinking
- // the mirror entry leaves the source file with refcount 1.
- _ = os.RemoveAll(dir)
- }
- return dir, cleanup, nil
-}
-
-// mirrorHostClaudeExceptSkills mirrors every direct entry under
-// hostClaudeDir into destDir, skipping `skills/`. Each entry tries a
-// symlink first and falls back to a directory junction (Windows
-// `mklink /J`) or a hardlink/copy (Windows without Developer Mode) so the
-// mirror still works on hosts that lack SeCreateSymbolicLinkPrivilege. The
-// first per-entry error is returned so callers can log it; we do not abort
-// the loop, because the goal — keeping `skills/` out of the CLI's discovery
-// path — is met as soon as we own the scratch dir, and a partial mirror is
-// still better than no isolation.
-func mirrorHostClaudeExceptSkills(hostClaudeDir, destDir string) error {
- return mirrorHostClaudeExceptSkillsWith(hostClaudeDir, destDir, createDirLink, createFileLink)
-}
-
-// mirrorHostClaudeExceptSkillsWith is the testable seam behind
-// mirrorHostClaudeExceptSkills. Tests inject custom dirLink / fileLink
-// closures to exercise the symlink-failure fallback path on platforms
-// (Linux/macOS) where os.Symlink would otherwise always succeed.
-func mirrorHostClaudeExceptSkillsWith(
- hostClaudeDir, destDir string,
- dirLink, fileLink func(src, dst string) error,
-) error {
- entries, err := os.ReadDir(hostClaudeDir)
- if err != nil {
- return err
- }
- var firstErr error
- for _, entry := range entries {
- if entry.Name() == "skills" {
- continue
- }
- src := filepath.Join(hostClaudeDir, entry.Name())
- dst := filepath.Join(destDir, entry.Name())
- var linkErr error
- if entry.IsDir() {
- linkErr = dirLink(src, dst)
- } else {
- linkErr = fileLink(src, dst)
- }
- if linkErr != nil && firstErr == nil {
- firstErr = fmt.Errorf("link %s: %w", entry.Name(), linkErr)
- }
- }
- return firstErr
-}
-
-// mirrorHostClaudeJSONIfMissing links `$HOME/.claude.json` into destDir as
-// `.claude.json` when it is not already there. Claude Code's default layout
-// (no CLAUDE_CONFIG_DIR set) stores the main config — login state, project
-// history — at `$HOME/.claude.json`, a *sibling* of `~/.claude/`, not inside
-// it. Without this passthrough, isolating CLAUDE_CONFIG_DIR strands the CLI
-// in a dir without `.claude.json` and it bails with
-// `Claude configuration file not found … Not logged in · Please run /login`
-// (MUL-2661 regression).
-//
-// No-op when:
-// - destDir already has `.claude.json` (mirrored from inside a custom
-// CLAUDE_CONFIG_DIR by mirrorHostClaudeExceptSkills);
-// - hostConfigDir is not the default `$HOME/.claude` — a custom
-// CLAUDE_CONFIG_DIR is expected to be self-contained, and silently
-// merging `$HOME/.claude.json` from a different account would mask
-// credential drift;
-// - `$HOME/.claude.json` does not exist (env-var-auth-only or fresh
-// install).
-func mirrorHostClaudeJSONIfMissing(hostConfigDir, destDir string) error {
- return mirrorHostClaudeJSONIfMissingWith(hostConfigDir, destDir, os.UserHomeDir, createFileLink)
-}
-
-// mirrorHostClaudeJSONIfMissingWith is the testable seam behind
-// mirrorHostClaudeJSONIfMissing. Tests inject homeDir / fileLink so they can
-// exercise the precedence rules without mutating the process environment.
-func mirrorHostClaudeJSONIfMissingWith(
- hostConfigDir, destDir string,
- homeDir func() (string, error),
- fileLink func(src, dst string) error,
-) error {
- dst := filepath.Join(destDir, ".claude.json")
- if _, err := os.Lstat(dst); err == nil {
- return nil
- }
- home, err := homeDir()
- if err != nil || home == "" {
- return nil
- }
- if hostConfigDir != filepath.Join(home, ".claude") {
- return nil
- }
- src := filepath.Join(home, ".claude.json")
- if _, err := os.Stat(src); err != nil {
- return nil
- }
- return fileLink(src, dst)
-}
-
-// copyFile copies the bytes of src into dst with a fresh file. Used as the
-// last-resort fallback inside createFileLink on Windows when both symlink
-// and hardlink are unavailable. Kept in the platform-agnostic file so the
-// Unix build still compiles (it never calls copyFile, but the symbol must
-// exist for the test fallback seam to be exercisable on Linux/macOS).
-func copyFile(src, dst string) error {
- in, err := os.Open(src)
- if err != nil {
- return fmt.Errorf("open %s: %w", src, err)
- }
- defer in.Close()
- out, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)
- if err != nil {
- return fmt.Errorf("create %s: %w", dst, err)
- }
- defer out.Close()
- if _, err := io.Copy(out, in); err != nil {
- return fmt.Errorf("copy %s → %s: %w", src, dst, err)
- }
- return nil
-}
-
-
// blockedArgMode specifies whether a blocked arg takes a value or is standalone.
type blockedArgMode int
diff --git a/server/pkg/agent/claude_keychain_darwin.go b/server/pkg/agent/claude_keychain_darwin.go
deleted file mode 100644
index 6d68628e4a..0000000000
--- a/server/pkg/agent/claude_keychain_darwin.go
+++ /dev/null
@@ -1,87 +0,0 @@
-//go:build darwin
-
-package agent
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "os/exec"
- "strings"
- "time"
-)
-
-// claudeKeychainServiceName is the macOS keychain service name that
-// `claude /login` writes to when the user authenticates against
-// claude.ai. The payload is a JSON blob whose `claudeAiOauth.accessToken`
-// field is what we surface to the isolated child.
-const claudeKeychainServiceName = "Claude Code-credentials"
-
-// claudeKeychainReadTimeout caps how long we wait on `/usr/bin/security`.
-// Reads are normally instantaneous when the ACL already trusts the caller;
-// when macOS surfaces a "allow access" prompt this gives a present user
-// enough time to click through. We do NOT want to wait forever: a headless
-// run with no one at the console would otherwise stall the agent task
-// indefinitely on the very first run.
-const claudeKeychainReadTimeout = 10 * time.Second
-
-// readHostClaudeOAuthToken reads the host machine's Claude Code OAuth
-// access token from the macOS login keychain (entry
-// `Claude Code-credentials`). Returns ("", nil) when the token is not
-// available — entry missing, user denied / ignored the keychain prompt,
-// payload missing `claudeAiOauth.accessToken`, etc. — so callers in the
-// isolation path can fall back to whatever auth the child CLI can find on
-// its own (typically ANTHROPIC_API_KEY for headless / API-key-only hosts).
-//
-// Why this exists: Claude Code 2.x derives the keychain-lookup suffix from
-// SHA-256(CLAUDE_CONFIG_DIR)[:8], so the unsuffixed `Claude Code-credentials`
-// entry is read only when CLAUDE_CONFIG_DIR is unset or equals the install
-// default. The moment MUL-2603 isolation points the child at a scratch dir,
-// the CLI starts asking for `Claude Code-credentials-<other-hash>`, finds
-// nothing, and exits "Not logged in · Please run /login" even though the
-// host's OAuth token is sitting in the default entry. Surfacing the token
-// through CLAUDE_CODE_OAUTH_TOKEN sidesteps the suffix scheme entirely.
-//
-// Returns a non-nil error only for unexpected system failures (e.g.
-// `/usr/bin/security` not found) — the caller logs those at warn level so
-// operators can diagnose. The common "no token available" case stays
-// silent because we cannot tell "user is API-key-only" apart from "user
-// denied access" by exit code, and we do not want to spam the daemon log
-// on every isolated run for the former.
-func readHostClaudeOAuthToken() (string, error) {
- ctx, cancel := context.WithTimeout(context.Background(), claudeKeychainReadTimeout)
- defer cancel()
-
- cmd := exec.CommandContext(ctx, "/usr/bin/security", "find-generic-password", "-s", claudeKeychainServiceName, "-w")
- out, err := cmd.Output()
- if err != nil {
- var exitErr *exec.ExitError
- if errors.As(err, &exitErr) {
- // Non-zero exit from `security` covers entry-missing, denied,
- // and timeout — all soft failures from our perspective.
- return "", nil
- }
- // `/usr/bin/security` itself is missing or unexecutable — this is
- // unexpected on macOS and worth surfacing so the caller can log it.
- return "", fmt.Errorf("invoke security CLI: %w", err)
- }
-
- raw := strings.TrimSpace(string(out))
- if raw == "" {
- return "", nil
- }
- var payload struct {
- ClaudeAiOauth struct {
- AccessToken string `json:"accessToken"`
- } `json:"claudeAiOauth"`
- }
- if err := json.Unmarshal([]byte(raw), &payload); err != nil {
- // A malformed payload is almost certainly a Claude Code upstream
- // change to the keychain schema; downgrade to soft failure so
- // the child can still attempt API-key auth, but do not pretend
- // the schema is fine — surface so we update the parser.
- return "", fmt.Errorf("parse claude keychain payload: %w", err)
- }
- return payload.ClaudeAiOauth.AccessToken, nil
-}
diff --git a/server/pkg/agent/claude_keychain_other.go b/server/pkg/agent/claude_keychain_other.go
deleted file mode 100644
index b14486d089..0000000000
--- a/server/pkg/agent/claude_keychain_other.go
+++ /dev/null
@@ -1,18 +0,0 @@
-//go:build !darwin
-
-package agent
-
-// readHostClaudeOAuthToken is a no-op on non-Darwin platforms. Linux and
-// Windows Claude Code persists the OAuth token to
-// `$CLAUDE_CONFIG_DIR/.credentials.json` — a file that lives inside the
-// config dir, so mirrorHostClaudeExceptSkills already symlinks it into the
-// per-run scratch dir alongside everything else. The isolated child finds
-// it via the normal config-dir path; we do not need to surface anything
-// through CLAUDE_CODE_OAUTH_TOKEN here.
-//
-// The macOS keychain workaround exists specifically because that platform
-// derives the keychain-lookup suffix from the config-dir path — see
-// claude_keychain_darwin.go for the full story.
-func readHostClaudeOAuthToken() (string, error) {
- return "", nil
-}
diff --git a/server/pkg/agent/claude_link_unix.go b/server/pkg/agent/claude_link_unix.go
deleted file mode 100644
index bb97e7e2dc..0000000000
--- a/server/pkg/agent/claude_link_unix.go
+++ /dev/null
@@ -1,20 +0,0 @@
-//go:build !windows
-
-package agent
-
-import "os"
-
-// createDirLink symlinks src → dst for a directory entry mirrored into the
-// per-task scratch CLAUDE_CONFIG_DIR. On Unix the kernel always honours
-// symlinks, so a single os.Symlink call is sufficient and matches the
-// existing behaviour.
-func createDirLink(src, dst string) error {
- return os.Symlink(src, dst)
-}
-
-// createFileLink symlinks src → dst for a file entry mirrored into the
-// per-task scratch CLAUDE_CONFIG_DIR. Unix has no equivalent of Windows's
-// SeCreateSymbolicLinkPrivilege gate, so a single os.Symlink is enough.
-func createFileLink(src, dst string) error {
- return os.Symlink(src, dst)
-}
diff --git a/server/pkg/agent/claude_link_windows.go b/server/pkg/agent/claude_link_windows.go
deleted file mode 100644
index 56f5892ffb..0000000000
--- a/server/pkg/agent/claude_link_windows.go
+++ /dev/null
@@ -1,45 +0,0 @@
-//go:build windows
-
-package agent
-
-import (
- "fmt"
- "os"
- "os/exec"
-)
-
-// createDirLink mirrors a directory from src to dst inside the per-task
-// scratch CLAUDE_CONFIG_DIR. Windows os.Symlink requires
-// SeCreateSymbolicLinkPrivilege (Developer Mode or admin), which most
-// Multica CLI / Desktop installs do not have — without a fallback the
-// mirror leaves an empty `~/.claude/`-equivalent, and the default
-// "ignore" mode silently breaks Claude Code authentication on those
-// hosts. A directory junction (`mklink /J`) does not require the
-// privilege and behaves equivalently for our read-only mirror use, so
-// it is the first fallback. See server/internal/daemon/execenv for the
-// same pattern applied to CODEX_HOME.
-func createDirLink(src, dst string) error {
- if err := os.Symlink(src, dst); err == nil {
- return nil
- }
- out, err := exec.Command("cmd", "/c", "mklink", "/J", dst, src).CombinedOutput()
- if err != nil {
- return fmt.Errorf("mklink /J %s %s: %s: %w", dst, src, out, err)
- }
- return nil
-}
-
-// createFileLink mirrors a file from src to dst inside the per-task scratch
-// CLAUDE_CONFIG_DIR. Tries symlink first, then hardlink (works on the same
-// NTFS volume without elevated privileges and still shares content with the
-// shared `~/.claude/.credentials.json` so token refreshes propagate), then
-// a final content copy as a last resort.
-func createFileLink(src, dst string) error {
- if err := os.Symlink(src, dst); err == nil {
- return nil
- }
- if err := os.Link(src, dst); err == nil {
- return nil
- }
- return copyFile(src, dst)
-}
diff --git a/server/pkg/agent/claude_test.go b/server/pkg/agent/claude_test.go
index c60b2af213..f96dee0367 100644
--- a/server/pkg/agent/claude_test.go
+++ b/server/pkg/agent/claude_test.go
@@ -3,13 +3,9 @@ package agent
import (
"bytes"
"context"
- "crypto/rand"
- "encoding/hex"
"encoding/json"
- "errors"
"log/slog"
"os"
- "os/exec"
"path/filepath"
"runtime"
"strings"
@@ -654,892 +650,6 @@ func mustMarshal(t *testing.T, v any) json.RawMessage {
return data
}
-func TestClaudeExecuteIsolatesHostSkillsWhenIgnoreOptedIn(t *testing.T) {
- t.Parallel()
- if runtime.GOOS == "windows" {
- t.Skip("shell-script fixture is POSIX-only")
- }
-
- // Fake claude binary that prints its CLAUDE_CONFIG_DIR to stdout so we
- // can confirm the runtime redirected the CLI off `~/.claude/` when the
- // agent explicitly opted into "ignore" mode (the platform default is
- // "merge", which preserves the host's CLAUDE_CONFIG_DIR).
- fakePath := filepath.Join(t.TempDir(), "claude")
- script := "#!/bin/sh\n" +
- "cat >/dev/null\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"system\\\",\\\"session_id\\\":\\\"sess\\\"}\"\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"result\\\",\\\"subtype\\\":\\\"success\\\",\\\"is_error\\\":false,\\\"session_id\\\":\\\"sess\\\",\\\"result\\\":\\\"$CLAUDE_CONFIG_DIR\\\"}\"\n"
- writeTestExecutable(t, fakePath, []byte(script))
-
- backend, err := New("claude", Config{ExecutablePath: fakePath, Logger: slog.Default()})
- if err != nil {
- t.Fatalf("new claude backend: %v", err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- cwd := t.TempDir()
- // Explicit SkillsLocal == "ignore" → backend points CLAUDE_CONFIG_DIR at
- // a per-task scratch dir under cwd.
- session, err := backend.Execute(ctx, "ignored", ExecOptions{
- Cwd: cwd,
- Timeout: 5 * time.Second,
- SkillsLocal: "ignore",
- })
- if err != nil {
- t.Fatalf("execute: %v", err)
- }
- go func() {
- for range session.Messages {
- }
- }()
-
- select {
- case result := <-session.Result:
- if result.Status != "completed" {
- t.Fatalf("expected completed, got %q (err=%q)", result.Status, result.Error)
- }
- // The CLI saw a CLAUDE_CONFIG_DIR pointed at a multica-managed scratch
- // dir under our task cwd, not the host user's ~/.claude.
- got := strings.TrimSpace(result.Output)
- if got == "" {
- t.Fatalf("expected CLAUDE_CONFIG_DIR to be non-empty in ignore mode")
- }
- if !strings.Contains(got, "multica-claude-config-") {
- t.Fatalf("expected isolated scratch dir, got %q", got)
- }
- if !strings.HasPrefix(got, cwd) {
- t.Fatalf("expected isolated dir under %q, got %q", cwd, got)
- }
- case <-time.After(10 * time.Second):
- t.Fatal("timeout waiting for result")
- }
-}
-
-func TestClaudeExecuteDefaultModeKeepsHostConfigDir(t *testing.T) {
- // NOT parallel — t.Setenv mutates global env.
- if runtime.GOOS == "windows" {
- t.Skip("shell-script fixture is POSIX-only")
- }
-
- // Default ExecOptions (no SkillsLocal) must preserve the host's
- // CLAUDE_CONFIG_DIR — the platform default is "merge", which inherits
- // the host's user-global skill directory (Bohan's product decision on
- // MUL-2603: keep MUL-2603 hardening as an explicit opt-in to avoid
- // regressing personal workflows that rely on locally installed skills).
- fakePath := filepath.Join(t.TempDir(), "claude")
- script := "#!/bin/sh\n" +
- "cat >/dev/null\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"system\\\",\\\"session_id\\\":\\\"sess\\\"}\"\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"result\\\",\\\"subtype\\\":\\\"success\\\",\\\"is_error\\\":false,\\\"session_id\\\":\\\"sess\\\",\\\"result\\\":\\\"${CLAUDE_CONFIG_DIR:-unset}\\\"}\"\n"
- writeTestExecutable(t, fakePath, []byte(script))
-
- t.Setenv("CLAUDE_CONFIG_DIR", "/tmp/test-host-claude")
-
- backend, err := New("claude", Config{ExecutablePath: fakePath, Logger: slog.Default()})
- if err != nil {
- t.Fatalf("new claude backend: %v", err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- // Default ExecOptions → SkillsLocal == "" → backend treats as merge
- // (inherit-from-machine) and the host CLAUDE_CONFIG_DIR is preserved.
- session, err := backend.Execute(ctx, "ignored", ExecOptions{
- Cwd: t.TempDir(),
- Timeout: 5 * time.Second,
- })
- if err != nil {
- t.Fatalf("execute: %v", err)
- }
- go func() {
- for range session.Messages {
- }
- }()
-
- select {
- case result := <-session.Result:
- if result.Status != "completed" {
- t.Fatalf("expected completed, got %q (err=%q)", result.Status, result.Error)
- }
- got := strings.TrimSpace(result.Output)
- if got != "/tmp/test-host-claude" {
- t.Fatalf("expected host CLAUDE_CONFIG_DIR preserved in default mode, got %q", got)
- }
- case <-time.After(10 * time.Second):
- t.Fatal("timeout waiting for result")
- }
-}
-
-func TestClaudeExecuteMergeModeKeepsHostConfigDir(t *testing.T) {
- // NOT parallel — t.Setenv mutates global env which conflicts with
- // concurrent tests reading CLAUDE_CONFIG_DIR or running under t.Parallel.
- if runtime.GOOS == "windows" {
- t.Skip("shell-script fixture is POSIX-only")
- }
-
- fakePath := filepath.Join(t.TempDir(), "claude")
- script := "#!/bin/sh\n" +
- "cat >/dev/null\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"system\\\",\\\"session_id\\\":\\\"sess\\\"}\"\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"result\\\",\\\"subtype\\\":\\\"success\\\",\\\"is_error\\\":false,\\\"session_id\\\":\\\"sess\\\",\\\"result\\\":\\\"${CLAUDE_CONFIG_DIR:-unset}\\\"}\"\n"
- writeTestExecutable(t, fakePath, []byte(script))
-
- // Set a host-style CLAUDE_CONFIG_DIR so we can assert merge mode
- // preserves it. The backend strips this in ignore mode but must leave
- // it alone when the operator explicitly opted into merging.
- t.Setenv("CLAUDE_CONFIG_DIR", "/tmp/test-host-claude")
-
- backend, err := New("claude", Config{ExecutablePath: fakePath, Logger: slog.Default()})
- if err != nil {
- t.Fatalf("new claude backend: %v", err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- session, err := backend.Execute(ctx, "ignored", ExecOptions{
- Cwd: t.TempDir(),
- Timeout: 5 * time.Second,
- SkillsLocal: "merge",
- })
- if err != nil {
- t.Fatalf("execute: %v", err)
- }
- go func() {
- for range session.Messages {
- }
- }()
-
- select {
- case result := <-session.Result:
- if result.Status != "completed" {
- t.Fatalf("expected completed, got %q (err=%q)", result.Status, result.Error)
- }
- got := strings.TrimSpace(result.Output)
- if got != "/tmp/test-host-claude" {
- t.Fatalf("expected host CLAUDE_CONFIG_DIR preserved in merge mode, got %q", got)
- }
- case <-time.After(10 * time.Second):
- t.Fatal("timeout waiting for result")
- }
-}
-
-func TestBuildClaudeEnvAppendsIsolatedConfigDir(t *testing.T) {
- t.Parallel()
-
- hostDir, homeDir := noopHostGate()
- env := buildClaudeEnvWith(nil, "/tmp/isolated-claude-config", hostDir, slog.Default(), homeDir, noopOAuthTokenReader)
-
- var last string
- hits := 0
- for _, entry := range env {
- if strings.HasPrefix(entry, "CLAUDE_CONFIG_DIR=") {
- hits++
- last = entry
- }
- }
- if hits != 1 {
- t.Fatalf("expected exactly one CLAUDE_CONFIG_DIR entry, got %d (%v)", hits, env)
- }
- if last != "CLAUDE_CONFIG_DIR=/tmp/isolated-claude-config" {
- t.Fatalf("expected isolated CLAUDE_CONFIG_DIR override, got %q", last)
- }
-}
-
-func TestBuildClaudeEnvSkipsOverrideWhenEmpty(t *testing.T) {
- t.Parallel()
-
- // Asking for "merge" mode passes "" through. We should not add a
- // CLAUDE_CONFIG_DIR=… entry; the parent's value (if any) wins.
- hostDir, homeDir := noopHostGate()
- env := buildClaudeEnvWith(map[string]string{"FOO": "bar"}, "", hostDir, slog.Default(), homeDir, noopOAuthTokenReader)
- for _, entry := range env {
- if strings.HasPrefix(entry, "CLAUDE_CONFIG_DIR=") {
- // The parent env may legitimately have one set on a developer
- // machine — only assert we did not *add* one. Find the unfiltered
- // merge case to compare.
- return
- }
- }
-}
-
-func TestBuildClaudeEnvOverridesPreviousValue(t *testing.T) {
- t.Parallel()
-
- // Even if custom_env supplies a CLAUDE_CONFIG_DIR, the isolated dir
- // must take precedence: a stale custom_env entry must never be able
- // to point the child back at `~/.claude/`.
- hostDir, homeDir := noopHostGate()
- env := buildClaudeEnvWith(
- map[string]string{"CLAUDE_CONFIG_DIR": "/etc/hostile"},
- "/tmp/safe",
- hostDir,
- slog.Default(),
- homeDir,
- noopOAuthTokenReader,
- )
-
- hits := 0
- for _, entry := range env {
- if entry == "CLAUDE_CONFIG_DIR=/etc/hostile" {
- t.Fatalf("hostile custom_env CLAUDE_CONFIG_DIR was not stripped: %v", env)
- }
- if entry == "CLAUDE_CONFIG_DIR=/tmp/safe" {
- hits++
- }
- }
- if hits != 1 {
- t.Fatalf("expected isolated dir to be present exactly once, got %d (%v)", hits, env)
- }
-}
-
-// noopOAuthTokenReader stands in for the production keychain reader in
-// tests that do not care about the auth-passthrough branch. Returning
-// ("", nil) takes the "no token available" path: buildClaudeEnvWith
-// neither appends CLAUDE_CODE_OAUTH_TOKEN nor logs a warning.
-func noopOAuthTokenReader() (string, error) { return "", nil }
-
-// defaultHostGate returns (hostConfigDir, homeDir) inputs that satisfy
-// isDefaultHostClaudeConfigDir, so buildClaudeEnvWith treats the host
-// source as the default `$HOME/.claude` and runs the keychain
-// passthrough. Tests that exercise the passthrough branch use this; the
-// chosen home lives under t.TempDir so each subtest is hermetic and the
-// real machine's $HOME never matters.
-func defaultHostGate(t *testing.T) (string, func() (string, error)) {
- t.Helper()
- home := t.TempDir()
- return filepath.Join(home, ".claude"), func() (string, error) { return home, nil }
-}
-
-// noopHostGate returns (hostConfigDir, homeDir) inputs that always fail
-// the gate. Used by tests that don't care about the gate because the
-// passthrough is short-circuited earlier (merge mode, hasOAuthToken,
-// hasAnthropicKey). Returning an empty hostConfigDir is the explicit
-// "this test does not exercise the keychain branch" signal.
-func noopHostGate() (string, func() (string, error)) {
- return "", func() (string, error) { return "", nil }
-}
-
-// countEnvEntries returns the number of `key=…` entries in env. Used by
-// the auth-passthrough tests below to assert "exactly one" instead of
-// "at least one" — a duplicate CLAUDE_CODE_OAUTH_TOKEN entry would let
-// later behaviour depend on which one the kernel hands to the child.
-func countEnvEntries(env []string, key string) int {
- prefix := key + "="
- n := 0
- for _, entry := range env {
- if strings.HasPrefix(entry, prefix) {
- n++
- }
- }
- return n
-}
-
-// envValue returns the first value bound to key in env, or "" if absent.
-func envValue(env []string, key string) string {
- prefix := key + "="
- for _, entry := range env {
- if strings.HasPrefix(entry, prefix) {
- return strings.TrimPrefix(entry, prefix)
- }
- }
- return ""
-}
-
-// TestBuildClaudeEnvIsolatedInjectsKeychainOAuthToken locks in the
-// MUL-2603 follow-up: when isolation strips CLAUDE_CONFIG_DIR, the host
-// OAuth token must reach the child through CLAUDE_CODE_OAUTH_TOKEN.
-// Without this passthrough Claude Code's per-config-dir keychain suffix
-// scheme strands the isolated child at "Not logged in · Please run
-// /login" even though the host's OAuth credential is sitting in the
-// default keychain entry.
-func TestBuildClaudeEnvIsolatedInjectsKeychainOAuthToken(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) { return "sk-ant-oat-test", nil }
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(nil, "/tmp/isolated", hostDir, slog.Default(), homeDir, reader)
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 1 {
- t.Fatalf("expected exactly one CLAUDE_CODE_OAUTH_TOKEN entry, got %d (%v)", got, env)
- }
- if got := envValue(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != "sk-ant-oat-test" {
- t.Fatalf("expected keychain token to be surfaced verbatim, got %q", got)
- }
-}
-
-// TestBuildClaudeEnvMergeModeDoesNotInjectOAuthToken guards the
-// merge-mode side: CLAUDE_CODE_OAUTH_TOKEN must never appear when the
-// caller opted out of isolation, because in that path the child reads
-// the host keychain itself and a stale env-var would shadow a freshly
-// refreshed token.
-func TestBuildClaudeEnvMergeModeDoesNotInjectOAuthToken(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) {
- t.Fatal("readOAuthToken must not be invoked in merge mode")
- return "", nil
- }
- hostDir, homeDir := noopHostGate()
- env := buildClaudeEnvWith(nil, "", hostDir, slog.Default(), homeDir, reader)
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 0 {
- t.Fatalf("expected no CLAUDE_CODE_OAUTH_TOKEN in merge mode, got %d (%v)", got, env)
- }
-}
-
-// TestBuildClaudeEnvIsolatedRespectsCustomOAuthToken documents that a
-// CLAUDE_CODE_OAUTH_TOKEN pinned via agent custom_env wins over the
-// keychain reader. Operators sometimes pin a long-lived setup-token
-// (`claude setup-token`) for shared agents that must run after the
-// interactive user logs out; calling the keychain in that case would
-// either prompt or silently replace the intended token.
-func TestBuildClaudeEnvIsolatedRespectsCustomOAuthToken(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) {
- t.Fatal("readOAuthToken must not be invoked when custom_env pinned a token")
- return "", nil
- }
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(
- map[string]string{"CLAUDE_CODE_OAUTH_TOKEN": "sk-ant-oat-pinned"},
- "/tmp/isolated",
- hostDir,
- slog.Default(),
- homeDir,
- reader,
- )
-
- if got := envValue(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != "sk-ant-oat-pinned" {
- t.Fatalf("expected pinned custom_env token, got %q", got)
- }
-}
-
-// TestBuildClaudeEnvIsolatedSkipsKeychainWhenAnthropicKeyPresent
-// documents that a user who explicitly chose API-key auth via
-// ANTHROPIC_API_KEY does NOT get an OAuth token shoved on top — the two
-// auth modes are mutually exclusive on the CLI side, and silently
-// adding the keychain token would surface a confusing
-// "ambiguous auth" path on every isolated run.
-func TestBuildClaudeEnvIsolatedSkipsKeychainWhenAnthropicKeyPresent(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) {
- t.Fatal("readOAuthToken must not be invoked when ANTHROPIC_API_KEY is set")
- return "", nil
- }
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(
- map[string]string{"ANTHROPIC_API_KEY": "sk-ant-api-test"},
- "/tmp/isolated",
- hostDir,
- slog.Default(),
- homeDir,
- reader,
- )
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 0 {
- t.Fatalf("expected no CLAUDE_CODE_OAUTH_TOKEN alongside ANTHROPIC_API_KEY, got %d (%v)", got, env)
- }
-}
-
-// TestBuildClaudeEnvIsolatedReaderErrorIsSoftFailure documents that a
-// keychain read error (e.g. /usr/bin/security missing) does NOT abort
-// the build — the child still gets a coherent env minus the OAuth
-// token, and the warning is surfaced through the injected logger so
-// operators can correlate "Not logged in" with the underlying cause.
-func TestBuildClaudeEnvIsolatedReaderErrorIsSoftFailure(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) {
- return "", errors.New("security CLI unavailable")
- }
- var logBuf bytes.Buffer
- logger := slog.New(slog.NewTextHandler(&logBuf, nil))
-
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(nil, "/tmp/isolated", hostDir, logger, homeDir, reader)
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 0 {
- t.Fatalf("expected no CLAUDE_CODE_OAUTH_TOKEN when reader errors, got %d (%v)", got, env)
- }
- if got := countEnvEntries(env, "CLAUDE_CONFIG_DIR"); got != 1 {
- t.Fatalf("expected isolation env to still be intact, got %d CLAUDE_CONFIG_DIR entries", got)
- }
- if !strings.Contains(logBuf.String(), "read host oauth token failed") {
- t.Fatalf("expected reader error to be logged, got %q", logBuf.String())
- }
-}
-
-// TestBuildClaudeEnvIsolatedReaderNilTokenStaysQuiet documents the
-// common "host is not logged in" path: the reader returns ("", nil) —
-// no token, no error — and the env builder must neither append a
-// CLAUDE_CODE_OAUTH_TOKEN nor log a warning. We assert the silence
-// explicitly because a noisy warning every isolated run on every
-// API-key-only / unauthenticated host would drown out the real ones.
-func TestBuildClaudeEnvIsolatedReaderNilTokenStaysQuiet(t *testing.T) {
- t.Parallel()
-
- var logBuf bytes.Buffer
- logger := slog.New(slog.NewTextHandler(&logBuf, nil))
-
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(nil, "/tmp/isolated", hostDir, logger, homeDir, noopOAuthTokenReader)
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 0 {
- t.Fatalf("expected no CLAUDE_CODE_OAUTH_TOKEN when reader returns empty, got %d (%v)", got, env)
- }
- if logBuf.Len() != 0 {
- t.Fatalf("expected silence on (\"\", nil) reader return, got log output %q", logBuf.String())
- }
-}
-
-// TestBuildClaudeEnvIsolatedTreatsEmptyAnthropicAPIKeyAsUnpinned guards the
-// MUL-2603 review fix: a parent-inherited `ANTHROPIC_API_KEY=` (set but
-// empty — common on login-shell setups that conditionally export auth)
-// must not pose as an "operator pinned API key" and disable the keychain
-// reader. Without this gate the isolated child gets neither a usable env
-// var nor a keychain token, and strands at "Not logged in" while
-// pretending the user opted into API-key auth.
-//
-// CLAUDE_CODE_OAUTH_TOKEN does not need the same os.Environ test: mergeEnv
-// strips every `CLAUDE_CODE_*` key from the parent before assembling the
-// child env (isFilteredChildEnvKey), so a parent-set value cannot reach
-// the gate at all. The empty-value gate still applies on the custom_env
-// path — see TestBuildClaudeEnvIsolatedEmptyOAuthTokenInCustomEnvAsUnpinned
-// below.
-func TestBuildClaudeEnvIsolatedTreatsEmptyAnthropicAPIKeyAsUnpinned(t *testing.T) {
- // NOT parallel — t.Setenv mutates global env.
- t.Setenv("ANTHROPIC_API_KEY", "")
-
- reader := func() (string, error) { return "sk-ant-oat-keychain", nil }
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(nil, "/tmp/isolated", hostDir, slog.Default(), homeDir, reader)
-
- if got := envValue(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != "sk-ant-oat-keychain" {
- t.Fatalf("expected keychain token to be injected when ANTHROPIC_API_KEY is empty, got %q", got)
- }
-}
-
-// TestBuildClaudeEnvIsolatedHonorsNonEmptyAnthropicAPIKey is the positive
-// counterpart: a non-empty ANTHROPIC_API_KEY in the parent env is a real
-// auth pin and must keep the keychain reader off, otherwise an isolated
-// run on a hostile/API-key host would silently shove an OAuth token in
-// on top.
-func TestBuildClaudeEnvIsolatedHonorsNonEmptyAnthropicAPIKey(t *testing.T) {
- // NOT parallel — t.Setenv mutates global env.
- t.Setenv("ANTHROPIC_API_KEY", "sk-ant-api-real")
-
- reader := func() (string, error) {
- t.Fatal("readOAuthToken must not be invoked when non-empty ANTHROPIC_API_KEY is set")
- return "", nil
- }
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(nil, "/tmp/isolated", hostDir, slog.Default(), homeDir, reader)
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 0 {
- t.Fatalf("expected no CLAUDE_CODE_OAUTH_TOKEN with non-empty ANTHROPIC_API_KEY, got %d (%v)", got, env)
- }
-}
-
-// TestBuildClaudeEnvIsolatedEmptyOAuthTokenInCustomEnvAsUnpinned is the
-// custom_env-side mirror of the empty-value gate: an explicit
-// CLAUDE_CODE_OAUTH_TOKEN="" passed through custom_env (e.g. an agent
-// config field that the operator forgot to remove) must not block the
-// keychain reader. Same justification as the ANTHROPIC_API_KEY case —
-// silent strand at "Not logged in" while disguised as a pinned token.
-func TestBuildClaudeEnvIsolatedEmptyOAuthTokenInCustomEnvAsUnpinned(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) { return "sk-ant-oat-keychain", nil }
- hostDir, homeDir := defaultHostGate(t)
- env := buildClaudeEnvWith(
- map[string]string{"CLAUDE_CODE_OAUTH_TOKEN": ""},
- "/tmp/isolated",
- hostDir,
- slog.Default(),
- homeDir,
- reader,
- )
-
- // The keychain token must reach the child even though custom_env had
- // the key present with an empty value.
- if got := envValue(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != "sk-ant-oat-keychain" {
- t.Fatalf("expected keychain token when custom_env CLAUDE_CODE_OAUTH_TOKEN is empty, got %q", got)
- }
-}
-
-// TestBuildClaudeEnvIsolatedSkipsKeychainForCustomHostConfigDir pins the
-// "do not cross accounts" boundary the round-2 MUL-2603 review flagged
-// as Must-fix 1: when the host config source is a custom CLAUDE_CONFIG_DIR
-// (set via agent custom_env or daemon-host env), the isolated child must
-// NOT receive the daemon user's default `Claude Code-credentials` keychain
-// token. Claude Code 2.x maps custom dirs to suffixed keychain entries
-// (`Claude Code-credentials-<sha256(dir)[:8]>`) belonging to whatever
-// account `claude /login` was last run against under that dir, so
-// injecting the unsuffixed default entry would mix accounts — the same
-// boundary mirrorHostClaudeJSONIfMissing already enforces for
-// `.claude.json` (see TestMirrorHostClaudeJSONIfMissing_CustomHostDirSkipped).
-//
-// The reader closure uses t.Fatal so a regression that re-enables the
-// keychain read for custom dirs fails loud and obvious — silent
-// re-introduction is exactly how cross-account leaks slip past review.
-func TestBuildClaudeEnvIsolatedSkipsKeychainForCustomHostConfigDir(t *testing.T) {
- t.Parallel()
-
- reader := func() (string, error) {
- t.Fatal("readOAuthToken must NOT be invoked when host config dir is a custom CLAUDE_CONFIG_DIR — would inject the daemon user's default account into a managed/custom-dir agent")
- return "", nil
- }
- // Home points somewhere; hostConfigDir intentionally is NOT
- // $HOME/.claude — it's a managed/custom location an operator pinned.
- home := t.TempDir()
- customHost := filepath.Join(t.TempDir(), "managed-claude")
- homeDir := func() (string, error) { return home, nil }
-
- env := buildClaudeEnvWith(nil, "/tmp/isolated", customHost, slog.Default(), homeDir, reader)
-
- if got := countEnvEntries(env, "CLAUDE_CODE_OAUTH_TOKEN"); got != 0 {
- t.Fatalf("expected no CLAUDE_CODE_OAUTH_TOKEN to be injected for custom hostConfigDir, got %d (%v)", got, env)
- }
- // Isolation env itself must still be intact — the gate only suppresses
- // the keychain passthrough, it does not change CLAUDE_CONFIG_DIR.
- if got := countEnvEntries(env, "CLAUDE_CONFIG_DIR"); got != 1 {
- t.Fatalf("expected isolated CLAUDE_CONFIG_DIR to still be set, got %d entries", got)
- }
-}
-
-// TestIsDefaultHostClaudeConfigDir documents the gate's truth table at
-// the unit level so the keychain passthrough's host-dir boundary is
-// regression-tested even when buildClaudeEnvWith short-circuits earlier
-// (operator pinned auth, merge mode, etc.).
-func TestIsDefaultHostClaudeConfigDir(t *testing.T) {
- t.Parallel()
- const fakeHome = "/fake-home"
- okHome := func() (string, error) { return fakeHome, nil }
- emptyHome := func() (string, error) { return "", nil }
- errHome := func() (string, error) { return "", errors.New("no home for you") }
-
- cases := []struct {
- name string
- hostConfigDir string
- homeDir func() (string, error)
- want bool
- }{
- {"matches default", filepath.Join(fakeHome, ".claude"), okHome, true},
- {"custom dir under home", filepath.Join(fakeHome, "managed-claude"), okHome, false},
- {"completely unrelated dir", "/etc/claude-managed", okHome, false},
- {"empty hostConfigDir (merge mode)", "", okHome, false},
- {"empty home resolves to false", filepath.Join(fakeHome, ".claude"), emptyHome, false},
- {"home resolver error", filepath.Join(fakeHome, ".claude"), errHome, false},
- {"nil home resolver", filepath.Join(fakeHome, ".claude"), nil, false},
- }
- for _, tc := range cases {
- t.Run(tc.name, func(t *testing.T) {
- if got := isDefaultHostClaudeConfigDir(tc.hostConfigDir, tc.homeDir); got != tc.want {
- t.Fatalf("isDefaultHostClaudeConfigDir(%q, ...) = %v, want %v",
- tc.hostConfigDir, got, tc.want)
- }
- })
- }
-}
-
-// TestClaudeCLIScrubsOAuthTokenFromBashSubprocess is the safety-boundary
-// regression test backing the security comment in buildClaudeEnvWith:
-// surfacing the host OAuth token through CLAUDE_CODE_OAUTH_TOKEN is only
-// safe because Claude Code itself strips that variable from the env it
-// hands to the model-driven **Bash tool subprocess**, so a `printenv`
-// inside the model's bash invocation cannot echo the secret into the
-// agent transcript. The MUL-2603 review (Elon, round 3) flagged that
-// hard-coded proof markers like "UNSET" / "CONTROL-SET" still
-// false-passed any time the model only paraphrased the prompt without
-// invoking Bash — `strings.Contains` would match the literal that was
-// already in the prompt. This version replaces them with per-run
-// random nonces that are passed *only* via env vars (never written into
-// the prompt text); the prompt references the env var names, so the
-// nonce values can land in the transcript only if a real Bash
-// subprocess inherits those env vars and echoes them. The three
-// conjoined assertions are:
-//
-// 1. the canary CLAUDE_CODE_OAUTH_TOKEN value is NOT in the transcript
-// (the primary safety claim);
-// 2. the unsetNonce IS in the transcript — the Bash tool actually ran
-// AND saw CLAUDE_CODE_OAUTH_TOKEN as unset (the model cannot
-// paraphrase a fresh random value it never saw, so this rules out
-// the "model refused" / "model paraphrased the prompt" false pass);
-// 3. the controlNonce IS in the transcript — ordinary env propagation
-// works for the non-sensitive MUL2603_CONTROL variable, proving the
-// scrub is a targeted strip of CLAUDE_CODE_OAUTH_TOKEN, not a
-// side-effect of "the CLI sandboxes Bash with no env at all",
-// which would not be a security property we could rely on for
-// arbitrary future env-exposed secrets.
-//
-// The boundary intentionally narrows to the **Bash tool subprocess**.
-// We have not reproduced the env shape the CLI hands to hook
-// subprocesses (e.g. PreToolUse / PostToolUse hooks), so this test does
-// not assert anything about them — and neither do the code comment in
-// buildClaudeEnvWith nor the PR description. If a future feature
-// requires the same env-scrub property for hooks, a parallel hook
-// regression has to be added before relying on it.
-//
-// Skipped by default because it requires:
-// - macOS (the keychain-suffix path the passthrough exists for)
-// - the real `claude` CLI in PATH
-// - a working ANTHROPIC_API_KEY (the subprocess auth that lets the model
-// actually invoke the Bash tool — we cannot exercise the scrub
-// boundary without the model running)
-// - MULTICA_E2E_CLAUDE_OAUTH_SCRUB=1 (opt-in so CI never gets billed
-// for the model call)
-//
-// Run it locally on a macOS box where you are logged into both
-// `claude /login` and have an API key handy:
-//
-// MULTICA_E2E_CLAUDE_OAUTH_SCRUB=1 go test ./pkg/agent/ \
-// -run TestClaudeCLIScrubsOAuthTokenFromBashSubprocess -v
-//
-// A failure here means upstream Claude Code stopped scrubbing
-// CLAUDE_CODE_OAUTH_TOKEN before spawning Bash. In that case the
-// passthrough in buildClaudeEnvWith must move off env vars (e.g. write a
-// short-lived `apiKeyHelper` script that the CLI invokes synchronously)
-// before MUL-2603 can ship.
-func TestClaudeCLIScrubsOAuthTokenFromBashSubprocess(t *testing.T) {
- if os.Getenv("MULTICA_E2E_CLAUDE_OAUTH_SCRUB") != "1" {
- t.Skip("set MULTICA_E2E_CLAUDE_OAUTH_SCRUB=1 to run the live claude CLI env-scrub check")
- }
- if runtime.GOOS != "darwin" {
- t.Skip("env scrub test is only meaningful for the macOS keychain-suffix path")
- }
- if os.Getenv("ANTHROPIC_API_KEY") == "" {
- t.Skip("set ANTHROPIC_API_KEY so the model can be invoked to drive the Bash tool")
- }
- claudePath, err := exec.LookPath("claude")
- if err != nil {
- t.Skipf("claude CLI not in PATH: %v", err)
- }
-
- // Distinctive canary the model has no reason to produce on its own.
- // Long + structured so a substring match cannot false-positive on
- // "sk-ant-…" prefixes that legitimately appear in CLI help text.
- const (
- canary = "sk-ant-oat-leak-canary-CLAUDE_CODE_OAUTH_TOKEN-MUL2603-PROBE"
- controlValue = "mul2603-control-value-non-secret"
- )
-
- // Per-run random nonces. These are the proof-of-execution markers,
- // and they are passed to Bash *only* via env vars — never written
- // into the prompt text — so the model has no way to reproduce them
- // by paraphrasing the prompt. If a nonce appears in the transcript,
- // a real Bash subprocess inherited the env var and echoed it.
- nonceBytes := func(t *testing.T, label string) string {
- t.Helper()
- b := make([]byte, 16)
- if _, err := rand.Read(b); err != nil {
- t.Fatalf("rand.Read(%s): %v", label, err)
- }
- return hex.EncodeToString(b)
- }
- unsetNonce := nonceBytes(t, "unset")
- controlNonce := nonceBytes(t, "control")
-
- // Use the *user's* shell-resolved env plus the canary + control vars
- // and the two nonce vars. We do not use t.Setenv because the CLI is
- // spawned via exec.Command, not as a child of the test goroutine;
- // an explicit env list keeps the boundary obvious.
- env := append(os.Environ(),
- "CLAUDE_CODE_OAUTH_TOKEN="+canary,
- "MUL2603_CONTROL="+controlValue,
- "MUL2603_UNSET_NONCE="+unsetNonce,
- "MUL2603_CONTROL_NONCE="+controlNonce,
- )
-
- ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
- defer cancel()
- cmd := exec.CommandContext(ctx, claudePath,
- "--print",
- "--output-format", "text",
- "--allow-dangerously-skip-permissions",
- "--allowedTools", "Bash",
- )
- cmd.Env = env
- // The prompt asks Bash to run two `test -n` probes and emit a nonce
- // in each branch we care about:
- // - if CLAUDE_CODE_OAUTH_TOKEN is empty/unset (the safety case),
- // echo $MUL2603_UNSET_NONCE
- // - if MUL2603_CONTROL is non-empty (the env-still-flows control),
- // echo $MUL2603_CONTROL_NONCE
- // The prompt never contains the nonce *values* — only the variable
- // names. So a paraphrasing model that never spawns Bash cannot
- // produce either nonce in its prose; only a real Bash subprocess
- // with these env vars present will echo them.
- cmd.Stdin = strings.NewReader(
- "Please run this exact bash command and paste the raw output verbatim. " +
- "Do not paraphrase, do not redact, do not summarize:\n" +
- "`test -n \"$CLAUDE_CODE_OAUTH_TOKEN\" || echo \"$MUL2603_UNSET_NONCE\"; " +
- "test -n \"$MUL2603_CONTROL\" && echo \"$MUL2603_CONTROL_NONCE\"`",
- )
- out, err := cmd.CombinedOutput()
- if err != nil {
- t.Fatalf("claude --print failed: %v\noutput:\n%s", err, out)
- }
- body := string(out)
-
- // Primary safety assertion: the canary OAuth value never lands in the
- // transcript verbatim.
- if strings.Contains(body, canary) {
- t.Fatalf("CLAUDE_CODE_OAUTH_TOKEN leaked to Bash tool subprocess — Claude Code stopped scrubbing it.\nProof: canary %q present in transcript:\n%s",
- canary, body)
- }
- // Control-prong proves the scrub is *targeted*, not "Bash has no env".
- // Without this, a Claude Code change that walled Bash off entirely
- // would pass the canary check but break the security model we documented.
- // The nonce can only appear if Bash ran AND inherited MUL2603_CONTROL.
- if !strings.Contains(body, controlNonce) {
- t.Fatalf("Bash tool did not echo the control nonce — either Bash never ran or MUL2603_CONTROL did not propagate, which would mean the scrub has widened to all env vars and changes the security model we documented.\nTranscript:\n%s",
- body)
- }
- // Proof-of-execution: a real Bash subprocess ran the probe AND saw
- // CLAUDE_CODE_OAUTH_TOKEN as empty/unset (the false branch of
- // `test -n` echoed $MUL2603_UNSET_NONCE). The nonce value is not in
- // the prompt, so a paraphrasing/refusing model cannot fake it.
- if !strings.Contains(body, unsetNonce) {
- t.Fatalf("Bash tool either did not run or saw CLAUDE_CODE_OAUTH_TOKEN as SET — both invalidate the scrub assertion. The expected unset nonce never appeared in the transcript.\nTranscript:\n%s",
- body)
- }
-}
-
-func TestNewIsolatedClaudeConfigDirCreatesAndCleansUp(t *testing.T) {
- t.Parallel()
-
- parent := t.TempDir()
- dir, cleanup, err := newIsolatedClaudeConfigDir(parent, "", slog.Default())
- if err != nil {
- t.Fatalf("newIsolatedClaudeConfigDir: %v", err)
- }
- defer cleanup()
-
- if dir == "" {
- t.Fatal("expected non-empty dir")
- }
- if filepath.Dir(dir) != parent {
- t.Fatalf("expected dir under %q, got %q", parent, dir)
- }
- if info, err := os.Stat(dir); err != nil || !info.IsDir() {
- t.Fatalf("expected created dir to exist, stat err=%v", err)
- }
- // The dir may contain symlinks mirrored from the host's ~/.claude/ (auth
- // token, settings, etc. — see mirrorHostClaudeExceptSkills). What it must
- // NOT contain is a `skills/` entry; that is the entire point of the
- // isolation. Mirroring behaviour is exercised in dedicated tests below.
- if _, err := os.Lstat(filepath.Join(dir, "skills")); !os.IsNotExist(err) {
- t.Fatalf("expected no skills/ entry in isolated dir, stat err=%v", err)
- }
-
- // Cleanup is idempotent (Execute may double-defer in error paths).
- cleanup()
- cleanup()
- if _, err := os.Stat(dir); !os.IsNotExist(err) {
- t.Fatalf("expected dir removed, stat err=%v", err)
- }
-}
-
-// TestMirrorHostClaudeExceptSkills_PassesAuthAndSkipsSkills locks in the
-// invariant Elon flagged in review: the isolation must not also isolate the
-// Claude login token. Mirror reaches every non-skills entry — including
-// `.credentials.json`, the Linux/Windows store for the OAuth token — so a
-// host that has only "run `claude` to log in" (no ANTHROPIC_API_KEY) still
-// authenticates inside the isolated config dir.
-func TestMirrorHostClaudeExceptSkills_PassesAuthAndSkipsSkills(t *testing.T) {
- t.Parallel()
-
- host := t.TempDir()
- // Populate a realistic-ish ~/.claude/ layout.
- for _, sub := range []string{"skills", "agents", "commands", "plugins"} {
- if err := os.MkdirAll(filepath.Join(host, sub), 0o755); err != nil {
- t.Fatalf("mkdir %s: %v", sub, err)
- }
- }
- // A broken skill in `skills/`: if the mirror passes it through, the
- // regression Elon's review highlighted is back.
- if err := os.WriteFile(filepath.Join(host, "skills", "broken.md"), []byte("frontmatter-corrupt"), 0o644); err != nil {
- t.Fatalf("write broken skill: %v", err)
- }
- // The OAuth credential file is the asset the reviewer specifically flagged.
- if err := os.WriteFile(filepath.Join(host, ".credentials.json"), []byte(`{"token":"abc"}`), 0o600); err != nil {
- t.Fatalf("write credentials: %v", err)
- }
- if err := os.WriteFile(filepath.Join(host, "settings.json"), []byte(`{}`), 0o644); err != nil {
- t.Fatalf("write settings: %v", err)
- }
-
- dest := t.TempDir()
- if err := mirrorHostClaudeExceptSkills(host, dest); err != nil {
- t.Fatalf("mirror: %v", err)
- }
-
- // skills/ must be absent — claude would otherwise discover the broken
- // host skill through the symlink and crash before reading stdin (#3052).
- if _, err := os.Lstat(filepath.Join(dest, "skills")); !os.IsNotExist(err) {
- t.Fatalf("expected skills/ to be skipped, got stat err=%v", err)
- }
-
- // Everything else must reach the isolated dir with the same contents as
- // the host source. We resolve through the mirrored entry to confirm the
- // CLI sees real bytes whether the implementation used a symlink (Unix),
- // a junction (Windows), a hardlink (Windows no Developer Mode, same
- // volume), or a content copy (last-resort fallback). os.Stat follows
- // every variant, so the assertion is platform-agnostic.
- for _, expected := range []string{".credentials.json", "settings.json", "agents", "commands", "plugins"} {
- dst := filepath.Join(dest, expected)
- if _, err := os.Stat(dst); err != nil {
- t.Fatalf("expected %s mirrored and reachable, stat err=%v", expected, err)
- }
- }
-
- // The credential file should round-trip — claude reading
- // $CLAUDE_CONFIG_DIR/.credentials.json must see the live host token.
- got, err := os.ReadFile(filepath.Join(dest, ".credentials.json"))
- if err != nil {
- t.Fatalf("read mirrored credentials: %v", err)
- }
- if string(got) != `{"token":"abc"}` {
- t.Fatalf("mirrored credentials content drifted, got %q", got)
- }
-}
-
-// TestMirrorHostClaudeExceptSkills_MissingHostDirIsNoop documents that a host
-// with no `~/.claude/` (env-var-auth-only setups) is a supported state, not
-// an error. The isolated dir simply stays empty.
-func TestMirrorHostClaudeExceptSkills_MissingHostDirIsNoop(t *testing.T) {
- t.Parallel()
-
- dest := t.TempDir()
- err := mirrorHostClaudeExceptSkills(filepath.Join(t.TempDir(), "nope"), dest)
- if err == nil {
- t.Fatal("expected a read error for missing host dir")
- }
- // dest must remain untouched (no skills/, no other entries).
- entries, _ := os.ReadDir(dest)
- if len(entries) != 0 {
- t.Fatalf("expected empty dest on missing host, got %d entries", len(entries))
- }
-}
-
-func TestNewIsolatedClaudeConfigDirFallsBackToTemp(t *testing.T) {
- t.Parallel()
-
- // Empty cwd → falls back to OS temp dir without erroring.
- dir, cleanup, err := newIsolatedClaudeConfigDir("", "", slog.Default())
- if err != nil {
- t.Fatalf("expected fallback to OS temp, got err=%v", err)
- }
- defer cleanup()
-
- if !strings.HasPrefix(dir, os.TempDir()) {
- t.Fatalf("expected fallback under %q, got %q", os.TempDir(), dir)
- }
-}
-
func TestBuildClaudeArgsExtraArgsBeforeCustomArgsAndFiltersBoth(t *testing.T) {
args := buildClaudeArgs(ExecOptions{
ExtraArgs: []string{"--output-format", "text", "--max-budget-usd", "1.00"},
@@ -1562,550 +672,3 @@ func TestBuildClaudeArgsExtraArgsBeforeCustomArgsAndFiltersBoth(t *testing.T) {
t.Fatalf("expected extra args before custom args, got %v", args)
}
}
-
-// TestResolveHostClaudeConfigDir locks in the precedence Elon's review asked
-// for: agent custom_env wins over a daemon-host CLAUDE_CONFIG_DIR, which
-// wins over the documented default at `~/.claude`. Without this, switching
-// default mode to "ignore" would mirror the wrong source dir and overwrite
-// a valid CLAUDE_CONFIG_DIR pointing at e.g. a managed shared profile.
-func TestResolveHostClaudeConfigDir(t *testing.T) {
- // NOT parallel — t.Setenv mutates global env which conflicts with
- // concurrent tests reading CLAUDE_CONFIG_DIR.
-
- // 1. Agent custom_env wins over parent env.
- t.Setenv("CLAUDE_CONFIG_DIR", "/from/parent/env")
- got := resolveHostClaudeConfigDir(map[string]string{"CLAUDE_CONFIG_DIR": "/from/custom/env"})
- if got != "/from/custom/env" {
- t.Fatalf("agent custom_env should win, got %q", got)
- }
-
- // 2. Empty custom_env falls back to parent env.
- got = resolveHostClaudeConfigDir(map[string]string{"CLAUDE_CONFIG_DIR": ""})
- if got != "/from/parent/env" {
- t.Fatalf("parent env should win when custom_env is empty, got %q", got)
- }
- got = resolveHostClaudeConfigDir(nil)
- if got != "/from/parent/env" {
- t.Fatalf("parent env should win when custom_env is nil, got %q", got)
- }
-
- // 3. With neither set, falls back to `~/.claude`.
- t.Setenv("CLAUDE_CONFIG_DIR", "")
- got = resolveHostClaudeConfigDir(nil)
- home, err := os.UserHomeDir()
- if err != nil {
- t.Skipf("no UserHomeDir on this host: %v", err)
- }
- want := filepath.Join(home, ".claude")
- if got != want {
- t.Fatalf("default should be %q, got %q", want, got)
- }
-}
-
-// TestNewIsolatedClaudeConfigDirMirrorsCustomHostDir confirms the scratch
-// dir reflects the effective CLAUDE_CONFIG_DIR source, not unconditionally
-// `~/.claude/`. Previously the mirror was hardcoded to UserHomeDir, so an
-// operator who pinned CLAUDE_CONFIG_DIR at a managed install would get the
-// wrong credentials in the scratch dir.
-func TestNewIsolatedClaudeConfigDirMirrorsCustomHostDir(t *testing.T) {
- t.Parallel()
-
- host := t.TempDir()
- if err := os.WriteFile(filepath.Join(host, ".credentials.json"), []byte(`{"token":"from-custom-host"}`), 0o600); err != nil {
- t.Fatalf("seed credentials: %v", err)
- }
-
- dir, cleanup, err := newIsolatedClaudeConfigDir(t.TempDir(), host, slog.Default())
- if err != nil {
- t.Fatalf("newIsolatedClaudeConfigDir: %v", err)
- }
- defer cleanup()
-
- got, err := os.ReadFile(filepath.Join(dir, ".credentials.json"))
- if err != nil {
- t.Fatalf("read mirrored credentials from custom host: %v", err)
- }
- if string(got) != `{"token":"from-custom-host"}` {
- t.Fatalf("mirror sourced from wrong dir: got %q", got)
- }
-}
-
-// TestNewIsolatedClaudeConfigDirEmptyHostIsNoop documents the env-var-auth
-// case: with no host config dir (host has no `~/.claude/` and no
-// CLAUDE_CONFIG_DIR set anywhere), the scratch dir is created but empty and
-// nothing is mirrored. The CLI runs with `ANTHROPIC_API_KEY` only.
-func TestNewIsolatedClaudeConfigDirEmptyHostIsNoop(t *testing.T) {
- t.Parallel()
-
- dir, cleanup, err := newIsolatedClaudeConfigDir(t.TempDir(), "", slog.Default())
- if err != nil {
- t.Fatalf("newIsolatedClaudeConfigDir: %v", err)
- }
- defer cleanup()
-
- entries, err := os.ReadDir(dir)
- if err != nil {
- t.Fatalf("read scratch dir: %v", err)
- }
- if len(entries) != 0 {
- t.Fatalf("expected empty scratch dir with no host source, got %d entries", len(entries))
- }
-}
-
-// TestMirrorHostClaudeExceptSkillsWith_FallbackWhenSymlinkFails locks in the
-// Windows-no-Developer-Mode behaviour Elon's review asked for: when symlink
-// raises a permission error, the mirror still places the entry in the
-// scratch dir via a fallback (junction for dirs, hardlink/copy for files).
-// Tested via the lower-level seam so the assertion runs on Linux/macOS CI;
-// the production createDirLink / createFileLink wrappers encode the same
-// "try symlink first, then fall back" chain in their platform builds.
-func TestMirrorHostClaudeExceptSkillsWith_FallbackWhenSymlinkFails(t *testing.T) {
- t.Parallel()
-
- host := t.TempDir()
- if err := os.WriteFile(filepath.Join(host, ".credentials.json"), []byte(`{"token":"fallback"}`), 0o600); err != nil {
- t.Fatalf("seed credentials: %v", err)
- }
- if err := os.MkdirAll(filepath.Join(host, "agents"), 0o755); err != nil {
- t.Fatalf("seed agents dir: %v", err)
- }
- if err := os.WriteFile(filepath.Join(host, "agents", "global.md"), []byte("global agent"), 0o600); err != nil {
- t.Fatalf("seed agent file: %v", err)
- }
- // `skills/` must still be skipped even when the linker reports an
- // error — the broken-skill GitHub #3052 regression must not slip back.
- if err := os.MkdirAll(filepath.Join(host, "skills"), 0o755); err != nil {
- t.Fatalf("seed skills dir: %v", err)
- }
- if err := os.WriteFile(filepath.Join(host, "skills", "broken.md"), []byte("frontmatter-corrupt"), 0o600); err != nil {
- t.Fatalf("seed broken skill: %v", err)
- }
-
- dest := t.TempDir()
-
- // Simulated "Windows without Developer Mode": symlink always returns
- // EPERM. The fallback path must still land the entry in dest.
- failedSymlinkAttempts := 0
- fakeSymlinkErr := errors.New("simulated EPERM: symlink not permitted")
- dirLink := func(src, dst string) error {
- if err := os.Symlink(src, dst); err == nil {
- // Forcing failure: if a symlink would have worked, pretend it
- // didn't and engage the junction equivalent. We mimic the
- // junction by using os.MkdirAll (a junction behaves like a
- // directory entry from userspace) and copying the immediate
- // child files into it. For the test we only need the entry to
- // exist and be reachable; we do not need real recursive
- // equivalence.
- _ = os.Remove(dst)
- }
- failedSymlinkAttempts++
- _ = fakeSymlinkErr // referenced so the simulated-EPERM error is documented in the test body
- if err := os.MkdirAll(dst, 0o755); err != nil {
- return err
- }
- // Copy any direct children so the destination is non-empty and
- // the test can read through it.
- entries, err := os.ReadDir(src)
- if err != nil {
- return err
- }
- for _, e := range entries {
- data, err := os.ReadFile(filepath.Join(src, e.Name()))
- if err != nil {
- continue
- }
- _ = os.WriteFile(filepath.Join(dst, e.Name()), data, 0o600)
- }
- return nil
- }
- fileLink := func(src, dst string) error {
- if err := os.Symlink(src, dst); err == nil {
- _ = os.Remove(dst)
- }
- failedSymlinkAttempts++
- // Hardlink fallback first (this is what createFileLink does on
- // Windows when symlink is denied but the source/dest share a
- // volume). If hardlink also fails (e.g. cross-volume), fall back
- // to a content copy.
- if err := os.Link(src, dst); err == nil {
- return nil
- }
- return copyFile(src, dst)
- }
-
- if err := mirrorHostClaudeExceptSkillsWith(host, dest, dirLink, fileLink); err != nil {
- t.Fatalf("mirror with failing symlink: %v", err)
- }
-
- if failedSymlinkAttempts == 0 {
- t.Fatalf("expected fallback path to engage at least once")
- }
-
- // `.credentials.json` must round-trip through whatever fallback the
- // file linker used (hardlink or copy). This is the assertion Elon's
- // review pinned to "no `.credentials.json` ⇒ default ignore breaks
- // Claude Code auth on Windows".
- got, err := os.ReadFile(filepath.Join(dest, ".credentials.json"))
- if err != nil {
- t.Fatalf("read mirrored credentials after fallback: %v", err)
- }
- if string(got) != `{"token":"fallback"}` {
- t.Fatalf("mirrored credentials drifted after fallback, got %q", got)
- }
-
- // Sub-directories must also reach the destination via the dir
- // fallback (junction equivalent). We test reachability + child
- // content rather than the underlying file kind, because junctions,
- // symlinks, and the test's copy-based stand-in all present the same
- // userspace view.
- if _, err := os.Stat(filepath.Join(dest, "agents")); err != nil {
- t.Fatalf("agents/ not mirrored: %v", err)
- }
- gotChild, err := os.ReadFile(filepath.Join(dest, "agents", "global.md"))
- if err != nil {
- t.Fatalf("read agent child file: %v", err)
- }
- if string(gotChild) != "global agent" {
- t.Fatalf("agent child content drifted, got %q", gotChild)
- }
-
- // `skills/` must be absent regardless of fallback engagement.
- if _, err := os.Lstat(filepath.Join(dest, "skills")); !os.IsNotExist(err) {
- t.Fatalf("skills/ leaked into scratch dir on fallback path, stat err=%v", err)
- }
-}
-
-// TestMirrorHostClaudeExceptSkillsWith_PropagatesFirstLinkError makes sure
-// callers see a per-entry link failure when even the fallback fails — the
-// scratch-dir caller logs the error so operators chasing auth issues on
-// Windows can correlate the missing mirror with their permission setup.
-func TestMirrorHostClaudeExceptSkillsWith_PropagatesFirstLinkError(t *testing.T) {
- t.Parallel()
-
- host := t.TempDir()
- if err := os.WriteFile(filepath.Join(host, ".credentials.json"), []byte("x"), 0o600); err != nil {
- t.Fatalf("seed credentials: %v", err)
- }
-
- hardFail := errors.New("link refused after fallback")
- fail := func(src, dst string) error { return hardFail }
-
- err := mirrorHostClaudeExceptSkillsWith(host, t.TempDir(), fail, fail)
- if err == nil {
- t.Fatal("expected an error when every linker fails")
- }
- if !errors.Is(err, hardFail) {
- t.Fatalf("expected wrapped hardFail, got %v", err)
- }
-}
-
-// TestCopyFileRoundTrip exercises the last-resort content-copy fallback used
-// by createFileLink on Windows when both symlink and hardlink are
-// unavailable (e.g. cross-volume scratch dir). The copy must produce a
-// byte-for-byte equivalent destination so Claude Code reads the real
-// credential bytes.
-func TestCopyFileRoundTrip(t *testing.T) {
- t.Parallel()
-
- src := filepath.Join(t.TempDir(), "creds")
- if err := os.WriteFile(src, []byte(`{"token":"abc"}`), 0o600); err != nil {
- t.Fatalf("seed source: %v", err)
- }
- dst := filepath.Join(t.TempDir(), "creds-copy")
- if err := copyFile(src, dst); err != nil {
- t.Fatalf("copyFile: %v", err)
- }
- got, err := os.ReadFile(dst)
- if err != nil {
- t.Fatalf("read copy: %v", err)
- }
- if string(got) != `{"token":"abc"}` {
- t.Fatalf("copy drifted, got %q", got)
- }
- // EXCL semantics — copyFile refuses to overwrite an existing file so
- // a stale mirror entry never silently shadows a fresh source.
- if err := copyFile(src, dst); err == nil {
- t.Fatal("expected copyFile to refuse overwriting existing dst")
- }
-}
-
-// TestMirrorHostClaudeJSONIfMissing_DefaultLayoutMirrorsParentFile covers
-// the MUL-2661 regression: Claude Code's default layout stores `.claude.json`
-// at `$HOME/.claude.json`, a sibling of `~/.claude/`. The isolation mirror
-// must pull that file into the scratch dir or the CLI exits with
-// `Not logged in · Please run /login` on the first turn after the operator
-// opts into `ignore` mode.
-func TestMirrorHostClaudeJSONIfMissing_DefaultLayoutMirrorsParentFile(t *testing.T) {
- t.Parallel()
-
- fakeHome := t.TempDir()
- if err := os.MkdirAll(filepath.Join(fakeHome, ".claude"), 0o755); err != nil {
- t.Fatalf("seed fake ~/.claude: %v", err)
- }
- if err := os.WriteFile(filepath.Join(fakeHome, ".claude.json"), []byte(`{"loggedIn":true}`), 0o600); err != nil {
- t.Fatalf("seed fake $HOME/.claude.json: %v", err)
- }
- dest := t.TempDir()
-
- homeDir := func() (string, error) { return fakeHome, nil }
- if err := mirrorHostClaudeJSONIfMissingWith(filepath.Join(fakeHome, ".claude"), dest, homeDir, os.Symlink); err != nil {
- t.Fatalf("mirror: %v", err)
- }
-
- got, err := os.ReadFile(filepath.Join(dest, ".claude.json"))
- if err != nil {
- t.Fatalf("read mirrored .claude.json: %v", err)
- }
- if string(got) != `{"loggedIn":true}` {
- t.Fatalf("mirrored content drifted, got %q", got)
- }
-}
-
-// TestMirrorHostClaudeJSONIfMissing_AlreadyPresentNoop documents that a
-// `.claude.json` already in destDir (mirrored from inside a custom
-// CLAUDE_CONFIG_DIR by the main mirror loop) wins over the parent-level
-// `$HOME/.claude.json`. Re-linking would silently overwrite the
-// operator-pinned credentials with the default-account ones.
-func TestMirrorHostClaudeJSONIfMissing_AlreadyPresentNoop(t *testing.T) {
- t.Parallel()
-
- fakeHome := t.TempDir()
- if err := os.WriteFile(filepath.Join(fakeHome, ".claude.json"), []byte(`{"loggedIn":"home"}`), 0o600); err != nil {
- t.Fatalf("seed home .claude.json: %v", err)
- }
- dest := t.TempDir()
- if err := os.WriteFile(filepath.Join(dest, ".claude.json"), []byte(`{"loggedIn":"custom"}`), 0o600); err != nil {
- t.Fatalf("seed existing dest .claude.json: %v", err)
- }
-
- called := false
- fileLink := func(src, dst string) error {
- called = true
- return nil
- }
- homeDir := func() (string, error) { return fakeHome, nil }
- if err := mirrorHostClaudeJSONIfMissingWith(filepath.Join(fakeHome, ".claude"), dest, homeDir, fileLink); err != nil {
- t.Fatalf("mirror: %v", err)
- }
-
- if called {
- t.Fatal("fileLink must not be invoked when dest already has .claude.json")
- }
- got, _ := os.ReadFile(filepath.Join(dest, ".claude.json"))
- if string(got) != `{"loggedIn":"custom"}` {
- t.Fatalf("existing dest .claude.json was overwritten, got %q", got)
- }
-}
-
-// TestMirrorHostClaudeJSONIfMissing_CustomHostDirSkipped guards the
-// operator-pinned CLAUDE_CONFIG_DIR contract. A custom dir is expected to be
-// self-contained; pulling in `$HOME/.claude.json` on top would silently merge
-// a different account's login state.
-func TestMirrorHostClaudeJSONIfMissing_CustomHostDirSkipped(t *testing.T) {
- t.Parallel()
-
- fakeHome := t.TempDir()
- if err := os.WriteFile(filepath.Join(fakeHome, ".claude.json"), []byte(`{"loggedIn":"home"}`), 0o600); err != nil {
- t.Fatalf("seed home .claude.json: %v", err)
- }
- customHost := t.TempDir()
- dest := t.TempDir()
-
- called := false
- fileLink := func(src, dst string) error {
- called = true
- return nil
- }
- homeDir := func() (string, error) { return fakeHome, nil }
- if err := mirrorHostClaudeJSONIfMissingWith(customHost, dest, homeDir, fileLink); err != nil {
- t.Fatalf("mirror: %v", err)
- }
-
- if called {
- t.Fatal("fileLink must not be invoked when host dir is custom (not default $HOME/.claude)")
- }
- if _, err := os.Lstat(filepath.Join(dest, ".claude.json")); !os.IsNotExist(err) {
- t.Fatalf("dest .claude.json should remain absent, stat err=%v", err)
- }
-}
-
-// TestMirrorHostClaudeJSONIfMissing_MissingSourceNoop documents that a host
-// with no `$HOME/.claude.json` (fresh install, env-var-auth-only setup) is a
-// supported state. The mirror is a no-op and the scratch dir's lack of
-// `.claude.json` is left to the CLI to handle (it will surface its own
-// "not logged in" error, but the daemon does not pretend a file exists).
-func TestMirrorHostClaudeJSONIfMissing_MissingSourceNoop(t *testing.T) {
- t.Parallel()
-
- fakeHome := t.TempDir()
- dest := t.TempDir()
-
- called := false
- fileLink := func(src, dst string) error {
- called = true
- return nil
- }
- homeDir := func() (string, error) { return fakeHome, nil }
- if err := mirrorHostClaudeJSONIfMissingWith(filepath.Join(fakeHome, ".claude"), dest, homeDir, fileLink); err != nil {
- t.Fatalf("mirror: %v", err)
- }
-
- if called {
- t.Fatal("fileLink must not be invoked when $HOME/.claude.json is absent")
- }
-}
-
-// TestClaudeExecuteIsolatesProvidesClaudeJSONFromHome is the end-to-end
-// MUL-2661 regression: an agent opted into `skills_local=ignore` on a host
-// that uses Claude Code's default layout ($HOME/.claude.json sibling of
-// ~/.claude/) must still start successfully. Before the fix, the scratch
-// CLAUDE_CONFIG_DIR was missing `.claude.json` and the CLI exited with
-// `Not logged in · Please run /login` on the first turn.
-func TestClaudeExecuteIsolatesProvidesClaudeJSONFromHome(t *testing.T) {
- // NOT parallel — t.Setenv mutates global env (HOME + CLAUDE_CONFIG_DIR).
- if runtime.GOOS == "windows" {
- t.Skip("shell-script fixture is POSIX-only")
- }
-
- // Synthesize Claude Code's default split layout under a fake $HOME:
- // $FAKE_HOME/.claude/ — settings, agents, plugins, etc.
- // $FAKE_HOME/.claude.json — main config (login state)
- fakeHome := t.TempDir()
- if err := os.MkdirAll(filepath.Join(fakeHome, ".claude"), 0o755); err != nil {
- t.Fatalf("seed fake ~/.claude: %v", err)
- }
- if err := os.WriteFile(filepath.Join(fakeHome, ".claude", "settings.json"), []byte(`{}`), 0o644); err != nil {
- t.Fatalf("seed fake settings.json: %v", err)
- }
- const expectedConfig = "logged-in-default-layout"
- if err := os.WriteFile(filepath.Join(fakeHome, ".claude.json"), []byte(expectedConfig), 0o600); err != nil {
- t.Fatalf("seed fake $HOME/.claude.json: %v", err)
- }
-
- t.Setenv("HOME", fakeHome)
- // Ensure the host has no CLAUDE_CONFIG_DIR override — the regression
- // only manifests in the default split layout.
- t.Setenv("CLAUDE_CONFIG_DIR", "")
-
- // Fake claude binary that echoes the .claude.json it reads from the
- // scratch CLAUDE_CONFIG_DIR. Before the fix this echoed "MISSING"
- // because the mirror skipped the sibling file.
- fakePath := filepath.Join(t.TempDir(), "claude")
- script := "#!/bin/sh\n" +
- "cat >/dev/null\n" +
- "cfg=$(cat \"$CLAUDE_CONFIG_DIR/.claude.json\" 2>/dev/null || echo MISSING)\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"system\\\",\\\"session_id\\\":\\\"sess\\\"}\"\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"result\\\",\\\"subtype\\\":\\\"success\\\",\\\"is_error\\\":false,\\\"session_id\\\":\\\"sess\\\",\\\"result\\\":\\\"$cfg\\\"}\"\n"
- writeTestExecutable(t, fakePath, []byte(script))
-
- backend, err := New("claude", Config{ExecutablePath: fakePath, Logger: slog.Default()})
- if err != nil {
- t.Fatalf("new claude backend: %v", err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- session, err := backend.Execute(ctx, "ignored", ExecOptions{
- Cwd: t.TempDir(),
- Timeout: 5 * time.Second,
- SkillsLocal: "ignore",
- })
- if err != nil {
- t.Fatalf("execute: %v", err)
- }
- go func() {
- for range session.Messages {
- }
- }()
-
- select {
- case result := <-session.Result:
- if result.Status != "completed" {
- t.Fatalf("expected completed, got %q (err=%q)", result.Status, result.Error)
- }
- got := strings.TrimSpace(result.Output)
- if got == "MISSING" {
- t.Fatalf("MUL-2661 regression: .claude.json was not mirrored into the isolated dir")
- }
- if got != expectedConfig {
- t.Fatalf("expected $HOME/.claude.json mirrored, got %q", got)
- }
- case <-time.After(10 * time.Second):
- t.Fatal("timeout waiting for result")
- }
-}
-
-// TestClaudeExecuteIsolatesUsesCustomEnvSource confirms the runtime mirrors
-// from the agent's custom_env CLAUDE_CONFIG_DIR — the exact bug Elon's
-// review flagged: when an operator pins CLAUDE_CONFIG_DIR via custom_env,
-// the scratch dir must mirror *that* source, not `~/.claude`. Otherwise
-// default `ignore` mode would silently load the wrong credentials.
-func TestClaudeExecuteIsolatesUsesCustomEnvSource(t *testing.T) {
- t.Parallel()
- if runtime.GOOS == "windows" {
- t.Skip("shell-script fixture is POSIX-only")
- }
-
- // Build a synthetic "host Claude config dir" the agent will pin via
- // custom_env. The mirror should land its `.credentials.json` in the
- // scratch dir. The token value is a plain quote-free string so the
- // fake-claude shell script can echo it through stream-json's `result`
- // field without escape gymnastics.
- customHost := t.TempDir()
- const expectedToken = "from-custom-host-token-ok"
- if err := os.WriteFile(filepath.Join(customHost, ".credentials.json"), []byte(expectedToken), 0o600); err != nil {
- t.Fatalf("seed credentials: %v", err)
- }
-
- // Fake claude binary that prints the mirrored credentials content from
- // the scratch CLAUDE_CONFIG_DIR — we then assert that we see the
- // custom host's token, not whatever lives in real `~/.claude/`.
- fakePath := filepath.Join(t.TempDir(), "claude")
- script := "#!/bin/sh\n" +
- "cat >/dev/null\n" +
- "creds=$(cat \"$CLAUDE_CONFIG_DIR/.credentials.json\" 2>/dev/null || echo MISSING)\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"system\\\",\\\"session_id\\\":\\\"sess\\\"}\"\n" +
- "printf '%s\\n' \"{\\\"type\\\":\\\"result\\\",\\\"subtype\\\":\\\"success\\\",\\\"is_error\\\":false,\\\"session_id\\\":\\\"sess\\\",\\\"result\\\":\\\"$creds\\\"}\"\n"
- writeTestExecutable(t, fakePath, []byte(script))
-
- backend, err := New("claude", Config{
- ExecutablePath: fakePath,
- Logger: slog.Default(),
- Env: map[string]string{"CLAUDE_CONFIG_DIR": customHost},
- })
- if err != nil {
- t.Fatalf("new claude backend: %v", err)
- }
-
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- // Explicit SkillsLocal == "ignore" → backend builds scratch dir mirrored
- // from custom_env CLAUDE_CONFIG_DIR. (The platform default is "merge",
- // which would just preserve the host CLAUDE_CONFIG_DIR untouched and
- // never exercise the mirror path — see MUL-2603 product decision.)
- session, err := backend.Execute(ctx, "ignored", ExecOptions{
- Cwd: t.TempDir(),
- Timeout: 5 * time.Second,
- SkillsLocal: "ignore",
- })
- if err != nil {
- t.Fatalf("execute: %v", err)
- }
- go func() {
- for range session.Messages {
- }
- }()
-
- select {
- case result := <-session.Result:
- if result.Status != "completed" {
- t.Fatalf("expected completed, got %q (err=%q)", result.Status, result.Error)
- }
- got := strings.TrimSpace(result.Output)
- if got != expectedToken {
- t.Fatalf("expected credentials mirrored from custom CLAUDE_CONFIG_DIR, got %q", got)
- }
- case <-time.After(10 * time.Second):
- t.Fatal("timeout waiting for result")
- }
-}
diff --git a/server/pkg/db/generated/agent.sql.go b/server/pkg/db/generated/agent.sql.go
index b191481c9f..586c316e6a 100644
--- a/server/pkg/db/generated/agent.sql.go
+++ b/server/pkg/db/generated/agent.sql.go
@@ -14,7 +14,7 @@ import (
const archiveAgent = `-- name: ArchiveAgent :one
UPDATE agent SET archived_at = now(), archived_by = $2, updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type ArchiveAgentParams struct {
@@ -48,7 +48,6 @@ func (q *Queries) ArchiveAgent(ctx context.Context, arg ArchiveAgentParams) (Age
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -57,7 +56,7 @@ const archiveAgentsByIDs = `-- name: ArchiveAgentsByIDs :many
UPDATE agent
SET archived_at = now(), archived_by = $1, updated_at = now()
WHERE id = ANY($2::uuid[]) AND archived_at IS NULL
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type ArchiveAgentsByIDsParams struct {
@@ -105,7 +104,6 @@ func (q *Queries) ArchiveAgentsByIDs(ctx context.Context, arg ArchiveAgentsByIDs
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
); err != nil {
return nil, err
}
@@ -121,7 +119,7 @@ const archiveAgentsByRuntime = `-- name: ArchiveAgentsByRuntime :many
UPDATE agent
SET archived_at = now(), archived_by = $1, updated_at = now()
WHERE runtime_id = ANY($2::uuid[]) AND archived_at IS NULL
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type ArchiveAgentsByRuntimeParams struct {
@@ -165,7 +163,6 @@ func (q *Queries) ArchiveAgentsByRuntime(ctx context.Context, arg ArchiveAgentsB
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
); err != nil {
return nil, err
}
@@ -586,7 +583,7 @@ func (q *Queries) ClaimAgentTask(ctx context.Context, agentID pgtype.UUID) (Agen
const clearAgentMcpConfig = `-- name: ClearAgentMcpConfig :one
UPDATE agent SET mcp_config = NULL, updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
func (q *Queries) ClearAgentMcpConfig(ctx context.Context, id pgtype.UUID) (Agent, error) {
@@ -615,7 +612,6 @@ func (q *Queries) ClearAgentMcpConfig(ctx context.Context, id pgtype.UUID) (Agen
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -623,7 +619,7 @@ func (q *Queries) ClearAgentMcpConfig(ctx context.Context, id pgtype.UUID) (Agen
const clearAgentThinkingLevel = `-- name: ClearAgentThinkingLevel :one
UPDATE agent SET thinking_level = NULL, updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
// Explicit NULL-clear for thinking_level. COALESCE-based UpdateAgent cannot
@@ -655,7 +651,6 @@ func (q *Queries) ClearAgentThinkingLevel(ctx context.Context, id pgtype.UUID) (
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -728,10 +723,9 @@ const createAgent = `-- name: CreateAgent :one
INSERT INTO agent (
workspace_id, name, description, avatar_url, runtime_mode,
runtime_config, runtime_id, visibility, max_concurrent_tasks, owner_id,
- instructions, custom_env, custom_args, mcp_config, model, thinking_level,
- skills_local
-) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+ instructions, custom_env, custom_args, mcp_config, model, thinking_level
+) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type CreateAgentParams struct {
@@ -751,7 +745,6 @@ type CreateAgentParams struct {
McpConfig []byte `json:"mcp_config"`
Model pgtype.Text `json:"model"`
ThinkingLevel pgtype.Text `json:"thinking_level"`
- SkillsLocal string `json:"skills_local"`
}
func (q *Queries) CreateAgent(ctx context.Context, arg CreateAgentParams) (Agent, error) {
@@ -772,7 +765,6 @@ func (q *Queries) CreateAgent(ctx context.Context, arg CreateAgentParams) (Agent
arg.McpConfig,
arg.Model,
arg.ThinkingLevel,
- arg.SkillsLocal,
)
var i Agent
err := row.Scan(
@@ -798,7 +790,6 @@ func (q *Queries) CreateAgent(ctx context.Context, arg CreateAgentParams) (Agent
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -1214,7 +1205,7 @@ func (q *Queries) FailStaleTasks(ctx context.Context, arg FailStaleTasksParams)
}
const getAgent = `-- name: GetAgent :one
-SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local FROM agent
+SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level FROM agent
WHERE id = $1
`
@@ -1244,13 +1235,12 @@ func (q *Queries) GetAgent(ctx context.Context, id pgtype.UUID) (Agent, error) {
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
const getAgentInWorkspace = `-- name: GetAgentInWorkspace :one
-SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local FROM agent
+SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level FROM agent
WHERE id = $1 AND workspace_id = $2
`
@@ -1285,7 +1275,6 @@ func (q *Queries) GetAgentInWorkspace(ctx context.Context, arg GetAgentInWorkspa
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -1590,7 +1579,7 @@ func (q *Queries) LinkTaskToIssue(ctx context.Context, arg LinkTaskToIssueParams
}
const listActiveAgentsByRuntime = `-- name: ListActiveAgentsByRuntime :many
-SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local FROM agent
+SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level FROM agent
WHERE runtime_id = $1 AND archived_at IS NULL
ORDER BY name ASC
`
@@ -1633,7 +1622,6 @@ func (q *Queries) ListActiveAgentsByRuntime(ctx context.Context, runtimeID pgtyp
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
); err != nil {
return nil, err
}
@@ -1646,7 +1634,7 @@ func (q *Queries) ListActiveAgentsByRuntime(ctx context.Context, runtimeID pgtyp
}
const listActiveAgentsByRuntimeForUpdate = `-- name: ListActiveAgentsByRuntimeForUpdate :many
-SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local FROM agent
+SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level FROM agent
WHERE runtime_id = $1 AND archived_at IS NULL
ORDER BY name ASC
FOR UPDATE
@@ -1692,7 +1680,6 @@ func (q *Queries) ListActiveAgentsByRuntimeForUpdate(ctx context.Context, runtim
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
); err != nil {
return nil, err
}
@@ -1814,7 +1801,7 @@ func (q *Queries) ListAgentTasks(ctx context.Context, agentID pgtype.UUID) ([]Ag
}
const listAgents = `-- name: ListAgents :many
-SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local FROM agent
+SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level FROM agent
WHERE workspace_id = $1 AND archived_at IS NULL
ORDER BY created_at ASC
`
@@ -1851,7 +1838,6 @@ func (q *Queries) ListAgents(ctx context.Context, workspaceID pgtype.UUID) ([]Ag
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
); err != nil {
return nil, err
}
@@ -1864,7 +1850,7 @@ func (q *Queries) ListAgents(ctx context.Context, workspaceID pgtype.UUID) ([]Ag
}
const listAllAgents = `-- name: ListAllAgents :many
-SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local FROM agent
+SELECT id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level FROM agent
WHERE workspace_id = $1
ORDER BY created_at ASC
`
@@ -1901,7 +1887,6 @@ func (q *Queries) ListAllAgents(ctx context.Context, workspaceID pgtype.UUID) ([
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
); err != nil {
return nil, err
}
@@ -2286,7 +2271,7 @@ SET status = CASE WHEN EXISTS (
) THEN 'working' ELSE 'idle' END,
updated_at = now()
WHERE a.id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
func (q *Queries) RefreshAgentStatusFromTasks(ctx context.Context, id pgtype.UUID) (Agent, error) {
@@ -2315,7 +2300,6 @@ func (q *Queries) RefreshAgentStatusFromTasks(ctx context.Context, id pgtype.UUI
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -2323,7 +2307,7 @@ func (q *Queries) RefreshAgentStatusFromTasks(ctx context.Context, id pgtype.UUI
const restoreAgent = `-- name: RestoreAgent :one
UPDATE agent SET archived_at = NULL, archived_by = NULL, updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
func (q *Queries) RestoreAgent(ctx context.Context, id pgtype.UUID) (Agent, error) {
@@ -2352,7 +2336,6 @@ func (q *Queries) RestoreAgent(ctx context.Context, id pgtype.UUID) (Agent, erro
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -2414,10 +2397,9 @@ UPDATE agent SET
mcp_config = COALESCE($14, mcp_config),
model = COALESCE($15, model),
thinking_level = COALESCE($16, thinking_level),
- skills_local = COALESCE($17, skills_local),
updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type UpdateAgentParams struct {
@@ -2437,7 +2419,6 @@ type UpdateAgentParams struct {
McpConfig []byte `json:"mcp_config"`
Model pgtype.Text `json:"model"`
ThinkingLevel pgtype.Text `json:"thinking_level"`
- SkillsLocal pgtype.Text `json:"skills_local"`
}
func (q *Queries) UpdateAgent(ctx context.Context, arg UpdateAgentParams) (Agent, error) {
@@ -2458,7 +2439,6 @@ func (q *Queries) UpdateAgent(ctx context.Context, arg UpdateAgentParams) (Agent
arg.McpConfig,
arg.Model,
arg.ThinkingLevel,
- arg.SkillsLocal,
)
var i Agent
err := row.Scan(
@@ -2484,7 +2464,6 @@ func (q *Queries) UpdateAgent(ctx context.Context, arg UpdateAgentParams) (Agent
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -2493,7 +2472,7 @@ const updateAgentCustomEnv = `-- name: UpdateAgentCustomEnv :one
UPDATE agent
SET custom_env = $2, updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type UpdateAgentCustomEnvParams struct {
@@ -2532,7 +2511,6 @@ func (q *Queries) UpdateAgentCustomEnv(ctx context.Context, arg UpdateAgentCusto
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
@@ -2540,7 +2518,7 @@ func (q *Queries) UpdateAgentCustomEnv(ctx context.Context, arg UpdateAgentCusto
const updateAgentStatus = `-- name: UpdateAgentStatus :one
UPDATE agent SET status = $2, updated_at = now()
WHERE id = $1
-RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level, skills_local
+RETURNING id, workspace_id, name, avatar_url, runtime_mode, runtime_config, visibility, status, max_concurrent_tasks, owner_id, created_at, updated_at, description, runtime_id, instructions, archived_at, archived_by, custom_env, custom_args, mcp_config, model, thinking_level
`
type UpdateAgentStatusParams struct {
@@ -2574,7 +2552,6 @@ func (q *Queries) UpdateAgentStatus(ctx context.Context, arg UpdateAgentStatusPa
&i.McpConfig,
&i.Model,
&i.ThinkingLevel,
- &i.SkillsLocal,
)
return i, err
}
diff --git a/server/pkg/db/generated/models.go b/server/pkg/db/generated/models.go
index cda61871f0..73e9423652 100644
--- a/server/pkg/db/generated/models.go
+++ b/server/pkg/db/generated/models.go
@@ -44,7 +44,6 @@ type Agent struct {
McpConfig []byte `json:"mcp_config"`
Model pgtype.Text `json:"model"`
ThinkingLevel pgtype.Text `json:"thinking_level"`
- SkillsLocal string `json:"skills_local"`
}
type AgentRuntime struct {
diff --git a/server/pkg/db/queries/agent.sql b/server/pkg/db/queries/agent.sql
index b7a34e8882..21401e3c82 100644
--- a/server/pkg/db/queries/agent.sql
+++ b/server/pkg/db/queries/agent.sql
@@ -20,9 +20,8 @@ WHERE id = $1 AND workspace_id = $2;
INSERT INTO agent (
workspace_id, name, description, avatar_url, runtime_mode,
runtime_config, runtime_id, visibility, max_concurrent_tasks, owner_id,
- instructions, custom_env, custom_args, mcp_config, model, thinking_level,
- skills_local
-) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
+ instructions, custom_env, custom_args, mcp_config, model, thinking_level
+) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
RETURNING *;
-- name: UpdateAgent :one
@@ -42,7 +41,6 @@ UPDATE agent SET
mcp_config = COALESCE(sqlc.narg('mcp_config'), mcp_config),
model = COALESCE(sqlc.narg('model'), model),
thinking_level = COALESCE(sqlc.narg('thinking_level'), thinking_level),
- skills_local = COALESCE(sqlc.narg('skills_local'), skills_local),
updated_at = now()
WHERE id = $1
RETURNING *;