Skip to content

fix(langgraph): run all tasks when maxConcurrency is 1 - #2665

Open
Pushkar Verma (pushkarverma3698) wants to merge 1 commit into
langchain-ai:mainfrom
pushkarverma3698:fix/max-concurrency-one-drops-tasks
Open

fix(langgraph): run all tasks when maxConcurrency is 1#2665
Pushkar Verma (pushkarverma3698) wants to merge 1 commit into
langchain-ai:mainfrom
pushkarverma3698:fix/max-concurrency-one-drops-tasks

Conversation

@pushkarverma3698

Copy link
Copy Markdown

Fixes #2656

Invoking a graph that fans out with Send under maxConcurrency: 1 silently skips every task after the first. No error is raised and the output is structurally valid, so the lost work leaves no signal downstream.

Root cause

The scheduling loop in PregelRunner._executeTasksWithRetry continues while:

(startedTasksCount === 0 || Object.keys(executingTasksMap).length > 0) && tasks.length

With a limit of 1, executingTasksMap holds a single task. When it settles and is deleted at the bottom of the loop, the map is empty and startedTasksCount is non-zero, so the loop exits with the remaining tasks never scheduled. Any limit >= 2 keeps at least one task in flight across a settle, which is why only 1 is affected.

The condition conflates "nothing in flight" with "nothing left to start".

Fix

Continue while unstarted tasks remain or tasks are in flight. The inner top-up loop already caps in-flight work at maxConcurrency, so the limit itself is unchanged. Tasks injected mid-tick (error handlers, PUSH tasks via call) still keep the loop alive through the barrier exactly as before.

Reproduction from the issue:

maxConcurrency before after
1 ran=0 ran=6
2 ran=6 ran=6
4 ran=6 ran=6
unset ran=6 ran=6

Test

Regression test added beside the existing test_max_concurrency port: a 6-way Send fan-out at maxConcurrency: 1 must complete all six tasks and observe a peak concurrency of exactly 1 — so a future change can't "fix" this by quietly widening the limit. Fails on main (0 of 6 tasks run), passes with this change.

libs/langgraph-core: 79 files, 1639 tests passed, 0 type errors. oxlint and oxfmt --check clean.

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cd0d9e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@langchain/langgraph Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@langchain/langgraph-checkpoint

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint@2665

@langchain/langgraph-checkpoint-mongodb

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-mongodb@2665

@langchain/langgraph-checkpoint-postgres

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-postgres@2665

@langchain/langgraph-checkpoint-redis

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-redis@2665

@langchain/langgraph-checkpoint-sqlite

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-sqlite@2665

@langchain/langgraph-checkpoint-validation

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-checkpoint-validation@2665

create-langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/create-langgraph@2665

@langchain/langgraph-api

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-api@2665

@langchain/langgraph-cli

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cli@2665

@langchain/langgraph

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph@2665

@langchain/langgraph-cua

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-cua@2665

@langchain/langgraph-supervisor

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-supervisor@2665

@langchain/langgraph-swarm

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-swarm@2665

@langchain/langgraph-ui

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-ui@2665

@langchain/langgraph-sdk

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/langgraph-sdk@2665

@langchain/angular

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/angular@2665

@langchain/react

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/react@2665

@langchain/svelte

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/svelte@2665

@langchain/vue

npm i https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/vue@2665

commit: cd0d9e2

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.

Send fan-out tasks are silently dropped when maxConcurrency: 1

1 participant