Cause: SystemPromptProjection skipped the first empty rendered prompt. The initial admitted user then occupied surface node zero, so a later nonempty prompt appended behind user history. Routes without in-history system support lost the leading system role; pi-ai demotes a non-leading system message to user content. Fix: append the initial system node even when its content is empty. The existing loop commit order reserves node zero before admitted user messages; later prompt text replaces that node. Empty content still derives to no wire message. Keep retained-node replacement, clearing, multi-system handling, and pi-ai conversion unchanged; this addresses only the reviewed PR3476 initial-empty finding, not PR3483. Tests: added initial-empty projection and two-turn loop regressions for empty wire output, reserved surface head, later leading system role, replacement intent, and series header. Negative control failed before the source fix. Focused projection/runtime-context/loop/request-reconstruction/session-surface/pi-ai-context suites passed 176 tests; exact runtime-context.ts coverage is 100% statements, branches, functions, and lines. test:docs passed all 15 gates. Updated README EN/ZH, architecture map and owning architecture note; recorded all three translation pairs. Broad doc-sync/lint stopped at parent request for combined-layer validation. No normalize.ts conflict-comment edit.
description, kind
| description | kind |
|---|---|
| The core group map: the session log, system-prompt assembly, tool registry, agent vocabulary, and default loop that form the product API spine. | package-group |
packages/core
English | 中文
Summary
The core group provides the product API spine of the DeepSeek Harness: an append-only session log, system-prompt assembly, a tool registry, the Agent handle, and the concrete loop that drives them. Every composition boots these packages, and plugins and consumers build against their stable contracts. A turn flows through all of them — the loop claims a prompt, opens a turn on the session log, assembles the request through system-prompt, streams the model response, dispatches tool calls through the registry, and appends every model-visible fact back to the log. Choose this group when you build an agent or extend one; the default product composition is dsh-base.
Table of Contents
Packages
| Package | Role | ctx key |
|---|---|---|
scope/ |
Scoped registration and event routing that isolate one agent's contributions | library — no ctx key |
session/ |
The append-only session event log every agent's history derives from | ctx.sessions |
system-prompt/ |
System-prompt assembly from ordered sections, tool schemas, and variables | ctx.systemPrompt |
tools/ |
The tool registry and guarded execution pipeline the loop dispatches through | ctx.tools |
agent-tool-presentation/ |
Per-agent tool-presentation selector for presets | no ctx key |
agent/ |
The Agent handle plugins program against, plus its live registry and events |
ctx.agents |
agent-default-model/ |
The deployment default model selection entry points apply to fresh agents | ctx.agentDefaultModel |
agent-loop/ |
The default agent driver: creates agents and runs the turn and step lifecycle | ctx.agentLoop |
scope supplies the shared scoping primitive; agent owns the public Agent contract, while agent-loop is its default implementation, so extension plugins depend on agent and the driver stays swappable. agent-default-model owns the deployment selection an entry point applies when a session has none of its own. Runnable compositions live under packages/bundle; this group owns only the swappable spine pieces.
Related documentation
- Core subsystem — the package-by-package loop map and the
Agenthandle contracts. - Session subsystem — the session event vocabulary and derived history.
- System-prompt subsystem — prompt section, dynamic context, and tool-schema types.
- Tools subsystem — the tool execution pipeline and presentation vocabulary.
- Scoped registration subsystem — the scoped-layer primitive these registries build on.
- Architecture — the turn flow and where new behavior goes.
- Base bundle — the default product composition.
- SDK minimal bundle — a complete standalone composition with a deliberately smaller feature set.
Dev Note
Working context for maintainers — click to expand
None.