Skip to content

Prompt sections

A prompt section is a part of HADAL’s system prompt that your module writes. Use one for a rule that HADAL must know in each request, or for a rule that depends on the session.

Use section from @earendil-works/pi-durable, and give the section to your extension:

const rule = section(
"no_force_push",
() => "Do not force-push with git. Push normally, or ask the person to.",
);
export default function createNoForcePush() {
return defineExtension({ name: "my-no-force-push", sections: [rule] });
}
  • section(name, render, { tag }). render(input, context) returns the text of the section. To leave the section out, return undefined.
  • HADAL puts the text between <name> and </name>. With { tag: false }, it puts the text without the tags.

Sections render before each request. HADAL sends again only the sections that changed, and the model provider can then use its cache.

  • Return the same text while nothing changed.
  • Put the date in a section, not the time.
  • Do not put counters in a section.

A section about a tool shows while input.agent.tools has the tool. In codemode’s Only mode, scripts alone call most tools, so also show it when input.agent.callable has the tool with callers that leave out "model", as browser.ts does.

input.conversationId is the session. input.read.snapshot(Doc, input.conversationId, context) reads a document of that session. Use them to write a section that depends on the session.

The text of a section goes to the model provider. Do not put secrets in it.

These pages describe HADAL 0.29.0. Your copy has the pages of its own version in its docs/ folder.