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

Resolved 💬 15 comments Opened May 3, 2026 by txtttx Closed May 16, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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_

View original on GitHub ↗

15 Comments

github-actions[bot] contributor · 2 months ago

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

  • #20598

Powered by Codex Action

txtttx · 2 months ago

@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

etraut-openai contributor · 2 months ago

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.

txtttx · 2 months ago
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

etraut-openai contributor · 2 months ago

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.

txtttx · 2 months ago
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.

Dhi13man · 2 months ago

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]

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.

etraut-openai contributor · 2 months ago

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).

BadAtCaptchas · 2 months ago

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.

etraut-openai contributor · 2 months ago

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

sriinnu · 2 months ago

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)

darlingm contributor · 2 months ago
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.

n-WN · 2 months ago

Version 0.132.0 has a similar issue.

extsps · 1 month ago

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

ench2 · 1 month ago

同时安装了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 表被新版本迁移删除了。