Instructions

Instructions are text you write for the model in agent/instructions.md or agent/instructions.ts. Use system-role instructions for the agent's identity and standing rules. Use user-role instructions for application context that belongs in the conversation history, such as an imported brief or retrieved memory.

Author instructions

The smallest instructions are a markdown file at the agent root. Its contents are the prompt:

agent/instructions.md
You are a concise assistant. Use tools when they are available.

Keep this file to stable behavior such as identity, tone, and standing rules.

System and user roles

System-role instructions stay outside the conversation history, and eve includes them on every model call. When you deploy a new version, or eve dev reloads, existing sessions use the current system instructions.

eve adds user-role instructions to the conversation history once, in source order, ahead of the next turn's input. It adds one again when its content changes, including when a newer deployment changes a static one, and when a compaction or clear removes it from the history.

Markdown vs TypeScript

Put a static system prompt in markdown (agent/instructions.md). Switch to a TypeScript module (agent/instructions.ts) when you need typed composition, lib/ code, build-time values, or a user-role message:

agent/instructions/brief.ts
import { defineInstructions } from "eve/instructions";
import { buildCustomerBrief } from "../lib/customer";

export default defineInstructions({
  content: buildCustomerBrief(), // blank content adds nothing
  role: "user", // "system" or "user"; omit for "system"
});

The module, including its ESM and asset imports such as a prompt imported with ?raw, runs once at build time and never at runtime. See Authored module lifecycle.

Split instructions across a directory

For more than one file, add an agent/instructions/ directory. eve reads its .md files and .ts modules, but not subdirectories. A .ts file can export defineInstructions or defineDynamic. Static system and user entries apply in alphabetical filename order (localeCompare).

A root agent/instructions.md (or .ts) can sit beside the directory, and the root file comes first. Having both instructions.md and instructions.ts at the root is a build error.

Dynamic instructions

To compute instructions from auth, tenant, channel, or external data, use defineDynamic((ctx) => ...) and return defineInstructions(...) or null. The function runs before each ordinary model call, not once per turn, so wrap every fetch, database query, and API call in ctx.memo(key, fn) to run it once per key. See Dynamic capabilities to choose a key.

A dynamic system instruction applies, outside history, while the function returns it.

A dynamic user instruction joins the conversation history only when its content changes:

  • Before a turn's first model call, it joins ahead of the turn's input.
  • During a turn, a change appends at the current position.
  • Returning null adds nothing and resets change tracking, so a later return of the earlier text adds it again.
  • Existing history is not removed.
  • Change tracking survives deployments. A compaction or clear that removes the instruction from the history adds it again.

See Dynamic capabilities for examples and failure behavior.

A session that replaced a stranded session can receive the earlier conversation. In a user-role instruction, read the earlier session's stream with sessions.attach() and transcriptOf(), memoized by that session's ID.

History controls and prompt caching

Compaction and clear rewrite the conversation history. When the rewrite removes a user-role instruction, as a clear or a summary does, eve adds it again before the next model call. A compaction that only shortens old tool results keeps it, so it isn't added twice. System-role instructions remain, because they are outside history.

Keep system-role content stable and ahead of frequently changing context when you can, so providers can reuse the prompt prefix. Cache behavior and billing depend on the provider, and eve doesn't promise a cache hit.

User-role instructions only append, so they keep the earlier prompt prefix the same. eve's notes about available skills and parked agents follow the same rule: a changed note appends after earlier steps, and eve skips an unchanged one until a clear or compaction removes it.

Instructions vs skills

Instructions and skills both add text to the model's context, at different times:

LoadedUse for
System-role instructionsOutside history on every model callPermanent identity and standing rules
User-role instructionsOnce, and again on each changeApplication context that belongs in conversation history
agent/skills/*On demand, when the model loads one with eve__skillOptional procedures that should not bloat every turn

Keep instructions short and stable. Put long or situational procedures in skills. Put typed behavior that runs code in a tool, because static instructions never run code at runtime.

Disclaimer

As the deployer, it is your responsibility to ensure your agent complies with applicable laws.

Where an eve agent communicates with people, law may require you to disclose that they are interacting with an automated AI system. eve doesn't add this disclosure; configure it in your instructions or channel responses.

  • Tools: typed actions, the next capability to add
  • Context control: all the levers for what the model sees
  • Skills: on-demand procedures, the counterpart to always-on instructions
  • Memory: provider-backed context that outlives a session, recalled before each turn