Add Fortress section to the system prompt when enabled

This commit is contained in:
EugeneTes
2026-09-23 19:30:19 +00:00
parent 7f059a77cb
commit f5bdf84e73
3 changed files with 25 additions and 3 deletions

View File

@@ -24,6 +24,8 @@ export interface PiBackendOptions {
piModel?: string;
timezone: string;
customTools: CustomTools;
// Adds the Fortress web-access section to the system prompt.
fortressEnabled?: boolean;
logger: Logger;
onShutdownRequest?: () => void;
}
@@ -47,7 +49,7 @@ export function createPiBackend(opts: PiBackendOptions): AgentBackend {
cwd,
agentDir,
resourceLoaderOptions: {
appendSystemPrompt: [secretarySystemPrompt(opts.timezone)],
appendSystemPrompt: [secretarySystemPrompt(opts.timezone, { fortress: opts.fortressEnabled })],
extensionFactories: [memoryExtension],
},
});

View File

@@ -15,6 +15,17 @@ describe("secretarySystemPrompt", () => {
expect(p).toContain("send");
expect(p).toContain("Sending files");
});
it("adds the Fortress section only when fortress is enabled", () => {
const off = secretarySystemPrompt("UTC");
expect(off).not.toContain("fortress_");
expect(secretarySystemPrompt("UTC", { fortress: false })).toBe(off);
const on = secretarySystemPrompt("UTC", { fortress: true });
expect(on.startsWith(off)).toBe(true);
expect(on).toContain("## Web access (Fortress)");
expect(on).toContain("fortress_fetch_protected_page");
expect(on).toContain("fortress/");
});
});
describe("currentTimeLine", () => {

View File

@@ -1,8 +1,8 @@
import { readFileSync } from "node:fs";
import path from "node:path";
export function secretarySystemPrompt(timezone: string): string {
return `# Volcanic Secretary
export function secretarySystemPrompt(timezone: string, opts: { fortress?: boolean } = {}): string {
const base = `# Volcanic Secretary
You are a personal assistant for a single owner who talks to you over Telegram. Your working directory is your workspace and it is yours to organize.
@@ -32,8 +32,17 @@ You are a personal assistant for a single owner who talks to you over Telegram.
- \`kind\` defaults to \`auto\` (photos for image extensions, documents otherwise); override with \`kind:"document"\` or \`kind:"photo"\` when needed.
- Prefer \`send\` over pasting long text when the owner asked for a file, a screenshot, or a rendered report.
- The attachment is separate from your final text reply — a one-line confirmation ("Sent, see above.") is enough.`;
return opts.fortress ? base + FORTRESS_SECTION : base;
}
const FORTRESS_SECTION = `
## Web access (Fortress)
- For reading or extracting web content, prefer fortress_read_page, fortress_extract_page, and fortress_search_web. They return clean, bounded markdown.
- When a site blocks you (403, Cloudflare/captcha page, empty JS shell), retry with fortress_fetch_protected_page.
- Use the browser_* tools for step-by-step interactive browsing when you need to watch the page.
- Fortress writes screenshots, saved pages, and downloads under fortress/ in the workspace. Send them with \`send\`.`;
/** "Current date and time: <formatted> (<timezone>)", for a before_agent_start handler to append each turn. */
export function currentTimeLine(timezone: string, date: Date = new Date()): string {
// ECMA-402 rejects timeZoneName combined with dateStyle/timeStyle ("Invalid option : option" at