Skip to content

Adding conditional edge from the entry point node does not seem to pass the Overall state to the validation function #3532

Open
@sand-heap

Description

Discussed in #3387

Originally posted by sand-heap February 11, 2025
Pretty much what the title says. I can explain further with code

...

@dataclass
class InputState:
  some_field: int

class OverAllState(messages):
  some_field: int

def validate_transition(state: OverallState)->List:
  if state.get("some_field") == 1:
    return END
  else:
    return "other_node"

def some_node(input: InputState)->OverAllState:
  return {"some_field": input.some_field+1}

workflow = StateGraph(OverAllState, input=InputState)
workflow.set_entry_point("node")
workflow.add("node", some_node)
workflow.add("other_node", other_node)
workflow.add_conditional_edges("node", validate_transition,...)
...
# add end
...

I would expect the validate_transition to receive the OverallState but for some reason it gets the InputState ?!

However if i add a mock_node between node and other_node and make the edge from mock_node conditional instead and have a sequential flow from node -> mock_node, the behavour is as expected.

can you please help? ++ @vbarda @hinthornw

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions