Skip to content

🤖 fix: fence a child's stale goal-agent refusal and fix its recovery wording - #5454

Merged
ThomasK33 merged 5 commits into
mainfrom
fix/5452-child-goal-refusal
Oct 2, 2026
Merged

ThomasK33 merged 5 commits into
mainfrom
fix/5452-child-goal-refusal

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #5452. A sub-agent's fail-closed goal-agent check (#5402) awaited without fencing its dispatch. A refusal that went stale during the check could show an obsolete chat error and pause a goal that a newer attempt (or a just-resumed goal) owned. The refusal text also told the user to "select an available agent", which cannot help a child: the picker does not repin its agentType.

Implementation

  1. Staleness fence (item 1). TaskService.sendChildGoalTurn builds a synchronous stillCurrent(goal) check. It holds while the captured attempt is still the task's current attempt and the goal keeps the same goalId, status and user-activation stamp (every user Resume restamps it).
    • The chat error: refuseUnavailableGoalTurnAgent takes a probe (it may now be async). The probe reads the goal under the goal file lock, then applies stillCurrent, so the attempt is checked after that await.
    • The pause: pauseForUnavailableAgent passes the fence to the write. A new internal SetGoalInput.stillCurrent is evaluated under the goal file lock next to expectedGoalId, and a refusal is a goal_conflict. reserveBudgetWrapupForRedispatch takes the same fence for a budget-limited goal.
    • A stale refusal therefore changes nothing. The stream end takes its normal path, which has its own attempt fences. Fail-closed behavior is unchanged for a current dispatch.
  2. Child wording (item 2). resolveAgentForStream's goal-turn refusal for a sub-agent names the pinned agent to restore or enable before reactivating the task. It no longer asks the user to select an agent. It does not promise a goal resume, because a reported child cannot resume its goal yet (🤖 Sub-agent goals: follow-ups (parent spend ceiling, UI test, deleted child agent) #5411 item (c), deferred).

Validation

Test-first. Before the fix:

Expected: "active"
Received: "paused"
(fail) TaskService child goals > a refusal whose attempt was replaced during the check leaves the goal alone
Expected: false
Received: undefined
(fail) TaskService child goals > a refusal whose goal was paused and resumed during the check shows no chat error
error: expect(received).not.toContain(expected)
Expected to not contain: "select an available agent"
(fail) AIService.streamMessage … > a sub-agent's goal turn does not fall through to a later candidate or exec

All three pass after the fix. A further test, "an attempt replaced just before the refusal's pause write keeps its goal", fails if the write fence is removed.

Deferred

Risks

Low. The change only drops a refusal whose dispatch is stale, and only on the child goal-turn path. The newer attempt or goal runs its own fail-closed check before any goal turn. The root goal dispatcher's synchronous probe is still evaluated in the same tick as its chat error, with no await (tested).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

…wording

Fixes #5452.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high -->
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T10:11:55.400873Z 2a83c22 New commits
🔒 Security Review ✅ Completed 2026-10-02T10:13:41.340641Z 2a83c22 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 90cfb0fe30

ℹ️ 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/taskService.ts Outdated
Comment thread src/node/services/taskService.ts Outdated
Comment thread src/node/services/aiService.test.ts Outdated

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

Copy link
Copy Markdown

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: 57afa72d14

ℹ️ 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/taskService.ts Outdated
Comment thread src/node/services/taskService.childGoals.test.ts

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

Copy link
Copy Markdown

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: 200f6e9a15

ℹ️ 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/taskService.ts Outdated

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

Copy link
Copy Markdown

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: 5c69b7d4f7

ℹ️ 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
Comment thread src/node/services/workspaceService.ts Outdated
Comment thread src/node/services/workspaceGoalService.ts
@ThomasK33

Copy link
Copy Markdown
Member Author

Readiness record (issue coordinator lane, workspace-63):


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit b343968 Oct 2, 2026
39 checks passed
@ThomasK33
ThomasK33 deleted the fix/5452-child-goal-refusal branch October 2, 2026 10:33
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.

🤖 Goal agent fail-closed (#5402) follow-ups: child refusal handling

1 participant