Setting a goal is not working with Failed to set thread goal: thread/goal/set failed in TUI

Resolved 💬 14 comments Opened May 1, 2026 by filip-minic Closed May 30, 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?

ChatGPT Pro Lite

Which model were you using?

gpt.5.5

What platform is your computer?

Darwin 25.4.0 arm64 arm

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

Terminal.app

What issue are you seeing?

Trying to set a goal (which is somewhat detailed) results in the error message:

Failed to set thread goal: thread/goal/set failed in TUI

What steps can reproduce the bug?

Uploaded thread: 019de31e-1130-7262-939a-e8479075fb3a

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

14 Comments

github-actions[bot] contributor · 2 months ago

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

  • #20591

Powered by Codex Action

etraut-openai contributor · 2 months ago

I'm guessing that your state db (~/.codex/state_5.sqlite) is corrupt. Try temporarily renaming it and restarting CLI. It should rebuild the db. By any chance, have you built Codex from source and/or run a fork at any point?

asafyish · 2 months ago

Uploaded thread: 019decd7-22a6-7b91-b0c6-11838b69fb3f
Happens to me too. I deleted state_5.sqlite and sidecars, logs_2.sqlite-wal, logs_2.sqlite-shm.
Installed using brew.

21888 · 2 months ago

same +1

21888 · 2 months ago

Is this an issue with long text? [pasted content 10997 chats]

asafyish · 2 months ago

I guess it's long text related. I pasted around 8k text. When I put the same text in a file and set the goal to read that file, it worked.

etraut-openai contributor · 2 months ago

Yes, goals are limited to 4000 characters. If you have a complex goal definition, you should write it to a file and refer to the file from the goal definition: /goal implement the app described by app_spec.md.

I'll add a better error message for cases where you exceed the 4000-character limit.

landanqrew · 2 months ago

I am running into this issue as well.

Here is my current prompt: /goal work exclusively within the current repo to implement the @goal.md

Here is the error: ■ Failed to read thread goal: thread/goal/get failed in TUI

I tried to delete instances of sqlite files in the ~/.codex directory but no success.

AdelEnazi1117 · 2 months ago

I ran into the same /goal failure and got it working with this workaround:

  1. Make sure the feature flag is enabled in ~/.codex/config.toml:
[features]
goals = true
  1. Restart Codex after changing the config.
  1. If /goal still fails with Failed to set thread goal: thread/goal/set failed in TUI, try setting a much shorter, single-line goal. In my case, long pasted objectives/specs seem to trigger the failure, while a concise goal works.

Example:

/goal Implement the requested fix, keep tests passing, and verify the main flow before stopping.

So the practical workaround is: enable features.goals, restart Codex, then keep the /goal text short instead of pasting a full task brief.

omarpinarecords · 1 month ago

I am seeing the same Goal mode failure family in Codex Desktop on macOS.

Symptoms:

  • The visible /goal / composer UI path fails with Failed to set goal.
  • After a backend-created test goal was completed, the visible UI still showed goal controls and failed to remove/clear it with Failed to clear goal.
  • The failure appears limited to the visible UI/composer/progress-row path: the backend assistant-side goal path was able to create and complete a goal, and later readback showed the goal status as complete.

Local config/runtime checks:

  • Project config has [features] goals = true.
  • codex features list reports goals experimental true.
  • codex --version reports codex-cli 0.133.0-alpha.1.

Trace:

  • Feedback ID: b7db443f-9070-4a60-8a1a-04df8a0e3139

Related public signals I found while checking before posting:

  • #20598 - thread/goal/set failure family.
  • #20841 - thread/goal/get failure family.
  • #20591 - /goal slash-command failure family.
  • #23984 - meta issue for /goal failures hiding DB/schema/process mismatch.
  • #24282 - Codex Desktop goal setting failure after thread/title state.

This looks less like the feature flag being disabled and more like a UI/composer/progress-row state synchronization or thread-goal routing problem.

omarpinarecords · 1 month ago

Addendum: performance trace uploaded from the Codex app.

Feedback ID:

b7db443f-9070-4a60-8a1a-04df8a0e3139

This Feedback ID corresponds to the Goal mode UI set/clear failure described above:

  • Visible UI /goal path showed Failed to set goal.
  • Visible UI clear/remove path showed Failed to clear goal.
  • Backend goal create/complete/readback path succeeded, with readback later showing status: complete.

I am adding this comment to make explicit that the Feedback ID is from an uploaded Codex performance trace, not just a local tracker reference.

omarpinarecords · 1 month ago

Follow-up after config repair and restart:

I found a local config-side problem that explains why Goal mode could appear unavailable or inconsistent across folders, and I repaired it locally.

Before repair, user-level Codex config had:

approval_policy = "never"
approvals_reviewer = "auto_review"

That means Auto-review was configured but approval prompts were disabled, so the Auto-review route could not actually be used for interactive approval requests. I changed it to:

approval_policy = "on-request"
approvals_reviewer = "auto_review"

[features]
goals = true

After restart, codex features list reports goals experimental true in both affected folders I checked. This repaired the local Goal enablement/config issue.

What I learned from the official docs/Cookbook:

  • Goal mode requires the features.goals = true feature flag when /goal does not appear or is not enabled.
  • Auto-review only applies when approvals are interactive, such as approval_policy = "on-request"; approval_policy = "never" disables approval prompts.
  • Goals are thread-scoped persistent objectives with lifecycle controls such as set, pause, resume, clear, complete, and budget/blocked stopping.
  • Cookbook guidance treats a strong Goal as an evidence-checked completion contract: outcome, verification surface, constraints, boundaries, iteration policy, and blocked stop condition.

Remaining issue boundary:

If the visible app composer/progress-row still fails to set or clear a goal after this config repair and restart, then the remaining failure is no longer explained by local config. It should stay tracked as a Codex UI/thread-goal state issue in this thread/issue family.

Same uploaded performance trace reference:

Feedback ID: b7db443f-9070-4a60-8a1a-04df8a0e3139

Sources:

omarpinarecords · 1 month ago

Additional public sibling to track with this Goal failure family: #24423.

#24423 reports Codex App Goal set and clear failures on Desktop, including /goal clear, with local evidence pointing to older thread resume parsing before the goal operation. GitHub Actions linked #24423 to possible duplicates #24140 and #24282.

This keeps the failure family connected without closing anything prematurely. The issue still appears unresolved unless maintainers identify a canonical duplicate, ship a fix, or provide a supported workaround.

etraut-openai contributor · 1 month ago

This /goal feature is now enabled by default in the latest version of the app and the CLI. Some users were hitting the "failed to set thread goal" because they were running an older version of the Codex app or app server where the goals feature was not enabled.

Some users were also hitting this because of a local db corruption. We've traced the problem to a bug in sqlite, and we've updated the version of sqlite that Codex is using. If you are still seeing thread/goal/get failures with the latest version of the app or CLI, that's the most likely cause. You can work around this by deleting CODEX_HOME/.codex/goals_1.sqlite* and CODEX_HOME/.codex/state_5.sqlite* and restarting codex. It will reconstruct these db files.