Introduction¶
When running multi-session workflows in DeepSeek Harness (DSH), the built-in @deepseek-ai/dsh-time-context injects the current time, browser timezone, and “duration since the last model-visible message” at the first step of every turn. This is sufficient for single-window conversations, but in scenarios involving QQ groups, scheduled tasks, or parallel sub-agents, two structural gaps appear: first, it is unable to provide time context only to specified sessions, resulting in wasted tokens on unneeded conversations; second, it lacks awareness of session boundaries—it does not know how long it has been since other windows were last active, nor can it distinguish between “user-initiated speech” and messages generated by scheduled wake-ups or tool triggers.
dsh-session-clock, published by community maintainer xfgil and categorized as a “Memory” plugin, is positioned as a supplement to the built-in time-context, not a replacement. The following sections explain what it supplements, how to install it, and how to configure it.
What is this?¶
In short: dsh-session-clock injects a session clock line into specified sessions and persists idle intervals across turns and sessions. By default, it coexists with the built-in dsh-time-context (mode: supplement); the timestamp and duration formatting remains consistent with the built-in version, so the two injections do not conflict when placed together.
- Directory Page: SkillHub - dsh-session-clock
- Source Code & Docs: GitHub - xfgil/dsh-session-clock
- License: MIT (package.json)
- Current Package Version: 0.1.1
- Supported DSH Version:
>=0.2.0-rc.2 <0.3.0-0(README developed and verified against0.2.1-rc.2)
Division of Labor with Built-in time-context¶
The built-in plugin excels at “what time is it now, and how long since the last model-visible message”; this plugin does not duplicate these (unless you set mode to full and disable the built-in time-context). The README summarizes the differences in a table; the core increments are as follows:
| Capability | Built-in dsh-time-context | dsh-session-clock |
|---|---|---|
| Time injection for specific sessions only | No | Yes (sessions / exceptSessions) |
/regex/, * session matching |
No | Yes |
| Cross-session “any session last active” pointer | No | Yes |
| Time since last user-initiated speech | No (only counts model-visible messages) | Yes |
| Interval persistence after restart | Relies on intra-session events | Persisted to $DSH_HOME/session-clock/activity.json |
| Agent active querying | No | session_clock tool |
| HTTP status observation | No | Loopback endpoint |
Core Features¶
Time Injection by Session¶
In the profile’s cordis.patch.yml, use whitelists and blacklists to control which sessions receive the injection:
sessions: ['onebot-*', 'session-*'] # Whitelist, supports * wildcards and /regex/
exceptSessions: ['/^onebot-group-.*$/'] # Blacklist, takes precedence over whitelist
'*' represents all sessions. Invalid regular expressions degrade to literal matching and will not crash the plugin.
Injection Content and Interval Semantics¶
Each injection is a single line, formatted as:
Session clock for onebot-group-2000000002-mv40ioj5: previous user message 3d 4h 12m 9s ago; any session last active 12m 3s ago (session-36f403a5-...), turn 42.
previous user message ... ago: Duration since the last user-initiated speech (excludes injections and scheduled wake-ups).any session last active ... ago: Cross-session pointer; the parentheses contain the ID of the last active session.turn 42: Cumulative turn count for this session.
Specific clauses can be disabled via configurations such as includeUserGap, includeGlobalIdle, and includeTurnCount.
Persistence¶
State is written to $DSH_HOME/session-clock/activity.json (default ~/.dsh/session-clock/activity.json). Disk writes employ delayed merging and atomic replacement (temporary file followed by renameSync). After a DSH restart, session objects are reconstructed, but the interval baselines in the file remain intact.
session_clock Tool¶
| action | Description |
|---|---|
now |
Current time and various idle durations for this session (or specified session_id) |
list |
Recently active sessions and idle durations (limit controls the number of entries) |
HTTP Observation Surface (Loopback Only)¶
Non-local access returns 403. Common paths:
| Method | Path | Description |
|---|---|---|
| GET | /session-clock |
enabled / mode / counters / last decision reason |
| GET | /session-clock/list |
Tracked sessions and idle durations |
| POST | /session-clock/toggle |
Enable/disable injection |
| POST | /session-clock/flush |
Write to disk immediately |
lastDecision distinguishes between “injection skipped this turn” and plugin exceptions; for example, when mode=supplement injects only at the first step, missing the first step results in silence for the entire turn.
Installation and Activation¶
The plugin runs with the permissions of the current DSH process; it is recommended to review the repository source code and MIT license before installing. The community directory SkillHub has no official affiliation with DeepSeek/HSQuant; the DSH ecosystem is “everything is a plugin,” and this package is distributed via npm / plugin managers.
Prerequisites¶
The host must include the built-in @deepseek-ai/dsh-time-context (0.2.0-rc.2, provided by @deepseek-ai/dsh-base; do not mount a second copy of time-context in the profile, otherwise two identical injections will appear at the first step of every turn).
Node Engine requirement: >=22 (package.json).
Recommended Installation¶
dsh plugin --profile <your_profile> add dsh-session-clock
After installation, a restart is usually not required; use GET /session-clock to verify enabled: true and ready: true. If the interface returns 404, restart DSH and reconcile once more.
Alternatively, download the source package from Releases, extract it, and link it using dsh plugin --profile <your_profile> add link:/absolute/path/dsh-session-clock (convenient for modifying source code in conjunction with HMR).
Typical Configuration¶
In the profile’s cordis.patch.yml:
- id: session-clock
name: dsh-session-clock
config:
mode: supplement
timeZone: Asia/Shanghai
sessions: ['*']
refreshIntervalMs: 60000
Common keys description (see README for the full list):
| Key | Default | Description |
|---|---|---|
mode |
supplement |
Only adds increments; append additionally provides time since last turn end; full replicates the three lines of time-context |
sessions |
['*'] |
Whitelist of sessions for time injection |
exceptSessions |
[] |
Blacklist, takes precedence over whitelist |
refreshIntervalMs |
60000 |
Minimum interval (ms) between two injections in the same session; 0 disables throttling |
skipSubagents |
true |
Skip sessions where origin === 'subagent' |
minGapSeconds |
0 |
Do not inject if idle time is insufficient |
If timeZone is left blank, the process timezone is used; if the process is UTC, unavailable, or the configuration is invalid, it falls back to fallbackTimeZone (default Asia/Shanghai), and the plugin will not halt.
Coexistence with time-context (Default)¶
Do not modify the existing time-context entry in the profile. If you wish to use this plugin to fully replace the built-in time-context:
- Add
disabled: trueto- id: time-contextincordis.patch.yml; - Set this plugin’s
mode: full.
Use Cases and Caveats¶
Suitable for: Multi-channel setups (e.g., QQ onebot), mixed environments of scheduled wake-ups and human conversation, agents requiring “how long since the user last spoke actively” or “when other sessions were last active”; scenarios requiring accurate idle intervals after restart; saving tokens by providing time context only to specific sessions.
Caveats:
- Injection occurs only once at the first step of each turn (
supplement), consistent with the built-in time-context rhythm. - Deleting
activity.jsonclears all interval records. webServeris optional; injection still works without an HTTP service, but the observation surface is unavailable.- Zero additional npm runtime dependencies; uses only Node built-in modules and the plugin’s bundled
time.js/store.js.
Conclusion¶
Without touching the built-in time-context, dsh-session-clock supplements four capabilities: session-level switching, cross-session pointers, user-initiated speech intervals, and persistence. It also exposes the session_clock tool and loopback HTTP for troubleshooting. Refer to the README for details.
- Directory Page: https://www.skillhub.cn/plugins/xfgil/dsh-session-clock
- GitHub: https://github.com/xfgil/dsh-session-clock