Last night my merge request !4466 was merged into the GitLab Language Server, the repo behind the GitLab Duo CLI. It closes issue #3312. Here is what was wrong, how I fixed it, and what four weeks of review taught me.

The bug

Sometimes the stream for a Duo CLI turn closes before the final status update arrives. When that happened, the CLI told you to restart with --existing-session-id.

That advice was usually wrong. In most cases only the last status update was lost, after the answer had already streamed. The workflow was still alive, so you could just keep typing. Restarting resumed the same workflow and changed nothing. But the notice made it look like your session was over.

Restarting only helps in one case: when the turn is stuck waiting for a tool approval that never showed up on screen. There, sending a plain message would actually fail the workflow.

The fix

The stream alone can't tell you which case you're in, so the CLI now asks the server. When a turn ends as incomplete, the backend fetches the latest workflow checkpoint and maps its status:

  • Waiting on a tool approval: keep the restart hint.
  • Waiting for input, or idle: no scary notice, so you just keep typing.
  • Finished, stopped or failed: handled exactly the way the stream would have handled it.
  • Still running, or no checkpoint yet: a cautious notice saying "send a message to continue", with the restart hint only if Duo was about to ask to run a tool.
  • The checkpoint query fails: a new checkpoint_unavailable state that falls back to the restart notice, because we can't know what's safe.

The query also respects Esc, so cancelling a turn stays instant.

What I learned

  • Read the issue twice. The issue itself said "why the socket drops is out of scope". Staying inside that line kept the MR reviewable.
  • Safety first, then UX. The hardest part wasn't the happy path. It was making sure that every unknown state failed toward the safe advice.
  • Review takes time, and that's fine. It took several rounds with the maintainer, plus GitLab Duo's automated review, before it landed. Every round made the MR better.

If you want to start contributing to GitLab, quick-win issues and the contributor platform are a great place to begin. Thanks to Karl Jamoralin for the reviews and the merge!