Skip to content

LangGraph does not preserve additional object fields during Flow state propagation #239

Description

@JainSajal23

Summary

The LangGraph runtime does not preserve dynamically added fields when an object-valued state is passed through multiple sequential ToolNodes.

The same Agent Spec flow behaves correctly in Wayflow but loses additional state fields in LangGraph.

Declared schema

{
  "type": "object",
  "properties": {
    "counter": {
      "type": "integer"
    },
    "trace": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": ["counter", "trace"],
  "additionalProperties": true
}

Input

{
    "state": {
        "counter": 0,
        "trace": []
    }
}

State transformations

Step 1

counter = counter + 1
trace += ["step1"]
state["step1"] = "initialized"

Step 2

counter = counter + 10
trace += ["step2"]
state["step2"] = "enriched"

Step 3

counter = counter + 100
trace += ["step3"]
state["step3"] = "finalized"

Expected output

Because the schema specifies "additionalProperties": true, all dynamically added fields should be preserved:

{
    "state": {
        "counter": 111,
        "trace": ["step1", "step2", "step3"],
        "step1": "initialized",
        "step2": "enriched",
        "step3": "finalized"
    }
}

Actual LangGraph output

{
    "state": {
        "counter": 111,
        "trace": ["step1", "step2", "step3"],
        "step3": "finalized"
    }
}

The fields step1 and step2 are lost during state propagation or output conversion.

The declared fields counter and trace are propagated correctly.

Runtime comparison

Runtime Result
Wayflow Passes and preserves all state fields
LangGraph Fails and drops step1 and step2

Wayflow returns:

{
    "state": {
        "counter": 111,
        "trace": ["step1", "step2", "step3"],
        "step1": "initialized",
        "step2": "enriched",
        "step3": "finalized"
    }
}

LangGraph returns:

{
    "state": {
        "counter": 111,
        "trace": ["step1", "step2", "step3"],
        "step3": "finalized"
    }
}

Impact

Flows using extensible object-valued state can lose fields when executed with the LangGraph runtime.

This produces inconsistent behavior between LangGraph and Wayflow for the same Agent Spec and may cause downstream nodes or consumers to receive incomplete state.

Expected behavior

LangGraph should preserve additional object properties when the declared schema allows them through:

"additionalProperties": true

The state should remain cumulative and should not lose fields added by intermediate nodes.

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