feat(agent-loop): open every prompt with the harness identity section

A static harness:identity section at order -100 — the first occupant of
the documented negative band — states that the agent is powered by the
DeepSeek Harness SDK before the deployment's persona renders. Harness
attribution is a harness fact: it lives on the loop plugin, not in each
deployment's persona, so every agent (subagents included) carries it and
no YAML can forget it. A deployment that must drop it can remove the
section in the system-prompt/assemble waterfall.

Order-band docs updated in all five homes (PromptSection JSDoc, the
system-prompt and agent-loop READMEs, architecture.md, the RFC).
This commit is contained in:
Tianyi Cui
2026-07-05 11:37:32 +08:00
parent 2f191cc72b
commit 00cf8b693a
7 changed files with 31 additions and 22 deletions

View File

@@ -82,13 +82,20 @@ export class AgentLoop extends Service implements AgentFactory {
// Provide the agent-creation factory to the registry (effect-scoped: the
// slot is cleared on dispose).
ctx.effect(() => this.ctx.agents.setFactory(this), 'agentLoop.setFactory()')
// The per-agent prompt pieces, registered once and resolved per assembly
// from the AssembleContext the loop passes (loop.ts assembles with
// `{ agent }` each step). The persona is the order-0 section — identity
// renders before all tool guidance; `{{model}}`/`{{cwd}}` are the built-in
// prompt variables projecting the agent's configured model and its
// session workspace. A provider returns undefined when the fact is absent
// (renderPrompt then rejects a persona that claims it — fail loud).
// The prompt pieces the harness itself owns, registered once. The
// harness-identity section states what every agent on this loop IS,
// ahead of everything (order 100 — before the deployment's persona);
// the persona is the order-0 section resolved per assembly from the
// AssembleContext the loop passes (loop.ts assembles with `{ agent }`
// each step); `{{model}}`/`{{cwd}}` are the built-in prompt variables
// projecting the agent's configured model and its session workspace. A
// provider returns undefined when the fact is absent (renderPrompt then
// rejects a persona that claims it — fail loud).
ctx.systemPrompt.section({
name: 'harness:identity',
order: -100,
text: 'You are an AI agent powered by the DeepSeek Harness SDK.',
})
ctx.systemPrompt.section({
name: 'agent:persona',
order: 0,