Skip to content

fix(mcp): cap concurrent babelfish_task_start processes - #22

Merged
steipete merged 1 commit into
openclaw:mainfrom
SebTardif:fix/f004-task-start-cap
Sep 30, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
SebTardif:fix/f004-task-start-cap

Conversation

@SebTardif

@SebTardif SebTardif commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Cap babelfish_task_start at eight occupied isolated Hermes processes. Task status becomes completed or failed when the helper returns, while its slot remains reserved until the child exits; stopping or timing out a task cannot admit a replacement during delayed termination.

Completed @SebTardif's fix with the original contributor credit. Child launch failures release their slots; process errors after launch do not falsely count as exit. Updated the README, MCP guide, compatibility reference, and Unreleased changelog. No command names or trust permissions change.

Proof: the previous MCP server fails the ninth-start regression. The corrected version passed npm run check (115 tests) and npm run pack:check on Linux Crabbox with npm 11.19.1. Tests include real Python children that delay termination after stop, completion, and timeout; status remains available while their slots stay occupied. Codex autoreview found no actionable P0–P2 findings. Cross-platform, CodeQL, and constrained-memory CI passed on the merged PR head: https://github.com/openclaw/babelfish/actions/runs/36669201543.

The combined dependency, pagination, task, and hook candidates also passed all 134 tests, package validation, and a zero-advisory audit on Linux.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 30, 2026, 12:29 AM ET / 04:29 UTC (Revision 14).

ClawSweeper review

What this changes

The branch limits background tasks in Babelfish’s optional Hermes MCP server to eight occupied Python processes, keeps slots reserved until child exit, publishes results promptly, and adds tests, documentation, and stacked pagination and dependency updates.

Merge readiness

⛔ Blocked before merge - 7 items remain

This PR addresses a task-cap behavior that is still absent from current main. The child-exit accounting appears to resolve the earlier lifecycle concern, but the unconditional eight-task default needs a maintainer compatibility decision, current-head behavior proof remains incomplete, and the branch conflicts with main.

Priority: P2
Reviewed head: e0b61bce2d59fa8e8b49dd610b860f9328872492
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused process-lifecycle work and real-child tests provide useful signal, while the default compatibility decision and current-head behavior trace remain merge gates.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The current-head check report says real SDK-client/Python-child tests pass through the changed MCP owner, including delayed stop, completion, and timeout; the earlier live stop trace predates this head. A redacted current-head request/response trace showing status and slot release for completion and timeout would establish the observed after-fix behavior. Updating the PR body should trigger re-review; otherwise a maintainer can comment @clawsweeper re-review. Redact private paths, endpoints, IP addresses, keys, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The current-head check report says real SDK-client/Python-child tests pass through the changed MCP owner, including delayed stop, completion, and timeout; the earlier live stop trace predates this head. A redacted current-head request/response trace showing status and slot release for completion and timeout would establish the observed after-fix behavior. Updating the PR body should trigger re-review; otherwise a maintainer can comment @clawsweeper re-review. Redact private paths, endpoints, IP addresses, keys, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-head capacity check: The introduced handler rejects a ninth start before launching a helper and reserves a slot for each accepted task.
Child-exit lifecycle: The isolated helper reports its result separately from occupancy; occupancy waits for the spawned child to exit.
Current-main behavior: Current main starts another isolated task without a capacity check, so the central change is still unique to this PR.
Findings 1 actionable finding [P1] Preserve the task-start upgrade contract
Security None None.

How this fits together

Babelfish’s optional MCP server receives background tool and command requests from an MCP client and runs them in isolated Hermes Python processes. Clients then poll task status or stop a task, while the server tracks when each process releases capacity.

flowchart LR
 A[MCP client] --> B[Background task start]
 B --> C{Eight slots occupied?}
 C -->|No| D[Hermes Python process]
 C -->|Yes| E[Capacity error]
 D --> F[Task status]
 D -->|Process exits| C
Loading

Decision needed

Question Recommendation
Should the optional MCP server reject a ninth background task by default for existing installations, or should the eight-process limit require an explicit opt-in setting? Opt in to the limit: Keep the existing default and let operators enable an eight-process ceiling explicitly, with tests for both modes.

Why: The prior API admitted additional tasks, and source checks cannot decide the compatibility policy for existing MCP clients.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The current-head check report says real SDK-client/Python-child tests pass through the changed MCP owner, including delayed stop, completion, and timeout; the earlier live stop trace predates this head. A redacted current-head request/response trace showing status and slot release for completion and timeout would establish the observed after-fix behavior. Updating the PR body should trigger re-review; otherwise a maintainer can comment @clawsweeper re-review. Redact private paths, endpoints, IP addresses, keys, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the task-start upgrade contract (P1) - The new guard rejects a ninth task even though current main accepts it, so existing MCP clients can fail after upgrading. Obtain explicit approval for that default with upgrade proof, or preserve the existing default and make the ceiling opt-in. This carries forward the prior review’s unresolved compatibility concern.
  • Resolve merge risk (P1) - Existing MCP clients that start more than eight background tasks will receive a new error on upgrade; no maintainer has explicitly accepted that default or approved an opt-in alternative.
  • Resolve merge risk (P2) - The current-head Linux check report covers real-child tests, but it does not provide a request/response trace showing completion and timeout status while a child remains alive and a replacement starts after exit.
  • Resolve merge risk (P1) - The branch currently has a changelog merge conflict with main.
  • Complete next step (P2) - Resolve the eight-task default with a maintainer, add current-head real-behavior proof for completion and timeout, and resolve the changelog merge conflict.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve the task-start upgrade contract — src/mcp-server.ts:289-299
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Source and test delta production +134/-29 lines; tests +670/-1 lines The production growth supports process-exit accounting and stacked pagination, with substantial focused coverage.
Current-main conflict 1 changelog conflict The stacked branch needs a resolved main-branch merge before it can land.

Merge-risk options

Maintainer options:

  1. Preserve the upgrade default (recommended)
    Make the eight-process ceiling opt-in and cover both the existing default and strict mode with focused tests.
  2. Approve ninth-task rejection
    Accept the changed MCP behavior explicitly and require upgrade documentation and proof before merge.

Technical review

Best possible solution:

Keep result publication separate from process occupancy, preserve existing task-start behavior by default unless maintainers approve the new limit, and validate the chosen upgrade path with a current-head real-client trace.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main has no task-start capacity guard, and the PR’s focused checks exercise a ninth start. I did not execute the checkout.

Is this the best way to solve the issue?

Unclear. Tracking actual child occupancy addresses the resource bound, but the unconditional default is not yet an approved upgrade-safe policy.

Full review comments:

  • [P1] Preserve the task-start upgrade contract — src/mcp-server.ts:289-299
    The new guard rejects a ninth task even though current main accepts it, so existing MCP clients can fail after upgrading. Obtain explicit approval for that default with upgrade proof, or preserve the existing default and make the ceiling opt-in. This carries forward the prior review’s unresolved compatibility concern.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3a079b6ba9dd.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded reliability improvement to an optional MCP workflow, with a compatibility decision still open.
  • merge-risk: 🚨 compatibility: An unconditional eight-process ceiling changes the existing task-start response for clients that exceed it.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The current-head check report says real SDK-client/Python-child tests pass through the changed MCP owner, including delayed stop, completion, and timeout; the earlier live stop trace predates this head. A redacted current-head request/response trace showing status and slot release for completion and timeout would establish the observed after-fix behavior. Updating the PR body should trigger re-review; otherwise a maintainer can comment @clawsweeper re-review. Redact private paths, endpoints, IP addresses, keys, and other private details. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-head capacity check: The introduced handler rejects a ninth start before launching a helper and reserves a slot for each accepted task. (src/mcp-server.ts:289, e0b61bce2d59)
  • Child-exit lifecycle: The isolated helper reports its result separately from occupancy; occupancy waits for the spawned child to exit. (src/hermes-python.ts:321, e0b61bce2d59)
  • Current-main behavior: Current main starts another isolated task without a capacity check, so the central change is still unique to this PR. (src/mcp-server.ts:282, 3a079b6ba9dd)
  • Production-path test coverage: The added tests use an SDK client and actual Python child processes for delayed stop, completion, and timeout, asserting rejection while occupied and admission after exit. (src/mcp-server.test.ts:475, e0b61bce2d59)
  • Proof and policy discussion: The contributor reported a live Python stop-and-exit trace for an earlier head and explicitly left the eight-task default for a maintainer decision. A later comment reported a mocked completion regression; the current PR body reports a Linux check run with real-child tests but provides no current-head request/response trace for completion and timeout.
  • Main-branch merge conflict: A read-only three-way comparison against current main reports a conflict in the Unreleased changelog entry; the remaining inspected paths merge. (CHANGELOG.md:5, 3a079b6ba9dd)

Likely related people:

  • Dallin Romney: Raw commit 633ff0f adds src/mcp-server.ts:44 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 633ff0fcd81d; files: src/mcp-server.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted current-head real-client trace for completed and timed-out tasks while their children still occupy slots, followed by admission after exit.
  • Resolve the eight-task default policy and verify the approved fresh-install and upgrade behavior.
  • Resolve the changelog conflict against current main.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-02T18:08:52.581Z sha 70f8a8f :: needs real behavior proof before merge. :: [P1] Keep stopped processes counted until exit
  • reviewed 2026-09-02T21:55:24.176Z sha 70f8a8f :: needs real behavior proof before merge. :: [P1] Keep stopping processes counted until they exit
  • reviewed 2026-09-03T15:03:58.569Z sha 70f8a8f :: needs real behavior proof before merge. :: [P1] Keep stopped processes counted until exit
  • reviewed 2026-09-03T23:52:44.227Z sha 70f8a8f :: needs real behavior proof before merge. :: [P1] Keep stopping processes counted until they exit
  • reviewed 2026-09-11T10:48:23.268Z sha 70f8a8f :: needs real behavior proof before merge. :: [P1] Keep process capacity reserved until the child exits
  • reviewed 2026-09-18T16:06:35.742Z sha 82faab8 :: blocked before merge. :: [P2] Publish task outcomes without waiting for child exit
  • reviewed 2026-09-20T22:57:17.716Z sha 112723a :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-29T05:28:05.224Z sha 112723a :: needs real behavior proof before merge. :: [P1] Preserve the task-start upgrade contract

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. and removed P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Sep 11, 2026
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Keep process capacity reserved until the child exits

Slots now stay reserved until the isolated child exits. Live python3 children: eight started, stop left the dying pid alive, the ninth start was rejected (Too many running Babelfish tasks (max 8)), and a replacement started only after that pid exited.

Should the existing background-task API unconditionally reject the ninth task, or should the new limit preserve compatibility through an opt-in policy?

The eight-task ceiling is unchanged. That default is still a maintainer product call. Please either accept it or say you want it opt-in.

@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 18, 2026
SebTardif added a commit to SebTardif/babelfish that referenced this pull request Sep 20, 2026
Isolated helper occupancy still waits for process exit. Task status
completes or fails when the helper returns, so task_stop cannot discard
a result that already landed.

Claw P2 on openclaw#22.

Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Publish task outcomes without waiting for child exit

runHelper(..., waitForExit) now returns the helper result immediately and reports occupancy separately. babelfish_task_status can show completed while the slot stays reserved until the child exits. task_stop only rewrites running tasks, so a published result is not discarded.

Windows 11 cannot catch SIGTERM (Node maps it to terminate), so the live Python hold fixture stays Unix-only. This host ran the new mock regression in src/mcp-server.test.ts (publishes a completed status while occupancy still holds the slot): completed with { held: true }, ninth start still rejected, then a start succeeds after occupancy releases. npx vitest run src/mcp-server.test.ts: 5 passed, 3 skipped (the SIGTERM hold cases).

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: sufficient Contributor real behavior proof is sufficient. labels Sep 20, 2026
@steipete
steipete force-pushed the fix/f004-task-start-cap branch from 112723a to e0b61bc Compare September 30, 2026 04:25
Limit background Hermes calls to eight occupied process slots while publishing completed results immediately.

Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
@steipete
steipete force-pushed the fix/f004-task-start-cap branch from e0b61bc to 3c9b646 Compare September 30, 2026 04:31
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(mcp): cap concurrent babelfish_task_start processes This is item 1/1 in the current shard. Shard 0/1.

This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 749d6fd into openclaw:main Sep 30, 2026
8 of 9 checks passed
@SebTardif
SebTardif deleted the fix/f004-task-start-cap branch September 30, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants