Instructions
Set an agent's system prompt and project rules, and add context to a single prompt.
An agent’s system prompt is the default prompt, which describes its tools, plus your instructions and project rules. Set them with a resource loader when you define the agent.
import { DefaultResourceLoader, getAgentDir } from "@earendil-works/pi-coding-agent";
import { pi } from "@rivet-dev/pi";
import { setup } from "rivetkit";
const resourceLoader = new DefaultResourceLoader({
cwd: process.cwd(),
agentDir: getAgentDir(),
appendSystemPrompt: ["You review pull requests for the payments team. Be brief and cite file paths."],
agentsFilesOverride: () => ({
agentsFiles: [
{ path: "AGENTS.md", content: "Run `npm test` before proposing a fix. Never edit files in `migrations/`." },
],
}),
});
await resourceLoader.reload();
const agent = pi({ model: "anthropic/claude-opus-5-5", resourceLoader });
export const registry = setup({ use: { agent } });
appendSystemPrompt adds your instructions after the default prompt. agentsFilesOverride supplies project rules as an inline AGENTS.md, so the agent gets the same rules wherever it runs. Call reload() before passing the loader. Every session of this agent gets the same instructions.
Context for one prompt
Put context for a single turn in the prompt text, or attach images with prompt(text, { images }). Each image is { type: "image", data, mimeType }, with the image base64-encoded in data. The system prompt stays the same.