Skip to content

fix: support session.snapshotEvents() in DSH presets - #88

Merged
xiaobright merged 1 commit into
xiaobright:mainfrom
324641aliyun:fix/session-snapshotEvents-compat
Sep 6, 2026
Merged

xiaobright merged 1 commit into
xiaobright:mainfrom
324641aliyun:fix/session-snapshotEvents-compat

Conversation

@324641aliyun

Copy link
Copy Markdown
Contributor

DeepSeek Harness has removed the direct session.events array and now provides session.snapshotEvents(). This caused preset plugins that scan session history to fail, so Prefab and other anchored presets could not seed/inject context correctly after a DSH update.

This PR updates all preset plugin files and verify helpers to use:

session.snapshotEvents ? session.snapshotEvents() : (session.events ?? [])

and the equivalent for agent.session.events.

It keeps compatibility with older DSH versions that still expose session.events.

Verification:

  • npm test passes: 214/214

DeepSeek Harness no longer exposes session.events as an array; presets
should read session history via session.snapshotEvents() when available.
Update all preset plugins and verify helpers to use snapshotEvents() with
a fallback to the older session.events API for compatibility.
@AndyZHENG0715

Copy link
Copy Markdown

Independent real-world verification of this fix: on dsh 0.1.2-rc.1, a deployed preset derived from this repo's combo-anchored/tool-bootstrap.mjs crashed on every prompt with TypeError: Cannot read properties of undefined (reading 'length') at the state.next < events.length loop in scanEvents() (session.events was removed in 0.1.2, so nothing after session-creation was ever persisted). Patching only scanEvents() to feature-detect snapshotEvents() — the same pattern as this PR — restored normal operation, verified end-to-end on a live instance (model replies, phase-1 anchoring intact, first-request input back to ~1.4K tok). The session.snapshotEvents ? session.snapshotEvents() : (session.events ?? []) fallback is confirmed sufficient on both 0.1.1 and 0.1.2-rc.1. Also affected the local anchored-creator copy the same way.

@xiaobright
xiaobright merged commit 4458390 into xiaobright:main Sep 6, 2026
xiaobright added a commit that referenced this pull request Sep 6, 2026
…ompat)

The mock suite only exercised the legacy session.events fallback that PR #88
keeps for older harness builds. Add snapshot-only session mocks (no events
property, mirroring dsh 0.1.3-alpha.1) across the core scan paths: tool
bootstrap promotion, dev_tool_search durable unlocks, compaction re-anchoring,
anchor-turn freshness, and instruction-hint restart safety. 223/223.
xiaobright added a commit that referenced this pull request Sep 6, 2026
…ty projects

- Record the 0.1.3-alpha.1 session.events -> snapshotEvents() change and the
  #88 compat shim in the Compatibility section (bilingual), verified by source
  comparison and the mock suite, not by live runs.
- Community projects: both-anchored (auto-b7n) per the #85 commitment once
  DeepseekCotexplorations#17 merged, plus dsh-recovery (ecosystem tooling,
  described as such).
- Acknowledge 324641aliyun; stats footnote 26/18 -> 27/19 (2026-09-06).
@xiaobright

Copy link
Copy Markdown
Owner

Merged as 4458390 — thank you for the clean, mechanical fix. Local verification and source audit on the merged main:

  • Local verification: npm run check (sync consistency + tests) passes, now 223/223 (the 214 baseline plus 9 new compat tests, see below).
  • Claim verified against the dsh source: on 0.1.3-alpha.1, the Session class keeps its log private, exposes snapshotEvents(from, to) returning a frozen readonly SessionEvent[] (cache invalidated on every append), and has no public events member — so the presets' history scans were indeed broken on that build. The plugin hook names (system-prompt/assemble, agent/pre-step, tools/pre-execute, agent/turn-stopping, …) are unchanged there, so this shim covers the breakage we know of.
  • Follow-ups pushed to main (docs + test commits after the merge):
    • a new test/snapshot-events-compat.test.mjs runs the core scan paths (promotion, dev_tool_search durable unlocks, compaction re-anchoring, anchor-turn freshness, instruction-hint restart safety) against snapshot-only session mocks — the existing mocks only exercised the legacy events fallback;
    • the Compatibility section (bilingual) now records the 0.1.3 change, with the honest caveat that this was verified by source comparison + mocks, not by live runs on that build (no API budget in maintenance mode).
  • Minor note, not blocking: a few guards call snapshotEvents() twice (Array.isArray(X) ? X : []); since the full snapshot is cached and invalidated per append this is harmless, just verbose.

CI notes: this being a first contribution, your branch CI shows action_required until a maintainer approves the run — the local verification above stands in for it. Fork PRs here also occasionally show a spurious "workflow file issue" red X; the post-merge main CI (green) is the authoritative signal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants