Skip to content

Show chats messages created by the sdk in real time in the opencode cli (even if opencode server is different) #2403

Closed

Description

@remorses

Currently messages created with the sdk are only shown if you reload the cli or refetch the session data with /sessions

Repro

  1. Create a new session from the sdk
  2. submit a message to it with prompt method
  3. Start opencode and run /sessions to display that session
  4. 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

Activity

  1. github-actions commented on Sep 3, 2025

    @github-actions
    Contributor

    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.

  2. rekram1-node commented on Sep 3, 2025

    @rekram1-node
    Collaborator

    Can you share your code? I've had this working just fine in the past without reloads

  3. remorses commented on Sep 4, 2025

    @remorses
    ContributorAuthor

    To reproduce:

    1. Start a new opencode server, connect to it with the sdk
    2. Create a new session from the sdk
    3. submit a message to it with prompt method
    4. Start opencode tui and run /sessions to display that session
    5. 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
  4. 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
  5. remorses commented on Sep 22, 2025

    @remorses
    ContributorAuthor

    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

  6. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Collaborator

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

  7. pspranger-throw commented on Jan 23, 2026

    @pspranger-throw

    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.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions