Skip to content

RemoteGraph: cannot use context with stateful runs (missing fix from Python PR #6497) #1922

@benAttarYuval

Description

@benAttarYuval

Problem

Python LangGraph fixed RemoteGraph in PR #6497 to allow using context with stateful runs. The JS version lacks this fix.

From the Python PR:

Otherwise, you cannot use context with stateful runs, because the server throws if you provide both configurable and context in a single call (due to ambiguous parameters)

Current JS Behavior (v1.1.2)

RemoteGraph only passes config to client.runs.stream(), not context:

// pregel/remote.js _streamIterator method
for await (const chunk of this.client.runs.stream(
  sanitizedConfig.configurable.thread_id, 
  this.graphId, 
  {
    config: sanitizedConfig,  // Only config, no context parameter
    ...
  }
))

The SDK client already supports context, but RemoteGraph doesn't expose/use it.

Expected Behavior

Port the Python fix:

  1. Pop thread_id from configurable
  2. Pass context parameter to client.runs.stream()
  3. Allow using context with stateful (checkpointed) runs

Use Case

When using RemoteGraph to call sub-agents, we need to propagate user context (userId, tenantId, featureFlags) via context to sub-agent middleware that uses contextSchema. Currently this fails with 400 error when combined with thread_id for checkpointing.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions