What is the deterministic way to monitor a session is completed #2526

Open
opened 2026-02-16 17:36:06 -05:00 by yindo · 5 comments
Owner

Originally created by @krishna1s on GitHub (Nov 3, 2025).

Originally assigned to: @rekram1-node on GitHub.

Question

Hi Team,

We are using the opencode/sdk and we are observing one issue, where we monitor a session based on session event, and we receive the session idle event sooner, but it seems session might still be working, is there is any deterministic way where we can say agent has stop working and might be asking for user input. Also let me know if it is possible to done by experimental hooks, please provide any sample code if there to check for session completetion

Thanks

Originally created by @krishna1s on GitHub (Nov 3, 2025). Originally assigned to: @rekram1-node on GitHub. ### Question Hi Team, We are using the opencode/sdk and we are observing one issue, where we monitor a session based on session event, and we receive the session idle event sooner, but it seems session might still be working, is there is any deterministic way where we can say agent has stop working and might be asking for user input. Also let me know if it is possible to done by experimental hooks, please provide any sample code if there to check for session completetion Thanks
Author
Owner

@github-actions[bot] commented on GitHub (Nov 3, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #3075: [QUESTION] How can I know if the session has ended from the server API? - This addresses the exact same question about determining when a session/AI response has completed via API
  • #3169: Feature Request: Session Information: State - Requests session state information to indicate whether sessions are active or idle, which would help with deterministic session monitoring
  • #3534: "Session went idle" text - Discusses issues with session idle events and their timing
  • #3744: plugin events are fired multiple times - Shows session.idle events being fired multiple times, indicating potential issues with session event reliability

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 3, 2025): This issue might be a duplicate of existing issues. Please check: - #3075: [QUESTION] How can I know if the session has ended from the server API? - This addresses the exact same question about determining when a session/AI response has completed via API - #3169: Feature Request: Session Information: State - Requests session state information to indicate whether sessions are active or idle, which would help with deterministic session monitoring - #3534: "Session went idle" text - Discusses issues with session idle events and their timing - #3744: plugin events are fired multiple times - Shows session.idle events being fired multiple times, indicating potential issues with session event reliability Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Nov 3, 2025):

@krishna1s

we receive the session idle event sooner

Sooner than what? I could see you getting session idle event and then the title generation completing after and sending session updated, but maybe you are encountering some other issues?

@rekram1-node commented on GitHub (Nov 3, 2025): @krishna1s > we receive the session idle event sooner Sooner than what? I could see you getting session idle event and then the title generation completing after and sending session updated, but maybe you are encountering some other issues?
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

Hm I guess the title generation is kinda a "background" thing so it doesnt follow the normal rules but I see what you are saying

@rekram1-node commented on GitHub (Nov 7, 2025): Hm I guess the title generation is kinda a "background" thing so it doesnt follow the normal rules but I see what you are saying
Author
Owner

@krishna1s commented on GitHub (Nov 9, 2025):

@rekram1-node I am also observing the same , session idle is coming sooner the agent is completing work

Also the issues which you have tagged, message api doesn't even guaranteed that agent has finished the worked, What I have observed is, when a session hang, message api is stuck forever so we never know when is the actual session getting completed

@krishna1s commented on GitHub (Nov 9, 2025): @rekram1-node I am also observing the same , session idle is coming sooner the agent is completing work Also the issues which you have tagged, message api doesn't even guaranteed that agent has finished the worked, What I have observed is, when a session hang, message api is stuck forever so we never know when is the actual session getting completed
Author
Owner

@rekram1-node commented on GitHub (Nov 10, 2025):

@krishna1s Did I tag an issue? I dont think I did?

session idle is coming sooner the agent is completing work

are you using subagents or something, can u provide any steps to reproduce this? The only case this should be possible is for one of the background things like title gen to still be going, otherwise we send that event after the agent loop is finished

I have a plugin that fires toasts whenever the session idle happens, I've never seen it fire a toast before the session was complete but maybe there is some edge case that I don't encounter that you guys have?

@rekram1-node commented on GitHub (Nov 10, 2025): @krishna1s Did I tag an issue? I dont think I did? > session idle is coming sooner the agent is completing work are you using subagents or something, can u provide any steps to reproduce this? The only case this should be possible is for one of the background things like title gen to still be going, otherwise we send that event after the agent loop is finished I have a plugin that fires toasts whenever the session idle happens, I've never seen it fire a toast before the session was complete but maybe there is some edge case that I don't encounter that you guys have?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2526