Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/agent/__tests__/__snapshots__/commandments.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ When a skill provides a numbered or bulleted list of questions, translate the en
After \`wizard_ask\` returns, use the answers directly — do not re-ask in text, and do not call \`wizard_ask\` again to confirm a field the user already answered.
Correcting a rejected value is the one exception, and it is expected: when whatever you handed an answer to rejects it — a connection that fails, a host or key the API calls invalid, a permission error — ask again for only the fields that were wrong, reuse the same \`subject\`, and say what was rejected and what a valid value looks like. A value the user could fix in one keystroke is never a reason to abandon the step for a link they have to follow themselves. Stop after a couple of attempts on one subject. A dismissed or timed-out ask is not this case — the result names the fields it did not collect and why, and that is a decline, so fall back instead of re-asking.
Use the Task tools to plan and track the whole run so the user always sees where you are. Create the task list once you understand the work — after you load and skim the skill workflow, not before — in a single tool call, in the order you will run them, with one task per stage covering the whole run through to instrumenting events, creating the dashboard, and writing the setup report. Give each an imperative subject AND an \`activeForm\` (the present-continuous label the panel shows while it runs, e.g. subject "Install SDK" / activeForm "Installing SDK"). Keep the list current: add a task the moment you discover work it is missing.
Try to keep exactly ONE task \`in_progress\`. \`TaskUpdate\` it to \`in_progress\` right before you start that stage, and to \`completed\` the instant you finish it — one at a time, never batched at the end. Only mark \`completed\` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it \`in_progress\` and add a task for the fix.
Try to keep exactly ONE task \`in_progress\`. \`TaskUpdate\` it to \`in_progress\` right before you start that stage, and to \`completed\` the instant you finish it — one at a time, never batched at the end. Never spend a whole turn on \`TaskUpdate\` alone: when transitioning between stages, pair \`TaskUpdate\` (\`completed\` for the finished stage and \`in_progress\` for the next) with the next stage’s first tool call in the same turn. Only mark \`completed\` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it \`in_progress\` and add a task for the fix.
After you complete a task, take the next one in order (lowest id first — earlier stages set up later ones), mark it \`in_progress\`, and continue. Driving the list in order top to bottom is how you finish every stage.
Each task subject is SHORT — a few words naming only the stage of work: "Analyze project", "Install SDK", "Initialize PostHog", "Instrument events", "Set env vars", "Verify", "Create dashboard". No file or directory names, no framework/router/package names, no specific event names, and no parenthetical "(...)" detail. The detail belongs in the work and the \`activeForm\`, not the subject."
`;
Expand Down Expand Up @@ -81,7 +81,7 @@ When a skill provides a numbered or bulleted list of questions, translate the en
After \`wizard_ask\` returns, use the answers directly — do not re-ask in text, and do not call \`wizard_ask\` again to confirm a field the user already answered.
Correcting a rejected value is the one exception, and it is expected: when whatever you handed an answer to rejects it — a connection that fails, a host or key the API calls invalid, a permission error — ask again for only the fields that were wrong, reuse the same \`subject\`, and say what was rejected and what a valid value looks like. A value the user could fix in one keystroke is never a reason to abandon the step for a link they have to follow themselves. Stop after a couple of attempts on one subject. A dismissed or timed-out ask is not this case — the result names the fields it did not collect and why, and that is a decline, so fall back instead of re-asking.
Use the Task tools to plan and track the whole run so the user always sees where you are. Create the task list once you understand the work — after you load and skim the skill workflow, not before — in a single tool call, in the order you will run them, with one task per stage covering the whole run through to instrumenting events, creating the dashboard, and writing the setup report. Give each an imperative subject AND an \`activeForm\` (the present-continuous label the panel shows while it runs, e.g. subject "Install SDK" / activeForm "Installing SDK"). Keep the list current: add a task the moment you discover work it is missing.
Try to keep exactly ONE task \`in_progress\`. \`TaskUpdate\` it to \`in_progress\` right before you start that stage, and to \`completed\` the instant you finish it — one at a time, never batched at the end. Only mark \`completed\` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it \`in_progress\` and add a task for the fix.
Try to keep exactly ONE task \`in_progress\`. \`TaskUpdate\` it to \`in_progress\` right before you start that stage, and to \`completed\` the instant you finish it — one at a time, never batched at the end. Never spend a whole turn on \`TaskUpdate\` alone: when transitioning between stages, pair \`TaskUpdate\` (\`completed\` for the finished stage and \`in_progress\` for the next) with the next stage’s first tool call in the same turn. Only mark \`completed\` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it \`in_progress\` and add a task for the fix.
After you complete a task, take the next one in order (lowest id first — earlier stages set up later ones), mark it \`in_progress\`, and continue. Driving the list in order top to bottom is how you finish every stage.
Each task subject is SHORT — a few words naming only the stage of work: "Analyze project", "Install SDK", "Initialize PostHog", "Instrument events", "Set env vars", "Verify", "Create dashboard". No file or directory names, no framework/router/package names, no specific event names, and no parenthetical "(...)" detail. The detail belongs in the work and the \`activeForm\`, not the subject.

Expand Down Expand Up @@ -182,7 +182,7 @@ ALWAYS surface a custom-scout proposal in step 6b: bring the user your one or tw
Rank candidates at the discriminator level, not the category level. "Covered" only means an enabled scout would actually FIRE for that failure mode: a conversion-rate watcher does not catch entry volume collapsing; a Stripe-transaction watcher does not catch a lead form going silent. A surface whose failure mode has no firing condition among the enabled scouts is your strongest candidate.
Be honest in the option descriptions: if a candidate overlaps something an enabled scout partially watches, say so in its description rather than dropping the candidate. The user chooses with full information; you do not gatekeep on their behalf.
Use the Task tools to plan and track the whole run so the user always sees where you are. Create the task list once you understand the work — after you load and skim the skill workflow, not before — in a single tool call, in the order you will run them, with one task per stage covering the whole run through to instrumenting events, creating the dashboard, and writing the setup report. Give each an imperative subject AND an \`activeForm\` (the present-continuous label the panel shows while it runs, e.g. subject "Install SDK" / activeForm "Installing SDK"). Keep the list current: add a task the moment you discover work it is missing.
Try to keep exactly ONE task \`in_progress\`. \`TaskUpdate\` it to \`in_progress\` right before you start that stage, and to \`completed\` the instant you finish it — one at a time, never batched at the end. Only mark \`completed\` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it \`in_progress\` and add a task for the fix.
Try to keep exactly ONE task \`in_progress\`. \`TaskUpdate\` it to \`in_progress\` right before you start that stage, and to \`completed\` the instant you finish it — one at a time, never batched at the end. Never spend a whole turn on \`TaskUpdate\` alone: when transitioning between stages, pair \`TaskUpdate\` (\`completed\` for the finished stage and \`in_progress\` for the next) with the next stage’s first tool call in the same turn. Only mark \`completed\` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it \`in_progress\` and add a task for the fix.
After you complete a task, take the next one in order (lowest id first — earlier stages set up later ones), mark it \`in_progress\`, and continue. Driving the list in order top to bottom is how you finish every stage.
Each task subject is SHORT — a few words naming only the stage of work: "Analyze project", "Install SDK", "Initialize PostHog", "Instrument events", "Set env vars", "Verify", "Create dashboard". No file or directory names, no framework/router/package names, no specific event names, and no parenthetical "(...)" detail. The detail belongs in the work and the \`activeForm\`, not the subject.

Expand Down
2 changes: 1 addition & 1 deletion src/agent/__tests__/commandments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('commandments by axis', () => {
'never reach an orchestrator task on %s',
(harness) => {
expect(prompt(harness, Sequence.orchestrator)).not.toMatch(
/TaskUpdate|TaskCreate|Task tools|task list/,
/TaskUpdate|TaskCreate|TaskGet|TaskList|Task tools|task list/i,
);
},
);
Expand Down
21 changes: 21 additions & 0 deletions src/agent/__tests__/initialize-agent.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
BASE_ALLOWED_TOOLS,
TaskTool,
initializeAgent,
resolveRunToolLists,
type AgentConfig,
} from '@agent/agent-interface';
import { WIZARD_TOOL_NAMES, createWizardToolsServer } from '@agent/tools';
import { Sequence } from '@shared/constants';
import { HostResolution } from '@shared/host-resolution';
import type { WizardRunOptions } from '@utils/types';

Expand Down Expand Up @@ -84,3 +87,21 @@ it('leaves publish_program_result out of the tools every program gets', () => {
WIZARD_TOOL_NAMES.publishProgramResult,
);
});

it('removes linear Task* tools on orchestrator runs while keeping them on linear runs', () => {
const orch = resolveRunToolLists({
sequence: Sequence.orchestrator,
disallowedTools: ['enqueue_task'],
});
for (const tool of Object.values(TaskTool)) {
expect(orch.allowedTools).not.toContain(tool);
expect(orch.disallowedTools).toContain(tool);
}
expect(orch.disallowedTools).toContain('enqueue_task');

const linear = resolveRunToolLists({ sequence: Sequence.linear });
for (const tool of Object.values(TaskTool)) {
expect(linear.allowedTools).toContain(tool);
expect(linear.disallowedTools).not.toContain(tool);
}
});
45 changes: 34 additions & 11 deletions src/agent/agent-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,12 +1080,7 @@ export async function runAgent(
// Per-program allow/disallow lists tweak BASE_ALLOWED_TOOLS. Skills are
// enabled via the `skills` query option; PostHog MCP tools come through
// `mcpServers`. Neither belongs in this list.
const disallow = new Set(agentConfig.disallowedTools ?? []);
const allowedTools = (
agentConfig.readOnly
? READ_ONLY_TOOLS
: [...BASE_ALLOWED_TOOLS, ...(agentConfig.allowedTools ?? [])]
).filter((t) => !disallow.has(t) && !CAN_USE_TOOL_FILE_TOOLS.has(t));
const { allowedTools, disallowedTools } = resolveRunToolLists(agentConfig);

// Subagents dispatched via the Agent tool don't inherit the parent's
// MCP servers by default — so general-purpose subagents can't see the
Expand Down Expand Up @@ -1148,9 +1143,8 @@ export async function runAgent(
// (sdk.d.ts: AgentDefinition has its own disallowedTools, and
// `tools: undefined` means "inherit all"). Without this, a program
// that disallows wizard_ask still leaks it to dispatched subagents.
disallowedTools: agentConfig.disallowedTools
? [...agentConfig.disallowedTools]
: undefined,
disallowedTools:
disallowedTools.length > 0 ? disallowedTools : undefined,
},
},
// Load skills from project's .claude/skills/ directory
Expand All @@ -1168,6 +1162,7 @@ export async function runAgent(
// 'Skill' in allowedTools in favor of this option.)
skills: agentConfig.readOnly ? [] : 'all',
allowedTools,
...(disallowedTools.length > 0 ? { disallowedTools } : {}),
sandbox: {
enabled: true,
// SDK 0.2.91 made failIfUnavailable default to true when enabled is
Expand Down Expand Up @@ -1275,7 +1270,7 @@ export async function runAgent(
{
readOnly: agentConfig.readOnly,
wizardAskPending: agentConfig.getPendingQuestion?.() != null,
disallowedTools: agentConfig.disallowedTools,
disallowedTools,
onDebug: (line) => debugLine(emit, options, line),
},
);
Expand Down Expand Up @@ -1923,7 +1918,7 @@ export const BASE_ALLOWED_TOOLS: readonly string[] = [
'Glob',
'Bash',
// Task list tools (replaced TodoWrite in 0.3.142). Commandments instruct
// the agent to call TaskCreate/TaskUpdate to surface progress in the TUI.
// linear agents to call TaskCreate/TaskUpdate to surface progress in the TUI.
...Object.values(TaskTool),
'ListMcpResourcesTool',
// publish_program_result is opt-in: a program that writes the result lists it in allowedTools.
Expand All @@ -1932,6 +1927,34 @@ export const BASE_ALLOWED_TOOLS: readonly string[] = [
),
];

/**
* Resolve effective allow/disallow tool lists for an Anthropic SDK run.
* Linear Task* tools are stripped and disallowed on orchestrator runs so
* linear todo tools never pollute task sessions or their subagents.
*/
export function resolveRunToolLists(config: {
sequence: Sequence;
readOnly?: boolean;
allowedTools?: readonly string[];
disallowedTools?: readonly string[];
}): { allowedTools: string[]; disallowedTools: string[] } {
const disallowedTools = [
...new Set([
...(config.disallowedTools ?? []),
...(config.sequence === Sequence.orchestrator
? Object.values(TaskTool)
: []),
]),
];
const disallow = new Set(disallowedTools);
const allowedTools = (
config.readOnly
? READ_ONLY_TOOLS
: [...BASE_ALLOWED_TOOLS, ...(config.allowedTools ?? [])]
).filter((t) => !disallow.has(t) && !CAN_USE_TOOL_FILE_TOOLS.has(t));
return { allowedTools, disallowedTools };
}

type TaskEntry = {
id?: string;
source?: string;
Expand Down
1 change: 1 addition & 0 deletions src/agent/runner/__tests__/switchboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ describe('switchboard model allow-list', () => {
'gpt-5.6-sol',
'gpt-5.6-terra',
'gpt-6-sol',
'gpt-6.2-sol',
];
const bare = (model: string): string => model.replace(/^openai\//, '');

Expand Down
12 changes: 9 additions & 3 deletions src/agent/runner/sequence/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ async function executeLinear(
);
if (signal?.aborted) return aborted();
if (installResult.kind !== 'ok') {
return failed(installFailure(run.integrationLabel, installResult));
if (!run.optionalSkill) {
return failed(installFailure(run.integrationLabel, installResult));
}
logToFile(
`[agent-runner] optional skill ${run.skillId} install failed (${installResult.kind}); falling back to runtime discovery`,
);
} else {
skillPath = installResult.path;
logToFile(`[agent-runner] skill installed at ${skillPath}`);
}
skillPath = installResult.path;
logToFile(`[agent-runner] skill installed at ${skillPath}`);
}

let sdkSkillPaths: string[] = [];
Expand Down
2 changes: 2 additions & 0 deletions src/agent/runner/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface AgentRunDefinition {
integrationLabel: string;
/** Skill ID to pre-install. Omit for agent-driven skill discovery. */
skillId?: string;
/** When true, a failed pre-install logs and falls back to runtime discovery instead of aborting. */
optionalSkill?: boolean;
/** Additional program-specific prompt instructions. Appended after the default project prompt. */
customPrompt?: (ctx: PromptContext) => string;
prompt?: (ctx: PromptContext) => string; // replaces the assembled project prompt; linear
Expand Down
20 changes: 2 additions & 18 deletions src/agent/runner/switchboard/commandments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,12 @@
import { Harness, Sequence } from '@shared/constants';
import { WIZARD_COMMANDMENTS } from '../../commandments';
import { piRuntimeNotes, type RuntimeCaps } from '../harness/pi/runtime-notes';
import { LINEAR_COMMANDMENTS } from './linear-commandments';

// ── Sequence axis ───────────────────────────────────────────────────────

/**
* LINEAR only. One session drives the whole run and holds the Task tools; an
* orchestrator task session holds none of them and reports through
* `complete_task`, so naming them there only earns a "no task tool available"
* remark. True on every harness — both mount the Task tools on linear and
* neither does for a task session.
*/
const TASK_LIST_MANAGEMENT = [
'Use the Task tools to plan and track the whole run so the user always sees where you are. Create the task list once you understand the work — after you load and skim the skill workflow, not before — in a single tool call, in the order you will run them, with one task per stage covering the whole run through to instrumenting events, creating the dashboard, and writing the setup report. Give each an imperative subject AND an `activeForm` (the present-continuous label the panel shows while it runs, e.g. subject "Install SDK" / activeForm "Installing SDK"). Keep the list current: add a task the moment you discover work it is missing.',

'Try to keep exactly ONE task `in_progress`. `TaskUpdate` it to `in_progress` right before you start that stage, and to `completed` the instant you finish it — one at a time, never batched at the end. Only mark `completed` when the work is genuinely done; if the build fails, a step is partial, or you hit a blocker, keep it `in_progress` and add a task for the fix.',

'After you complete a task, take the next one in order (lowest id first — earlier stages set up later ones), mark it `in_progress`, and continue. Driving the list in order top to bottom is how you finish every stage.',

'Each task subject is SHORT — a few words naming only the stage of work: "Analyze project", "Install SDK", "Initialize PostHog", "Instrument events", "Set env vars", "Verify", "Create dashboard". No file or directory names, no framework/router/package names, no specific event names, and no parenthetical "(...)" detail. The detail belongs in the work and the `activeForm`, not the subject.',
];

const SEQUENCE_COMMANDMENTS: Record<Sequence, readonly string[]> = {
[Sequence.linear]: TASK_LIST_MANAGEMENT,
[Sequence.linear]: LINEAR_COMMANDMENTS,
[Sequence.orchestrator]: [],
};

Expand Down
2 changes: 2 additions & 0 deletions src/agent/runner/switchboard/flags/schemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
GPT5_6_LUNA_MODEL,
GPT5_6_SOL_MODEL,
GPT5_6_TERRA_MODEL,
GPT6_2_SOL_MODEL,
Harness,
Sequence,
SONNET_5_MODEL,
Expand All @@ -25,6 +26,7 @@ const MODEL_FLAG_VARIANTS: Record<string, string> = {
'gpt-5-6-luna': GPT5_6_LUNA_MODEL,
'gpt-5-6-terra': GPT5_6_TERRA_MODEL,
'gpt-5-6-sol': GPT5_6_SOL_MODEL,
'gpt-6-2-sol': GPT6_2_SOL_MODEL,
'sonnet-5': SONNET_5_MODEL,
};

Expand Down
Loading
Loading