Files
deepseek-harness/docs/core-data-structures/system-prompt.md
T

63 lines
2.8 KiB
Markdown
Raw Normal View History

# System Prompt Assembly
English | [中文](system-prompt.zh.md)
The [system-prompt package](../../packages/core/system-prompt) owns the data exchanged between prompt contributors and one assembly call. The package [README](../../packages/core/system-prompt/README.md) documents registration, ordering, scoping, and rendering behavior; this page pins the literal cross-package shapes that plugins implement or pass.
Source: [`packages/core/system-prompt/src/index.ts`](../../packages/core/system-prompt/src/index.ts).
## Assembly context
2026-07-16 18:12:34 +08:00
`AssembleContext` identifies the scope layer one assembly resolves and may carry the explicit control signal for that request. It is merge-extensible: `dsh-agent` adds the optional live `agent` field, and `assembleContextFor(agent, signal)` sets the explicit fields together. A bare assembly has neither scope nor signal.
```ts type-equiv
2026-07-19 12:25:40 +08:00
/** Merge-extensible context for one prompt assembly. */
interface AssembleContext {
2026-07-19 12:25:40 +08:00
/**
* Scope whose providers and waterfall listeners participate. When absent,
* only global providers and subject-less listeners participate.
*/
scope?: ScopeKey
/** Explicit control signal for the turn that requested this assembly, when any. */
2026-07-16 18:12:34 +08:00
signal?: AbortSignal
}
```
## Tool-provider result
`ToolProviderResult.schemas` is the model-visible set for the current assembly. `knownNames` is the provider's pre-restriction name universe used to distinguish a configured-name typo from a known tool that is deliberately hidden in this scope.
```ts type-equiv
2026-07-19 12:25:40 +08:00
/** Tool schemas visible in one assembly and their pre-restriction name set. */
interface ToolProviderResult {
2026-07-19 12:25:40 +08:00
/** The schemas this provider contributes to THIS assembly. */
2026-07-12 22:49:46 +08:00
readonly schemas: readonly ToolSchema[]
2026-07-19 12:25:40 +08:00
/** The pre-restriction name universe for config validation (defaults to `schemas`' names). */
2026-07-12 22:49:46 +08:00
readonly knownNames?: readonly string[]
}
```
## Prompt sections
`PromptSection` is a readonly same-process registration contract. Its text may be static or resolved from the current assembly context.
```ts type-equiv
2026-07-19 12:25:40 +08:00
/** One contributed section of the system prompt (registry input). */
2026-07-12 22:49:46 +08:00
interface PromptSection {
2026-07-19 12:25:40 +08:00
/** Unique name — a duplicate registration throws (see {@link SystemPrompt.section}). */
2026-07-12 22:49:46 +08:00
readonly name: string
2026-07-19 12:25:40 +08:00
/**
* Sections are concatenated in ascending order. Convention: `-100` is the
* harness identity, `0` the deployment persona, tool guidance uses 100199;
* other negative orders also render before the persona.
*/
2026-07-12 22:49:46 +08:00
readonly order: number
2026-07-19 12:25:40 +08:00
/**
* Static text or a provider evaluated at each assembly with that assembly's
* {@link AssembleContext}. The text may reference `{{variable}}`s — they are
* interpolated later, by {@link renderPrompt}.
*/
2026-07-12 22:49:46 +08:00
readonly text: string | ((context: AssembleContext) => string)
}
```