Introduction¶
A common approach for building dialogue Agents with narrative arcs in DeepSeek Harness (DSH) is to either hard-code “user emotion” into the system prompt, or let the model infer it on its own each turn. The former is hard to update as the dialogue progresses; the latter lacks a portable, auditable explicit state, and it is also inconvenient to stably map “recognition results” onto strategies such as listening, empathy, or uncertainty reduction. The community plugin dph-emotion-arc (repo liuxinxing123/dph-emotion-arc) fills this gap with a pipeline architecture: text emotion recognition → explicit state file → strategy injection, and additionally provides a relational memory ledger and SillyTavern character card import. Maintainer: liuxinxing123; license: MIT; current package version: 0.2.0. In the SkillHub plugin directory it is classified as workflow, and the page is marked “installable”. SkillHub is an independent community directory with no official affiliation with DeepSeek / HiFive (幻方).
The plugin README makes its positioning clear: it is a screenwriter-style emotional narrative tool (a compliance whitelist direction), not continuous emotional companionship. The DSH ecosystem philosophy is “everything is a plugin”; this article only introduces the plugin’s capabilities and usage within Harness.
What Is This¶
In one sentence: text emotion recognition → explicit emotion-state file → dialogue strategy mapping, layered with an emotion memory ledger and character-card personality awareness.
Recognition uses a dual-engine approach, composed via the detectorMode setting:
- lexicon: dictionary + negation phrases + emoji + exclamation-mark weighting; zero cost and auditable, serving as a fallback.
- llm: LLM fine judgment (BYOK, 4s timeout, temperature 0, JSON tolerant parsing); in
automode the LLM is preferred, and on failure or timeout it falls back to the dictionary.
State is written to a JSON file in the data directory across sessions, and strategies are injected into the Agent via agent.inject() and systemPrompt.context(), rather than being an end-to-end black box.
Core Features¶
Emotion recognition → state machine → strategy¶
User messages enter the pipeline through the scoped event agent/inbox/claimed. Recognition results enter an emotion state machine (intensity, exponential decay, default half-life 30 minutes, label-switch hysteresis debounce). The README lists three guards against perception errors: low confidence falls back to neutral; label switching must exceed the intensity hysteresis; inference writes go to an audit log for traceability.
On significant change it can trigger strategy hints (empathy / listening / uncertainty reduction, etc.; notifyMode can disable this); at each step it injects the current state and the character-card personality into the system prompt, achieving steady-state perception. The persistence path is state/<sid>.json.
Memory ledger and character cards¶
| Capability | Implementation |
|---|---|
| Relational emotion memory | ledger/<sid>.jsonl, types include conflict / reconciliation / soothe / breakthrough / preference / milestone, retained across sessions |
| SillyTavern character cards | V2 PNG, V3 JSON, V2 JSON imported as persona/<id>.json, feeding back into personality-aware strategies (V1.1) |
The Agent can read and write through tools: emotion_ledger_append appends to the ledger; emotion_card_import imports and binds to the current session.
Agent tools¶
emotion_state: read the current label, intensity, confidence, trigger words, history, ledger tail, character card, etc.emotion_state_set: manual calibration (audit logrule=manual).emotion_ledger_append: append relational memory.emotion_card_import: import a SillyTavern character card and bind the session.
Client UI¶
Below the Composer there is an “Emotion Arc” chip: current emotion (color dot, emoji, name, intensity bar, relative time). Clicking expands the state panel (trigger words, change history, ledger tail). Data is fetched via a read-only HTTP endpoint; write operations go only through Agent tools.
Data files¶
The default data root directory is dshHomePath('emotion-arc'), which can be overridden with dataDir in the config:
<dataDir>/state/<sessionId>.json # emotion state (including version, history, persona binding)
<dataDir>/ledger/<sessionId>.jsonl # emotion memory ledger
<dataDir>/audit/<sessionId>.jsonl # inference audit (rule: llm / lexicon / lexicon-fallback / manual)
<dataDir>/persona/<personaId>.json # character-card persona profile
Files carry a version field to facilitate export and migration.
Installation and Activation¶
The fetched README and SkillHub directory page do not provide a standalone install command of the form dsh plugin add …. The directory page marks the plugin as “installable”; the installation method is based on the plugin management flow corresponding to your current DSH version and the instructions on the SkillHub page.
After installing and loading the bundle, enable and tune parameters in the plugin’s own cordis.patch.yml. Below is the complete configuration example from the README (paths and fields follow the repo):
config:
enabled: true
dataDir: !!js dshHomePath('emotion-arc')
decayHalfLifeMs: 1800000 # emotion half-life 30min
neutralFloor: 0.15 # fall back to neutral below this intensity
minConfidence: 0.5 # guard (1) threshold
hysteresis: 0.15 # guard (2) label-switch hysteresis
injectThreshold: 0.25 # intensity-change threshold that triggers strategy injection
injectCooldownMs: 5000 # injection cooldown
notifyOnShift: true # inject notification when emotion shifts significantly
notifyMode: inject # inject=inject + context; context-only=steady-state context only
detectorMode: auto # lexicon / llm / auto
llmTimeoutMs: 4000
llmMaxTokens: 120
# llmProvider / llmModel # optional; defaults to the Harness default model (BYOK)
historyLimit: 20
Development and operations notes (from the README):
- After modifying the Host-side
engine.js, you must restart Harness for it to take effect. - After modifying the Client-side
client.js, just refresh the page. - When disabling / enabling the plugin, leave an interval of ≥10 seconds to avoid cordis fibers not being released, which can cause routing exceptions.
Typical Usage¶
1. Automatically run a closed loop during dialogue¶
Enable the plugin and keep enabled: true. After the user sends a message, the plugin listens to agent/inbox/claimed, recognizes emotion according to detectorMode, updates state/<sid>.json, conditionally calls agent.inject() for strategy hints, and carries the current state at each step via systemPrompt.context(). The UI chip lets you view results read-only.
If you want to reduce disturbance, set notifyMode to context-only to keep only the steady-state context injection.
2. Agent proactively reads state and writes the ledger¶
Use emotion_state in the Agent tool list to view the current arc; at key plot nodes call emotion_ledger_append to record entries such as conflict, reconciliation, etc., for reference in subsequent turns and across sessions.
3. Import a character card and bind personality¶
Call emotion_card_import on a V2 PNG or V3 / V2 JSON exported by SillyTavern; after a persona profile is generated, the strategies and personality awareness will align with that character setting.
4. Manual calibration and audit¶
When recognition is off, correct it with emotion_state_set; the corresponding write goes to audit/<sid>.jsonl with rule=manual, facilitating comparison with llm / lexicon inference.
Local unit tests (provided by the maintainer): node test-emotion.mjs (24 cases), node test-fork-repro.mjs (regression).
Adaptation and Maintenance Discipline¶
Key points of the adaptation matrix given in the README:
| Component | Version / Requirement | Status |
|---|---|---|
| DeepSeek Harness | 0.1.7 – 0.2.x (Developer Preview) | Written against the 0.2.x API surface |
| Host API | agent/inbox/claimed, agent.inject, agent/created / agent/disposed, systemPrompt.context, tools.register, webServer.register, etc. |
Defensive calls; skip if missing |
| Client | window.__ModuleLoader__, ctx.slots, conversation.composer.dock (sessionId), etc. |
README marks as usable |
| Browser | Modern Chromium / WebView (fetch + React 18) | README marks as usable |
The plugin does not import @deepseek-ai/* packages (the bundle is self-contained); when host APIs change it prefers skipping features rather than throwing, to avoid affecting the session. After each dsh release, the README suggests running a smoke test on emotion_state and chip refresh.
The Roadmap’s V2 plans voice emotion and TTS, as a future direction; the current README marks V1.0 closed loop + ledger + adaptation matrix and V1.1 LLM fine judgment and character card import as the delivered scope.
Suitable Scenarios and Caveats¶
Suitable for: needing to do auditable, portable emotional narrative within DSH; screenwriter / text-RP (语C) style Agents that want explicit state to drive strategies rather than pure prompt guessing; those with existing SillyTavern character assets who want to reuse a single persona in Harness.
Must be aware:
- The plugin runs with the current dsh process’s permissions; before installing, review the GitHub source code and the MIT license yourself.
- LLM fine judgment is BYOK, using the Harness default or the configured
llmProvider/llmModel; on timeout it falls back to the dictionary. - README compliance statement: for research and creative assistance only, not medical / psychological services; does not provide continuous emotional interaction with anthropomorphic personalities.
Conclusion¶
dph-emotion-arc turns “emotion recognition → state → strategy” into a file-based, auditable Harness workflow, and extends the narrative arc with a ledger and character cards. To browse the intro and install entry, see the SkillHub directory page; architecture, configuration, and tool list are governed by the GitHub repo README.