Skip to content

fix: honor subagent concurrency for dreaming completions - #170273

Merged
steipete merged 1 commit into
mainfrom
fix/dreaming-subagent-concurrency
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/dreaming-subagent-concurrency

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #95746. Thanks @rogerallen1 for reporting the local-model concurrency problem.

What Problem This Solves

Dream Diary and other plugin background completions could start three model requests even when agents.defaults.subagents.maxConcurrent was set to one.

User Impact

Background completions now honor the existing subagent cap across plugins and workspaces. Set it to 1 to serialize requests to a small local model. The existing default of eight now applies instead of the old independent three-slot limit. No new setting or migration is required.

Why This Change Was Made

The Gateway completion owner now queues through the existing subagent lane at background priority. Restart, caller, and runtime cancellation remain connected, authorization is still rechecked after waits, and capacity remains held through inference cleanup. Skill Workshop retains its own background review budget.

Evidence

Native Ollama qwen3:4b with num_ctx=8192, four identical synthetic workspaces, and both configured concurrency caps set to one: the real CLI → Gateway → managed dreaming job → plugin completion → Ollama /api/chat flow produced four completed model replies and four diaries before and after. Recorded peak in-flight HTTP requests fell from 3 to 1. This proves cap enforcement; actual context exhaustion was not reproduced.

The owner regression fails on main with subagent queuedCount=0 instead of 2 behind an occupied cap-one slot. It passes after the repair (3.822s in the final standalone run), including requests from different plugins, without starting a provider or using test timers.

Focused checks: completion runtime 25/25 (153.64s wrapper wall), HTTP transport 2/2 (276.88s), Gateway lanes 7/7 in the combined run. A prior combined run (534.41s) hit the unchanged transport fixture's completion deadline during cold preparation; the isolated replay passed with the original timeout. Cold worker preparation accounts for most wrapper time.

Targeted lint, format, core and Gateway test types, and all seven required ratchets pass. The qaRuntime build and the source CLI's managed build pass. The final edits after live proof only rename a local variable and retain the same literal lane comparison in a test.

Production +12/-14 (net -2); tests +86/-18; docs +8/-5. Model-facing prompt token delta: 0.

Independent Codex autoreview: scoped-clean through P2, with no accepted/actionable findings.

Exact-head CI: run 38312617421 succeeded for 5193060ec42bce2bbe1b2b122477c7db9073ab00, including openclaw/ci-gate: 39 successful jobs, 25 skipped, no current failures. CI execution window: 622s; baseline ratchets: 289s. The pinned watcher classifies 81 older cancelled checks as superseded.

ClawSweeper reviewed this head with no actionable findings and no “Before merge” items. Live-proof limitation: the synthetic Ollama wire traces are retained locally and are not linked in this PR.

Route plugin background completions through the configured subagent lane while retaining cancellation and cleanup ownership. Document the shared cap and cover admission across plugins.

Refs #95746. Thanks @rogerallen1 for the report.
@steipete steipete added the ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. label Oct 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime plugin: file-transfer size: S labels Oct 12, 2026
@steipete
steipete marked this pull request as ready for review October 12, 2026 21:45
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Plugin background completions now honor the existing subagent concurrency limit across plugins and workspaces.

Example: Four dreaming workspaces use a local model with agents.defaults.subagents.maxConcurrent set to 1.

  • Before: The independent background budget can admit three model requests simultaneously.
  • After: Plugin completions share one slot and wait until the preceding inference finishes cleanup.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused owner repair and exact-head CI support correctness; independently inspectable live evidence is limited, and the linked issue's later timeout request is outside scope.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored classification exempts ordinary contributor proof gating: the body reports four completed Ollama replies and diaries with peak concurrency falling from three to one, but its traces are unlinked and the inspected media demonstrates the earlier refactor.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Dreaming can send several simultaneous requests to a constrained local model despite the operator selecting one concurrent subagent.
Reason: The existing setting becomes effective without another knob; the feature owner's authored change resolves the scheduling direction, while the later timeout request remains separate.

Merge readiness

✅ Ready for maintainer review

Keep open. This PR fixes a current concurrency defect in the shared completion owner, and no actionable correctness or security finding remains.

Priority: P2
Reviewed head: 5193060ec42bce2bbe1b2b122477c7db9073ab00

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported CLI-to-Gateway-to-Ollama cap-one run has no linked trace available for independent inspection.
Agent review details

How this fits together

Dreaming and other plugins submit tool-free completion requests to the Gateway, which authorizes them, queues inference, and returns text through the existing isolated runtime.

flowchart TD
  A[Dreaming and other plugins] --> B[Gateway completion owner]
  B --> C[Authorization and lifetime checks]
  C --> D[Subagent queue]
  D --> E[Isolated inference runtime]
  E --> F[Model provider]
  F --> G[Completion text]
Loading

Technical review

Best possible solution:

Use the existing subagent queue as the single plugin-completion capacity owner while preserving cleanup, cancellation, and authorization.

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

Current main's independent three-slot completion budget directly explains why a configured subagent limit of one is ignored; this review did not execute a reproduction.

Is this the best way to solve the issue?

The patch fixes admission at the shared Gateway owner, removes the competing completion budget, and retains the existing authorization and inference-cleanup contracts.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Plugin completion capacity and diagnostics changes intended behavior with a stated reason (2409cd6: Share three background slots across dreaming and Workshop, remove private session plumbing, and expose their combined load.)
  • Completion authority and cancellation checks keeps the original intent (6b4ebc0: Preserve the accepted operator's original and current model ceiling through queued and isolated execution.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source -2, Tests +68, Docs +3. Total +69 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 12 14 -2
Tests 1 86 18 +68
Docs 3 8 5 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 106 37 +69

Review metrics

Metric Value Why it matters
Production versus test LOC Production +12/-14; tests +86/-18 Production shrinks by reusing the existing queue; test growth covers cross-plugin admission and adapts existing lifecycle coverage.
Completion concurrency default 3 → 8 when unset The PR explicitly adopts the existing subagent default; stored settings remain intact and no new option is added.

Root-cause cluster

Relationship: partial_overlap
Canonical: #95746
Summary: This PR addresses the reported concurrency bypass; the issue also contains a later consolidation-timeout request.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs background inference concurrency for constrained local models without changing foreground conversation admission.
  • merge-risk: 🚨 compatibility: Changes the documented plugin completion scheduling contract and unset limit from three to eight; the feature owner explicitly accepts this change in the PR.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Optionally link the existing redacted Ollama trace showing cap-one admission and completed diaries; no new run is needed.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-12T21:52:41.954Z sha 5193060 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-12T21:58:17.776Z sha 5193060 :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 6:22 PM ET / 22:22 UTC (Revision 3).

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@steipete
steipete merged commit 0975d24 into main Oct 12, 2026
205 of 211 checks passed
@steipete
steipete deleted the fix/dreaming-subagent-concurrency branch October 12, 2026 22:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…0273)

Route plugin background completions through the configured subagent lane while retaining cancellation and cleanup ownership. Document the shared cap and cover admission across plugins.

Refs openclaw#95746. Thanks @rogerallen1 for the report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant