Skip to content

Fix goal update and add /goal edit command in TUI#21954

Open
etraut-openai wants to merge 5 commits intomainfrom
etraut/goal-edit-steering
Open

Fix goal update and add /goal edit command in TUI#21954
etraut-openai wants to merge 5 commits intomainfrom
etraut/goal-edit-steering

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented May 9, 2026

Why

Users have requested the ability to edit a goal's objective after a goal has been created. This PR exposes a new /goal edit command in the TUI to address this request.

In the process of implementing this, I also noticed an existing bug in the goal runtime. When a goal's objective is updated through the thread/goal/set app server API, the goal runtime didn't emit a new steering prompt to tell the agent about the new objective. This PR also fixes this hole.

What Changed

  • Adds /goal edit in the TUI, opening an edit box prefilled with the current goal objective.
  • Keeps active and paused goals in their current state, resets completed goals to active, keeps budget-limited goals budget-limited, and preserves the existing token budget.
  • Changes the existing thread/goal/set behavior so editing an objective preserves goal accounting instead of resetting it. The older reset-on-new-objective behavior was left over from before thread/goal/clear; clients that need to reset accounting can now clear the existing goal and create a new one.
  • Reuses the existing goal set API path; this does not add or change app-server protocol surface area.
  • Adds a dedicated goal runtime steering prompt when an externally persisted goal mutation changes the objective, so active turns receive the updated objective.

Validation

  • Make sure /goal edit returns an error if no goal currently exists
  • Make sure /goal edit displays an edit box that can be optionally canceled with no side effects
  • Make sure that an edited goal results in a steer so the agent starts pursuing the new objective
  • Make sure the new objective is reflected in the goal if you use /goal to display the goal summary
  • Make sure that /goal edit doesn't reset the token budget, time/token accounting on the updated goal

@etraut-openai etraut-openai requested a review from a team as a code owner May 9, 2026 18:09
@etraut-openai etraut-openai changed the title Add goal edit and objective-change steering Fixed goal update and added /goal edit command in TUI May 9, 2026
@etraut-openai etraut-openai changed the title Fixed goal update and added /goal edit command in TUI Fix goal update and add /goal edit command in TUI May 9, 2026
Comment thread codex-rs/core/src/goals.rs Outdated
@canvrno-oai
Copy link
Copy Markdown
Contributor

When testing /goal edit, it did reset the Time Used/Tokens Used values for the edited goal. The edits were successfully applied and steered, and edits were cancellable.

@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@canvrno-oai, good catch! I forgot that my original implementation cleared the goal time/token accounting when the objective was updated. That design decision no longer makes sense for the thread/goal/set api because I have since added a dedicated thread/goal/clear api that clients can use if they want to start a new goal (including resetting its account stats). I've updated the code in the PR accordingly.

Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex found this issue where if we edit the goal, it should reset the token budget.

Right now the replacement UI can strand the user in the old goal’s exhausted budget/accounting unless they know to manually /goal clear first.

And it suggested a manual repro:

  1. Create a goal with a token budget.
  2. Let it accumulate usage until it is budget-limited, or set usage over budget through the existing goal accounting path.
  3. Run /goal some new objective.
  4. Choose “Replace current goal”.
  5. Observe the returned goal keeps the previous usage/budget and may remain budgetLimited instead of starting the new objective active with fresh accounting.

However I was unable to start a new goal with a token limit. I tried:

/goal --tokens 8000 find largest rs file by complexity
/goal find largest rs file by complexity, use up to 8000 tokens

But both of them completed the goal with more than 8000 tokens used.

Did we remove the limit?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants