Skip to content

Failed to read thread goal: thread/goal/get failed in TUI #20841

Closed

Description

@txtttx

What version of Codex CLI is running?

codex-cli 0.128.0

What subscription do you have?

pro 5x

Which model were you using?

gpt-5.5

What platform is your computer?

Darwin 25.1.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

cursor

What issue are you seeing?

■ Failed to read thread goal: thread/goal/get failed in TUI

What steps can reproduce the bug?

Uploaded thread: 019debd9-2372-7f23-92b9-9f34002a6355

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    CLIIssues related to the Codex CLI
    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal display
    app-serverIssues involving app server protocol or interfaces
    on May 3, 2026
  2. github-actions commented on May 3, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. removed
    CLIIssues related to the Codex CLI
    app-serverIssues involving app server protocol or interfaces
    on May 3, 2026
  4. txtttx commented on May 3, 2026

    @txtttx
    Author

    @etraut-openai Thanks for the suggestion. I tried to move state_5.sqlite to state_5.sqlite_backup and let it rebuild. But it doesn't help

  5. etraut-openai commented on May 3, 2026

    @etraut-openai
    Contributor

    OK, thanks for trying. I'm investigating your logs (thanks for uploading!) and that's hinting at a problem with the logs_2.sqlite file.

  6. txtttx commented on May 3, 2026

    @txtttx
    Author

    OK, thanks for trying. I'm investigating your logs (thanks for uploading!) and that's hinting at a problem with the logs_2.sqlite file.

    Thanks for the suggestion. I moved logs_2.sqlite to backup. Codex can start up much faster, but I still hit the TUI bug.

    New thread ID: 019debf3-7108-78c1-97af-8b3dfdb48951

  7. etraut-openai commented on May 3, 2026

    @etraut-openai
    Contributor

    Did you move all of the logs_2 files including the logs_2.sqlite-wal and logs_2.sqlite-shm sidecars? The latest log you uploaded hints at having inconsistent db state. Try moving all of those files to backup.

  8. txtttx commented on May 3, 2026

    @txtttx
    Author

    Did you move all of the logs_2 files including the logs_2.sqlite-wal and logs_2.sqlite-shm sidecars? The latest log you uploaded hints at having inconsistent db state. Try moving all of those files to backup.

    Thanks it resolved the issue. For whoever hit this problem, I moved logs_2.sqlite* and state_5.sqlite* to backup folders.

  9. Dhi13man commented on May 16, 2026

    @Dhi13man

    Additional 0.130.0 Linux signal

    Confirming the same failure still occurs on Linux with codex-cli 0.130.0 and
    goals experimental true.

    The useful reproducer was:

    codex app-server --listen off

    That exposed the underlying init failure:

    failed to initialize sqlite state db: failed to initialize state runtime at ~/.codex: migration 1 was previously applied but has been modified
    

    Local isolation:

    • Moving only state_5.sqlite* did not clear the migration error.
    • Moving logs_2.sqlite* too cleared the state runtime failure.
    • backfill_state.status = complete
    • Current thread exists in threads
    • PRAGMA integrity_check returned ok for the recreated state and logs DBs
    • Goal reads stopped failing after the TUI was restarted

    Failure mapping:

    flowchart TD
        Start([TUI starts]) --> Init[Init StateRuntime]
        Init --> StateDb[Open state_5.sqlite]
        StateDb --> LogsDb[Open logs_2.sqlite]
        LogsDb --> Check{Migration checksum valid?}
        Check -->|No| NoHandle[State handle missing]
        NoHandle --> GoalGet[Call thread goal get]
        GoalGet --> Error[Show goal read failure]
        Check -->|Yes| Backfill[Backfill sessions]
        Backfill --> Goals[Goal reads work]
    
    Loading

    I do not see the exact app-server init signal above, so adding it here. The confusing part is that
    the TUI points at thread/goal/get, while the actionable failure is state runtime initialization. In
    this case, the blocking DB was logs_2.sqlite*, not only state_5.sqlite*.

    Suggested product-side fix: surface the state-runtime migration error in the TUI, include the failing
    DB name, and document recovery for both state_5.sqlite* and logs_2.sqlite*, including -wal and
    -shm sidecars.

  10. etraut-openai commented on May 16, 2026

    @etraut-openai
    Contributor

    The next version (0.131.0) addresses this issue by detecting sqlite corruption and lock contention at launch time rather than allowing these conditions to appear later (e.g. when creating a goal).

  11. BadAtCaptchas commented on May 16, 2026

    @BadAtCaptchas

    Just adding that I encountered this issue, but it was caused by multiple Codex processes running and not fully closed. After I closed the other processes, the issue went away.

  12. etraut-openai commented on May 16, 2026

    @etraut-openai
    Contributor

    @rmcc3, thanks for the tip. Yes, the next version will detect this situation and recommend that you close other copies.

  13. sriinnu commented on May 18, 2026

    @sriinnu

    even with the latest version (codex-cli 0.130.0) I have the same issue. (Failed to read thread goal: thread/goal/get failed in TUI)

  14. darlingm commented on May 18, 2026

    @darlingm
    Contributor

    even with the latest version (codex-cli 0.130.0) I have the same issue. (Failed to read thread goal: thread/goal/get failed in TUI)

    I just ran into this issue so am here too. In #20591, etraut-openai suggests moving ~/.codex/state_5.sqlite and restarting. Worked for me. He said that 0.131.0 will fix this issue. They just haven't released the next update yet. The other possible issue is if you have a long /goal prompt, to put it in a file and just tell it to do what's in the file.

  15. n-WN commented on May 21, 2026

    @n-WN

    Version 0.132.0 has a similar issue.

  16. extsps commented on May 22, 2026

    @extsps

    I fixed this issue by asking Codex to find problem in logs. Codex found in logs_2.sqlite that goals feature is disabled and executed by adding goals = true into config.toml. now everything works fine

  17. ench2 commented on May 24, 2026

    @ench2

    同时安装了codex cli 与 codex app 导致的,我让codex 自己成功修复并找出原因

    1. 你的桌面版/内置 app-server 是 codex-cli 0.133.0-alpha.1
    2. 终端里的全局 codex 还是 0.130.0
    3. 两个版本共用同一个 C:\Users\Administrator.codex
    4. 新版本已经把 goal 数据迁移到 goals_1.sqlite,并从 state_5.sqlite 删除了旧的 thread_goals 表
    5. 旧版 TUI 执行 /goal 时仍然去 state_5.sqlite.thread_goals 读取
    6. 表不存在,于是报:
      Failed to read thread goal: thread/goal/get failed in TUI
      底层日志是:
      no such table: thread_goals

    所以不是 cad_viewer 项目代码导致的,也不是 SQLite 损坏。根因是 新旧 Codex 同时使用同一份用户数据目录,但它们对 goal 表的位置预期不同。

    另外日志里那些 401/403、token invalidated、插件列表加载失败,不是 /goal 失败的直接原因。直接原因就是 state_5.sqlite 里旧版 TUI 要读的 thread_goals 表被新版本迁移删除了。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions