langchain-ai / langchain-ai/deepagentsjs

task tool doesn't work in browser builds — config not forwarded to getCurrentTaskInput()

Open Beginner friendly
#833 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.6k
Forks
272
Avg merge
1d 13h
Merged PRs (30d)
38

Description

Summary

In a browser build, every task call fails, so no subagent can run at all. The cause is one argument not being passed along, and the fix is one line.

Versions: deepagents@1.13.2, langchain@1.5.10, @langchain/core@1.2.9, @langchain/langgraph@1.4.13.

Reproduction

Live demo, no API key needed: https://stackblitz.com/edit/c5ksaquc

It runs three cases on load and prints the results. This issue is case C, which builds an agent with one subagent and calls task. (Cases A and B are a separate StateBackend problem, filed as #834.) The models are fake — they return a fixed tool call — so there is no API key and the result is the same every time.

Case C fails with:

Error: Config not retrievable. This is likely because you are running in an
environment without support for AsyncLocalStorage.

Why

createTaskTool() receives the LangGraph tool config and uses it on one line, but not on the next:

return tool(async (input, config) => {
  ...
  const subagent = selectSubagent(subagent_type, config);  // config passed here
  const currentState = getCurrentTaskInput();              // but not here

getCurrentTaskInput() with no argument falls back to AsyncLocalStorage, and a browser doesn't have one. Bundlers resolve @langchain/langgraph to its browser build, which — unlike the Node one — never calls initializeAsyncLocalStorageSingleton(). @langchain/core then falls back to MockAsyncLocalStorage and the lookup returns undefined.

The demo prints this before running any of the cases:

AsyncLocalStorage in use: MockAsyncLocalStorage
  getStore() -> undefined
  getRunnableConfig() -> undefined

That line runs on every task call, before any other work, so there is nothing a caller can do about it from the outside. Case C uses backend: (runtime) => new StateBackend(runtime), which works fine on its own, and it still fails here.

Suggested fix

Pass the config that's already in scope:

const currentState = getCurrentTaskInput(config);

Happy to open a PR for this if it helps.

Related

  • #834: the same root cause affects StateBackend — the only mode that works in a browser is the one marked as deprecated.
  • #553 is the same missing-config mistake in @langchain/quickjs (prepareSkillsForEval()), still open.
  • Other open browser reports that may share this root cause: #612, #616, #617.

Disclosure: this report was researched and written with the help of an AI assistant (Claude). The demo runs as described, and every code reference above was checked against the published deepagents@1.13.2 build.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at createTaskTool() and follow its getCurrentTaskInput() call, using the StackBlitz reproduction's case C to observe the browser failure. The task call should complete in a browser build, with the existing config used for current-task lookup; verify the fix against the provided demo.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design, web-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.