Skip to content

fix(code): keep the /goal criteria prompt responsive - #5142

Merged
Mason Daugherty (mdrxy) merged 6 commits into
mainfrom
mdrxy/code/goal-criteria-prompt-freeze
Jul 30, 2026
Merged

fix(code): keep the /goal criteria prompt responsive#5142
Mason Daugherty (mdrxy) merged 6 commits into
mainfrom
mdrxy/code/goal-criteria-prompt-freeze

Conversation

@mdrxy

Copy link
Copy Markdown
Member

Related #5086, #5127

/goal <objective> and /goal amend <feedback> no longer freeze the terminal the first time Auto mode asks how to handle generated goal criteria — Enter and Esc now resolve that prompt.


Slash commands are dispatched from the App's on_chat_input_submitted handler, which is awaited inline on the Textual message pump. The /goal create and amend branches awaited the one-time "How should Auto mode handle goal criteria?" modal in that chain, so the pump stayed blocked for as long as the modal was open. The modal therefore never received the Enter/Esc key events it needs to resolve, and because the modal watchdog is ten minutes, the app looked permanently frozen — not even the quit binding got through, so users had to kill the terminal.

This is the same failure #5086 fixed for the post-install restart prompt and #5127 fixes for the /update and /install --package prompts. Only the first Auto-mode /goal in a fresh install is affected: once the preference is answered (or set in config.toml / DEEPAGENTS_CODE_GOAL_AUTO_ACCEPT_CRITERIA) no modal opens and the flow never blocks. Launching with dcode --goal ... was already fine, because the startup sequence runs off the pump.

Notes for review:

  • The shared tail of both branches moves into _start_goal_proposal, which detaches the flow only when the preference prompt is actually owed; otherwise it stays inline, so ordinary /goal behavior and its queue interaction are unchanged. The proposal coroutine is now built by a callable so a preflight failure cannot strand it un-awaited.
  • Because the handler returns while the prompt is up, a second /goal (an external caller, or a queue drain) is refused with a toast instead of stacking a modal over an unanswered one, and app teardown cancels a flow still parked on the prompt.
  • Fail-closed behavior is unchanged: a timed-out or unmountable prompt still persists "review before applying" and records the one-time marker.
  • Tests submit through the real ChatInput.Submitted path and press a key; both regression tests wedge the app (pump blocked until the pytest timeout) against the previous code. If fix(code): keep /update and /install --package prompts responsive #5127 lands first, this detach could be folded into its _schedule_off_message_pump helper.

Made by Open SWE

`/goal` is dispatched from `on_chat_input_submitted`, which is awaited
inline on the Textual message pump, and the handler awaited the one-time
Auto criteria preference modal in that chain. The pump therefore stayed
blocked while the modal was open, so it never received the Enter/Esc keys
it needs to resolve and the terminal looked frozen until the ten-minute
watchdog fired. Run the flow off the pump when the prompt is still owed,
so the handler returns and keys reach the modal.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC labels Jul 29, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review July 29, 2026 19:11

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/app.py Outdated
Mason Daugherty (mdrxy) and others added 3 commits July 30, 2026 14:06
Replace the bespoke _goal_preference_task mechanism with the shared
_schedule_off_message_pump helper. This registers the continuation in
_modal_command_tasks synchronously, so the queue drain's busy check holds
queued messages while the criteria prompt is unanswered — closing a gap
where a dequeued /goal released the queue and let a following agent turn
start concurrently with goal drafting.

Also gains centralized exit cancellation (awaited in teardown), named
failure logging, and the drain-after-modal-command queue resume. Generalize
the helper's refusal toast now that it covers goal commands, and add a
regression test driving a queued /goal + normal message through the real
drain path.
@mdrxy
Mason Daugherty (mdrxy) merged commit 6f9ea6a into main Jul 30, 2026
55 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/goal-criteria-prompt-freeze branch July 30, 2026 18:48
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Jul 31, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. Publish reads the merged CHANGELOG via `release.yml`,
not this PR description — keep them aligned anyway so the PR stays an
accurate historical record for reviewers and anyone returning later._

---


##
[0.1.51](deepagents-code==0.1.50...deepagents-code==0.1.51)
(2026-07-31)

### Features

- The status bar and usage view now show the running session cost.
([#5036](#5036))
- Removed redundant `shell` and `web_search` prompt guidance.
([#5213](#5213))
- After switching threads, Deep Agents now points back to the previous
thread.
([#5172](#5172))
- Leaving `/mcp` with pending toggles now prompts you to reconnect.
([#5211](#5211))
- `dcode config get` now accepts configuration sections.
([#5134](#5134))

### Fixes

- Kept the `/goal` criteria prompt responsive.
([#5142](#5142))
- Improved goal handling so underspecified objectives can be resolved
from conversation context.
([#5201](#5201))
- Released the turn when an interrupted worker never starts.
([#5196](#5196))
- Hid timestamp footers together with their associated rows.
([#5167](#5167))
- Fixed editable SDK detection by scanning and correlating SDK locations
more accurately.
([#5199](#5199))
- Improved `doctor` output to explain why it may not have a
latest-version answer.
([#5209](#5209))

_End release notes preview._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant