Merge pull request #550 from mvanhorn/osc/529-fix-missing-agents-md-fallback
Some checks failed
Release / preview_stable (push) Has been cancelled
Release / publish_stable (push) Has been cancelled
Release / publish_canary (push) Has been cancelled
Release / verify_stable (push) Has been cancelled
Refresh Lockfile / refresh (push) Has been cancelled
Release / verify_canary (push) Has been cancelled

fix: graceful fallback when AGENTS.md is missing in claude-local adapter
This commit is contained in:
Dotta
2026-03-21 11:17:35 -05:00
committed by GitHub

View File

@@ -344,13 +344,23 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
// When instructionsFilePath is configured, create a combined temp file that // When instructionsFilePath is configured, create a combined temp file that
// includes both the file content and the path directive, so we only need // includes both the file content and the path directive, so we only need
// --append-system-prompt-file (Claude CLI forbids using both flags together). // --append-system-prompt-file (Claude CLI forbids using both flags together).
let effectiveInstructionsFilePath = instructionsFilePath; let effectiveInstructionsFilePath: string | undefined = instructionsFilePath;
if (instructionsFilePath) { if (instructionsFilePath) {
const instructionsContent = await fs.readFile(instructionsFilePath, "utf-8"); try {
const pathDirective = `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}.`; const instructionsContent = await fs.readFile(instructionsFilePath, "utf-8");
const combinedPath = path.join(skillsDir, "agent-instructions.md"); const pathDirective = `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}.`;
await fs.writeFile(combinedPath, instructionsContent + pathDirective, "utf-8"); const combinedPath = path.join(skillsDir, "agent-instructions.md");
effectiveInstructionsFilePath = combinedPath; await fs.writeFile(combinedPath, instructionsContent + pathDirective, "utf-8");
effectiveInstructionsFilePath = combinedPath;
await onLog("stderr", `[paperclip] Loaded agent instructions file: ${instructionsFilePath}\n`);
} 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); const runtimeSessionParams = parseObject(runtime.sessionParams);