Files
hapi/cli/src/codex/utils/systemPrompt.ts
T
988f8f183f feat: settings toggle for AGENT_NOTIFY_SUMMARY contract injection (#1376)
* feat: settings toggle for AGENT_NOTIFY_SUMMARY contract injection

Add a hub-persisted, default-off Settings control so operators can opt agents into emitting the trailing AGENT_NOTIFY_SUMMARY line. Propagate the resolved flag on CLI session bootstrap and inject at call time for Claude, Codex, OpenCode, and Grok (Cursor still unsupported).

Closes #1375

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: lock hub settings RMW and restore abort deliveryMode

Serialize settings.json updates with the shared .lock protocol and unique
temp files so the new hub toggle cannot clobber CLI/relay fields under
concurrency. Also supply deliveryMode on abort send-error restore so web
typecheck (and CI) pass.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): wrap SettingsGeneralPage tests with QueryClientProvider

The hub-settings toggle uses TanStack Query; the settings page suite
was rendering without a QueryClient and blew up CI.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): defer summary-contract toggle until settings load

Avoid rendering an interactive false switch while the hub GET is still
in flight, which could overwrite an enabled preference on early click.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): clarify Grok coverage for summary-contract toggle

Local Grok has no instruction inject path; settings copy now matches
remote-only Grok support (and still excludes Cursor).

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 18:51:35 +08:00

41 lines
2.1 KiB
TypeScript

/**
* Codex-specific system prompt for local mode.
*
* This prompt instructs Codex to call the hapi__change_title function
* to set appropriate chat session titles.
*/
import { trimIdent } from '@/utils/trimIdent';
import { buildSessionCitationSteerInstruction } from '@hapi/protocol/sessionCitation';
import { withSessionSummaryInstruction } from '@/modules/common/sessionSummaryInstruction';
/**
* Title instruction for Codex to call the hapi MCP tool.
* Note: Codex exposes MCP tools under the `functions.` namespace,
* so the tool is called as `functions.hapi__change_title`.
*/
export const TITLE_INSTRUCTION = trimIdent(`
Use the title tool sparingly. For a new chat, call it once after the user's initial request is clear, and set a concise task title.
Prefer calling functions.hapi__change_title.
If that exact tool name is unavailable, call an equivalent alias such as hapi__change_title, mcp__hapi__change_title, or hapi_change_title.
Do not rename the chat for routine progress, substeps, implementation details, or a slightly better wording.
Rename only when the user's primary objective changes substantially and the existing title would be misleading.
When you create or find a local image file that the user should see, call functions.hapi__display_image with the image path. If that exact tool name is unavailable, use an equivalent alias such as hapi__display_image, mcp__hapi__display_image, or hapi_display_image.
${buildSessionCitationSteerInstruction({
inspectTool: 'functions.hapi__inspect_peer',
pingTool: 'functions.hapi__ping_peer',
listPeersTool: 'functions.hapi__list_peers',
})}
`);
/**
* The system prompt to inject via developer_instructions in local mode.
* Session-summary contract is resolved at call time (hub toggle / env).
*/
export function getCodexSystemPrompt(env: NodeJS.ProcessEnv = process.env): string {
return withSessionSummaryInstruction(TITLE_INSTRUCTION, env)
}
/** Alias kept for existing call sites / tests that expect a string constant name. */
export const codexSystemPrompt = TITLE_INSTRUCTION