Skip to content

tui: Session crashes with "Failed to drain Session" error #57442

Closed as duplicate

Description

@jergauthier

Summary

OpenCode sessions are crashing intermittently with a "Failed to drain Session" error. The error appears in both GNOME Terminal and xterm, and it seems to happen most often when the agent is thinking or running commands. The error message indicates that the AI is receiving an empty message, which is causing the session to crash.

Environment

  • opencode version: 2.1.1
  • OS: Linux jbn5.tamu.edu 4.18.0-553.144.1.el8_10.x86_64 feat: compact and other improvements #1 SMP Tue Jul 14 13:14:49 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
  • Terminal: xterm-256color
  • Shell: /bin/tcsh
  • Install/channel: latest
  • Active plugins: None found in config

Reproduction

  1. Start an OpenCode session in either GNOME Terminal or xterm.
  2. Interact with the agent, especially by having it run commands.
  3. The session will intermittently crash.

Expected Behavior

The OpenCode session should not crash.

Actual Behavior

The session crashes, and the logs show a "Failed to drain Session" error with the following message:

level=ERROR run=b96943e0 message="Failed to drain Session" cause="AI.Error: [{'type': 'string_type', 'loc': ['body', 'messages', 29, 'content', 'str'], 'msg': 'Input should be a valid string', 'input': None}, {'type': 'list_type', 'loc': ['body', 'messages', 29, 'content', 'list[any]'], 'msg': 'Input should be a valid list', 'input': None}]"

Additional Context

The user does not have any local plugins installed. The issue has been observed in both GNOME Terminal and xterm.

The user's ~/.config/opencode/opencode.json is:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "chat.tamu.ai": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "TAMUS AI Chat API",
      "options": {
        "baseURL": "https://chat-api.tamu.ai/api"
      },
      "models": {
        "protected.Claude 3.5 Haiku": { "name": "Claude 3.5 Haiku" },
        "protected.Claude 3.5 Sonnet": { "name": "Claude 3.5 Sonnet" },
        "protected.Claude 3.7 Sonnet": { "name": "Claude 3.7 Sonnet" },
        "protected.Claude Opus 4.1": { "name": "Claude Opus 4.1" },
        "protected.Claude Opus 4.5": { "name": "Claude Opus 4.5" },
        "protected.Claude Sonnet 4": { "name": "Claude Sonnet 4" },
        "protected.Claude Sonnet 4.5": { "name": "Claude Sonnet 4.5" },
        "protected.Claude-Haiku-4.5": { "name": "Claude Haiku 4.5" },
        "protected.gemini-2.5-flash": { "name": "Gemini 2.5 Flash" },
        "protected.gemini-2.5-flash-lite": { "name": "Gemini 2.5 Flash Lite" },
        "protected.gemini-2.5-pro": { "name": "Gemini 2.5 Pro" },
        "protected.gpt-4.1": { "name": "GPT-4.1" },
        "protected.gpt-4o": { "name": "GPT-4o" },
        "protected.gpt-5": { "name": "GPT-5" },
        "protected.gpt-5.1": { "name": "GPT-5.1" },
        "protected.gpt-5.2": { "name": "GPT-5.2" },
        "protected.llama3.2": { "name": "Llama 3.2" },
        "protected.o3": { "name": "o3" },
        "protected.o3-mini": { "name": "o3-mini" },
        "protected.o4-mini": { "name": "o4-mini" },
        "protected.text-embedding-3-small": { "name": "Text Embedding 3 Small" }
      }
    }
  },
  "model": "chat.tamu.ai/protected.gemini-2.5-pro"
}

Activity

  1. opencode-agent commented on Oct 20, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the log line. I think this is a duplicate of #51661.

    The error says the provider rejected messages[29].content because it was None. When the model makes a tool call (for example, running a command) without any text, OpenCode v2 sends that assistant message with "content": null. The OpenAI spec allows this, but some OpenAI-compatible endpoints only accept a string or a list. That seems to be the case for chat-api.tamu.ai, and it explains why the crash happens while the agent is running commands.

    Possible duplicates and related issues, ordered from most to least likely:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. Please follow #51661 for updates.

  2. opencode-agent commented on Oct 21, 2026

    @opencode-agent
    Contributor

    Closing as a duplicate of #51661, since there's been no reply saying this problem is different. In both issues, an assistant message that makes a tool call without any text is sent with "content": null, and stricter OpenAI-compatible endpoints like chat-api.tamu.ai reject that. Please follow #51661 for updates. It also describes a workaround plugin that replaces null with "". If you think your case is different, reply here with the details and we can reopen it. Thanks for the report!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions