Skip to content

The open-source app everyone uses to manage agents at work

fix: graceful fallback when AGENTS.md is missing in claude-local adapter

Matt Van Hornb41c00a9efc5
diff --git a/packages/adapters/claude-local/src/server/execute.ts b/packages/adapters/claude-local/src/server/execute.ts
index be85439d7b..cdcb252ffb 100644
--- a/packages/adapters/claude-local/src/server/execute.ts
+++ b/packages/adapters/claude-local/src/server/execute.ts
@@ -341,13 +341,22 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
// When instructionsFilePath is configured, create a combined temp file that
// includes both the file content and the path directive, so we only need
// --append-system-prompt-file (Claude CLI forbids using both flags together).
- let effectiveInstructionsFilePath = instructionsFilePath;
+ let effectiveInstructionsFilePath: string | undefined = instructionsFilePath;
if (instructionsFilePath) {
- const instructionsContent = await fs.readFile(instructionsFilePath, "utf-8");
- const pathDirective = `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}.`;
- const combinedPath = path.join(skillsDir, "agent-instructions.md");
- await fs.writeFile(combinedPath, instructionsContent + pathDirective, "utf-8");
- effectiveInstructionsFilePath = combinedPath;
+ try {
+ const instructionsContent = await fs.readFile(instructionsFilePath, "utf-8");
+ const pathDirective = `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}.`;
+ const combinedPath = path.join(skillsDir, "agent-instructions.md");
+ await fs.writeFile(combinedPath, instructionsContent + pathDirective, "utf-8");
+ effectiveInstructionsFilePath = combinedPath;
+ } catch (err) {
+ const reason = err instanceof Error ? err.message : String(err);
+ await onLog(
+ "stderr",
+ `[paperclip] Warning: could not read agent instructions file "${instructionsFilePath}": ${reason}\n`,
+ );
+ effectiveInstructionsFilePath = undefined;
+ }
}
const runtimeSessionParams = parseObject(runtime.sessionParams);