Skip to content

🤖 fix: lock goal state to chat tail#3404

Merged
ammario merged 1 commit into
mainfrom
fix/goal-chat-tail-state
May 27, 2026
Merged

🤖 fix: lock goal state to chat tail#3404
ammario merged 1 commit into
mainfrom
fix/goal-chat-tail-state

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented May 27, 2026

Summary

  • Locks goal running/paused mode to the accepted chat tail: a latest user goal_continuation turn means running, while manual user turns pause the goal.
  • Makes Resume await enough of kickoff dispatch for the continuation user message to be accepted before reporting the goal active.
  • Removes the redundant "Send and pause goal" UI action because manual sends now pause by default.

Background
The previous model kept goal.json.status and chat history loosely coupled. Resume could flip a goal to active before the continuation message was actually accepted, and manual "steer" sends could leave a goal active even though the latest user message was not a continuation.

Implementation

  • Added chat-tail reconciliation in WorkspaceGoalService and a hidden synthetic pause boundary for explicit Pause.
  • Added background-start support for accepted goal continuation sends so Resume can return after the continuation row is durable instead of waiting for the whole stream.
  • Marked CLI goal-run driver turns as goal continuations because CLI suppresses the desktop kickoff dispatcher and drives those turns itself.

Validation

  • bun test src/node/services/workspaceGoalService.test.ts src/node/services/agentSession.goalAutoPause.test.ts tests/ui/chat/sendModeDropdown.test.ts ./tests/ui/chat/goalSlashCommand.test.ts
  • bun run typecheck
  • make static-check

Risks

  • Manual messages during a running goal now pause instead of steering while remaining active. This is intentional for the new invariant, but users must press Resume to continue autonomous goal progress after manual intervention.

Generated with mux • Model: openai:gpt-5.5 • Thinking: xhigh • Cost: unknown

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e2af42543

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceGoalService.ts Outdated
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 2e2af42 to 4607794 Compare May 27, 2026 16:24
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 460779475b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceService.ts Outdated
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 4607794 to f0820ef Compare May 27, 2026 16:30
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FKG8HreadChatTailGoalMode now skips synthetic maintenance user rows unless they are explicit goal_continuation rows or the new typed goal-pause-boundary marker. Added coverage with a synthetic heartbeat row after a continuation so maintenance rows do not pause active goals.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0820ef87a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/agentSession.ts
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from f0820ef to 2750139 Compare May 27, 2026 16:47
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FKYCg — normal goal continuation candidates are now retained until stream-end replaces/clears them, and WorkspaceService.executeGoalContinuation re-requests the pending candidate if a background continuation fails before stream start. Budget-limit wrap-ups keep the old awaited behavior.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FKdxw — background goal continuations now install an onAcceptedPreStreamFailure handler via WorkspaceService.executeGoalContinuation, and normal continuation candidates are retained so that handler can re-request dispatch instead of losing the retry. Budget-limit wrap-ups still await startup/stream completion.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27501391f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/run.ts
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 2750139 to 41e349c Compare May 27, 2026 17:02
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 41e349c to 449b3e4 Compare May 27, 2026 17:05
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FKvvf — CLI goal driver sends now mark goal-run turns as synthetic and agentInitiated along with goalContinuation, so AgentSession does not treat them as manual interventions and auto-pause the goal.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41e349ce27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/run.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Codex follow-up:

  • PRRT_kwDOPxxmWM6FK_P0 appears to be reviewing stale context. The current branch sets synthetic: true and agentInitiated: true immediately before goalKind: GOAL_CONTINUATION_KIND in src/cli/run.ts, so CLI goal turns bypass manual goal-intervention safety as requested.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 449b3e4b31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceGoalService.ts
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 449b3e4 to 1a52a39 Compare May 27, 2026 17:18
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 1a52a39 to 7c8fa86 Compare May 27, 2026 17:21
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FLElTappendGoalPauseBoundaryIfNeeded now reports whether it actually made the chat tail safe to reconcile. If the hidden pause boundary append fails, setGoal(status: "paused") keeps the just-written paused goal state and skips reconciling against the stale continuation tail.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c8fa866c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceGoalService.ts
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 7c8fa86 to 4fb7001 Compare May 27, 2026 17:29
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FLR4FAgentSession now recognizes synthetic goal-pause-boundary messages and skips them when selecting the last non-system history message and when considering startup retry user messages.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fb7001d37

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceService.ts Outdated
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from 4fb7001 to c2bd44e Compare May 27, 2026 17:37
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FLZfEstartStreamInBackground is now requested only for kickoff/resume candidates. Normal stream-end auto-continuations and budget-limit wrap-ups await through executeGoalContinuation, so IdleDispatcher keeps its concurrency slot for the active goal stream. Kickoff candidates are still retained for startup-failure retry.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2bd44ee77

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceGoalService.ts
---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `unknown`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=unknown -->
@ammar-agent ammar-agent force-pushed the fix/goal-chat-tail-state branch from c2bd44e to 4510e09 Compare May 27, 2026 17:52
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

Addressed Codex feedback:

  • PRRT_kwDOPxxmWM6FLiCN — explicit pause now clears any pending kickoff continuation candidate before reconciling the pause boundary. Added coverage that a deferred kickoff does not fire after the user pauses.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammario ammario merged commit bb3ac5f into main May 27, 2026
24 checks passed
@ammario ammario deleted the fix/goal-chat-tail-state branch May 27, 2026 18:35
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.

2 participants