Files
deepseek-harness/website/zh-CN/api/harness/system-prompt.md
2026-07-19 14:14:02 +08:00

4.1 KiB

ctx.systemPrompt

SystemPrompt — provided by @deepseek-ai/dsh-system-prompt.

Registry service for the prompt inputs assembled before each model step.

Source

ctx.systemPrompt.section(section)

/**
 * Register an ordered prompt section in the calling context's scope. A scoped
 * section shadows a global section with the same name; duplicates within one
 * layer and non-finite orders throw. Registration and disposal emit
 * `system-prompt/change`.
 * @param section - the section to register.
 * @returns the exact Cordis effect disposer.
 */
section(section: PromptSection): () => void

Register an ordered prompt section in the calling context's scope. A scoped section shadows a global section with the same name; duplicates within one layer and non-finite orders throw. Registration and disposal emit system-prompt/change.

  • section — the section to register.

Returns the exact Cordis effect disposer.

Source

ctx.systemPrompt.tools(provider)

/**
 * Register a tool-schema provider in the calling context's scope. Global and
 * matching scoped providers both contribute; returning the reserved
 * {@link TOOL_ORDER_REST} name makes assembly fail.
 * @param provider - evaluated for each assembly with its context.
 * @returns the exact Cordis effect disposer.
 */
tools(provider: (context: AssembleContext) => ToolProviderResult): () => void

Register a tool-schema provider in the calling context's scope. Global and matching scoped providers both contribute; returning the reserved TOOL_ORDER_REST name makes assembly fail.

  • provider — evaluated for each assembly with its context.

Returns the exact Cordis effect disposer.

Source

ctx.systemPrompt.variable(name, provider)

/**
 * Register a prompt variable in the calling context's scope. Scoped values
 * shadow globals; invalid or duplicate names throw. A provider may return
 * `undefined`, but rendering a section that references that value then fails.
 * @param name - the `[a-z][a-z0-9_]*` reference name.
 * @param provider - evaluated for each assembly.
 * @returns the exact Cordis effect disposer.
 */
variable(name: string, provider: (context: AssembleContext) => string | undefined): () => void

Register a prompt variable in the calling context's scope. Scoped values shadow globals; invalid or duplicate names throw. A provider may return undefined, but rendering a section that references that value then fails.

  • name — the [a-z][a-z0-9_]* reference name.
  • provider — evaluated for each assembly.

Returns the exact Cordis effect disposer.

Source

ctx.systemPrompt.assemble(context?)

/**
 * Assemble global and scoped providers, detach tool parameters, apply
 * canonical ordering, then run the assembly waterfall. Scoped sections and
 * variables shadow globals; the returned waterfall value is authoritative.
 * @param context - the optional scope and plugin-defined assembly fields.
 * @returns the authoritative post-waterfall assembly.
 */
async assemble(context: AssembleContext = {}): Promise<PromptAssembly>

Assemble global and scoped providers, detach tool parameters, apply canonical ordering, then run the assembly waterfall. Scoped sections and variables shadow globals; the returned waterfall value is authoritative.

  • context — the optional scope and plugin-defined assembly fields.

Returns the authoritative post-waterfall assembly.

Source