You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show chats messages created by the sdk in real time in the opencode cli (even if opencode server is different) #2403
Currently messages created with the sdk are only shown if you reload the cli or refetch the session data with /sessions
Repro
Create a new session from the sdk
submit a message to it with prompt method
Start opencode and run /sessions to display that session
Opencode will not update with new assistant new parts. Even after the assistant message completes. To see the final message you have to run /sessions again and reopen the session
I searched through existing issues and couldn't find any clear duplicates of this specific issue. While there are several issues related to session management, message handling, and real-time updates, none specifically address the problem of SDK-created messages not appearing in the CLI in real-time.
This appears to be a unique feature request for implementing real-time message synchronization between the SDK and CLI, which would likely require implementing either polling or server-sent events as suggested.
Start a new opencode server, connect to it with the sdk
Create a new session from the sdk
submit a message to it with prompt method
Start opencode tui and run /sessions to display that session
Opencode will not update with new assistant new parts. Even after the assistant message completes. To see the final message you have to run /sessions again and reopen the session
changed the title [-]Show chats messages created by the sdk in real time in the opencode cli (by polling or using an SSE endpoint)[/-][+]Show chats messages created by the sdk in real time in the opencode cli (even if opencode server is different)[/+]on Sep 22, 2025
The problem seems to be that opencode servers do not share the same events stream, to do this we would probably need a centralized place where all opencode servers subscribe and send events, something like Redis pubsub
Using opencode serve did not work for me either. Attaching a cli to the running server and then using the sdk to e.g. inject a prompt always led to "forking", i.e. the session in the cli would not update live and act as nothing was ever injected, while a parallel session seems to run with the new injected prompt on the server. So when I restart the cli and enter that session, I see the injected prompt AND the agents reponse.
I could circumvent this problem by using opencode web on the 4096 port. Attaching the cli to that port and then using the sdk to inject a prompt live updated the cli as well as the web client, although I am not sure how stable this is, since I have not robust-tested this yet and I did have one session that simply kept forking instead of updating.
Activity
github-actions commentedon Sep 3, 2025
I searched through existing issues and couldn't find any clear duplicates of this specific issue. While there are several issues related to session management, message handling, and real-time updates, none specifically address the problem of SDK-created messages not appearing in the CLI in real-time.
This appears to be a unique feature request for implementing real-time message synchronization between the SDK and CLI, which would likely require implementing either polling or server-sent events as suggested.
rekram1-node commentedon Sep 3, 2025
Can you share your code? I've had this working just fine in the past without reloads
remorses commentedon Sep 4, 2025
To reproduce:
promptmethod[-]Show chats messages created by the sdk in real time in the opencode cli (by polling or using an SSE endpoint)[/-][+]Show chats messages created by the sdk in real time in the opencode cli (even if opencode server is different)[/+]remorses commentedon Sep 22, 2025
The problem seems to be that opencode servers do not share the same events stream, to do this we would probably need a centralized place where all opencode servers subscribe and send events, something like Redis pubsub
rekram1-node commentedon Dec 28, 2025
[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
pspranger-throw commentedon Jan 23, 2026
Using opencode serve did not work for me either. Attaching a cli to the running server and then using the sdk to e.g. inject a prompt always led to "forking", i.e. the session in the cli would not update live and act as nothing was ever injected, while a parallel session seems to run with the new injected prompt on the server. So when I restart the cli and enter that session, I see the injected prompt AND the agents reponse.
I could circumvent this problem by using opencode web on the 4096 port. Attaching the cli to that port and then using the sdk to inject a prompt live updated the cli as well as the web client, although I am not sure how stable this is, since I have not robust-tested this yet and I did have one session that simply kept forking instead of updating.