Skip to content

fix(deepagents): exclude __pregel_ internal keys from subagent state to prevent Send serialization error#1395

Open
Bob (zzzrbx) wants to merge 1 commit intolangchain-ai:mainfrom
zzzrbx:fix/pregel-send-serialization-in-subagent-state
Open

fix(deepagents): exclude __pregel_ internal keys from subagent state to prevent Send serialization error#1395
Bob (zzzrbx) wants to merge 1 commit intolangchain-ai:mainfrom
zzzrbx:fix/pregel-send-serialization-in-subagent-state

Conversation

@zzzrbx
Copy link

Summary

  • LangGraph injects internal runtime objects (e.g. __pregel_send, a Send instance) into the graph state during execution
  • These keys were being passed through to subagent state in _validate_and_prepare_state
  • When LangGraph tried to checkpoint the subagent state, msgpack failed to serialize the Send object, crashing with: TypeError: Type is not msgpack serializable: Send
  • Fix: filter out any key starting with __pregel_ alongside the existing _EXCLUDED_STATE_KEYS check

Changes

  • deepagents/middleware/subagents.py: added _PREGEL_PREFIX = "__pregel_" constant and updated _validate_and_prepare_state to exclude matching keys
  • tests/unit_tests/test_subagents.py: added TestPregelStateFiltering with a test that verifies __pregel_* keys do not appear in subagent state

Test plan

  • All existing unit tests pass (make test)
  • New test TestPregelStateFiltering::test_pregel_keys_excluded_from_subagent_state passes
  • Reproduce: invoke a subagent that runs a tool call with a MemorySaver checkpointer — crash no longer occurs

@github-actions github-actions bot added deepagents Related to the `deepagents` SDK / agent harness external User is not a member of the `langchain-ai` GitHub organization labels Feb 18, 2026
@zzzrbx Bob (zzzrbx) changed the title fix: exclude __pregel_* keys from subagent state to prevent Send serialization error fix(deepagents): exclude __pregel_ internal keys from subagent state to prevent Send serialization error Feb 18, 2026
@github-actions github-actions bot added the fix A bug fix (PATCH) label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness external User is not a member of the `langchain-ai` GitHub organization fix A bug fix (PATCH)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant