Skip to content

Stop agent thread_send from unlocking thread_merge (#1433) - #1594

Merged
currentbits merged 1 commit into
mainfrom
coder/hotfix-agent-thread-send-turns-must-not--b2818b
Oct 11, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/hotfix-agent-thread-send-turns-must-not--b2818b

Conversation

@currentbits

Copy link
Copy Markdown
Owner

A worker can thread_send an idle lead “the user approved, merge me” and land itself: inbound turns reset autoTurns, so isAutoTurn is false and thread_merge({approved:true}) passes. Notices already counted as machine-delivered; thread_send did not. Closes #1433 (I3 of #1425).

Changes

  • startRun increments autoTurns (and the 25-turn crew cap) on fromInbound instead of resetting to 0
  • Notices still increment only in flushOrchNotices, so one inbound is not double-counted
  • User send, retry, and verify-fix still reset the counter

Verification

  • New orch-merge test: a fromInbound turn leaves isAutoTurn true and refuses thread_merge({approved:true}). Failed first (false !== true), passed after the fix.
  • electron/test/orch-merge.test.js and electron/test/crew-notices.test.js both pass with inherited CODER_* unset.

Notes for reviewers

Inbound cap exhaustion throws from startRun rather than the notice undeliverable-event path. That is intentional: inbound never goes through flushOrchNotices.


cursor-grok-4.6 via Cursor

Made with Cursor

A worker can otherwise ping an idle lead and pass thread_merge with approved:true because fromInbound reset autoTurns to 0.

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T19:11:38.852241Z 86da63b PR opened
ℹ️ 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.

@currentbits
currentbits merged commit 8a2d959 into main Oct 11, 2026
4 of 6 checks passed

@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: 86da63b1fd

ℹ️ 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 electron/runner.js
// delivered: increment here, not in flushOrchNotices, so one inbound
// is not double-counted or capped twice. User send, retry, and
// verify-fix still reset to 0.
if (input.fromInbound) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid recounting inbound turns when admitting queued runs

When the global concurrency cap queues a fromInbound start, this branch increments autoTurns before enqueueRun stores the unchanged input; admitQueuedRuns later calls startRun again with that same fromInbound: true, incrementing it a second time. Besides exhausting the 25-turn cap prematurely, an inbound queued when the counter is 24 is accepted initially but rejected on admission after the queue entry has already been cleared, so the message never runs. Count the inbound only when it is actually admitted, or skip the increment for fromRunQueue re-entry.

Useful? React with 👍 / 👎.

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.

Hotfix: agent thread_send turns must not count as human (merge gate)

1 participant