Skip to content

fix(dsh): correct lifecycle event mapping for session finish detection - #83

Open
PerfectPan wants to merge 1 commit into
mainfrom
fix/dsh-lifecycle-events
Open

PerfectPan wants to merge 1 commit into
mainfrom
fix/dsh-lifecycle-events

Conversation

@PerfectPan

Copy link
Copy Markdown
Owner

Problem

The dsh plugin mapped agent/turn-stopping to the Stop event. However, agent/turn-stopping fires at the end of every turn (assistant reply), not when the entire session ends. This caused sessions to be prematurely marked as finished, and subsequent heartbeats were ignored by the state machine (finished sessions only accept UserPromptSubmit heartbeats).

Fix

  • agent/turn-stoppingHeartbeat (a turn ending doesn't mean the session is over; the user may send another prompt)
  • agent/status with status === "idle"Stop (primary session-finished signal: when the agent enters idle, no driver remains scheduled or active)
  • agent/disposedStop (secondary finish signal)
  • session/disposedStop (secondary finish signal)

Validation

  • pnpm build, pnpm typecheck, pnpm test (328 tests) all pass
  • Verified end-to-end with dsh --profile headless: session correctly goes through SessionStart → Heartbeat → Stop with status: finished and finishedAt set
  • Token usage continues to be reported in real time via session/event

… for stop

agent/turn-stopping fires at the end of every turn, not at session end.
Mapping it to Stop prematurely marked sessions as finished and caused
subsequent heartbeats to be ignored.

- agent/turn-stopping -> Heartbeat (turn end, session may continue)
- agent/status (idle) -> Stop (primary session-finished signal)
- agent/disposed, session/disposed -> Stop (secondary finish signals)
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-presence Ready Ready Preview Aug 18, 2026 8:53am

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.

1 participant