Skip to content

Let agents end a chat's /goal themselves (goal_clear) - #266

Merged
danielehrhardt merged 1 commit into
mainfrom
feat/goal-clear-tool
Oct 29, 2026
Merged

danielehrhardt merged 1 commit into
mainfrom
feat/goal-clear-tool

Conversation

@danielehrhardt

Copy link
Copy Markdown
Contributor

Why

When the human drops a /goal (for example "end the goal, the site stays live passively"), the goal's Stop hook keeps blocking every turn until its condition is met. The agent could not end it, so it had to give the human a task to type /goal clear.

What

  • New MCP tool goal_clear({ reason }) for chat runs. It reads the chat's goal from Claude Code's session file: the latest goal_status decides, the same rule Claude Code uses when it resumes a session. It also works for GLM runs, which keep their own config folder.
  • Once the tool is called, the next block from the goal's check ends the process, the same way the existing idle-goal pause does. The agent's answer stays.
  • After the turn, Godmode runs /goal clear in the Claude session. This is a local Claude Code command with no model call (about 1 s, checked against CLI 2.1.312).
  • The chat then shows the notice "Goal ended: “…” — reason".
  • If the human presses Stop before the turn ends, the goal stays and the chat says so. Stopping to send the queued messages now, or shutting down, still ends it.
  • Prompt: one sentence in the follow-up section. Tool card: "Ended the goal".

Tests

  • test/goal-clear.test.ts (5 tests): how the session's goal status is read; the full run with the fake Claude (the run ends at the check without waiting out the continuation, the clear invocation, the notice, the session is kept); a call made during a forced continuation; a chat with no goal; a run that is no longer active.
  • Also ran: run-stream, slash-commands, followups, connect, mcp and conversations suites, plus the typecheck for core and desktop.

When the human drops or replaces a /goal, the agent ends it with the new
goal_clear tool instead of handing them a task to type /goal clear. The
goal's check stops holding the turn up, and after the turn Godmode runs
/goal clear in the Claude session (a local command, no model call) and
notes it in the chat with the agent's reason. The goal is read from the
session's latest goal_status, also for GLM runs.
@danielehrhardt
danielehrhardt merged commit 3263f6d into main Oct 29, 2026
8 checks passed
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.

1 participant