[PR #6635] fix(prebuilt): remove self-loop edge in graph visualization when using post_model_hook #5180

Closed
opened 2026-02-20 17:51:20 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/6635

State: closed
Merged: No


Fix for #6516

Description

Fix graph visualization showing a confusing self-loop arrow from post_model_hook back to agent (or pre_model_hook) when using response_format with post_model_hook.

The issue was caused by:

  1. Including entrypoint in post_model_hook_paths initialization
  2. An unreachable condition in post_model_hook_router that returned entrypoint when the last message was a ToolMessage

This condition never triggers because after tools execute, they route to the agent which produces an AIMessage before reaching post_model_hook_router.

Issue

Fixes #6516

Dependencies

None

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/6635 **State:** closed **Merged:** No --- Fix for #6516 ## Description Fix graph visualization showing a confusing self-loop arrow from `post_model_hook` back to `agent` (or `pre_model_hook`) when using `response_format` with `post_model_hook`. The issue was caused by: 1. Including `entrypoint` in `post_model_hook_paths` initialization 2. An unreachable condition in `post_model_hook_router` that returned `entrypoint` when the last message was a `ToolMessage` This condition never triggers because after tools execute, they route to the agent which produces an `AIMessage` before reaching `post_model_hook_router`. ## Issue Fixes #6516 ## Dependencies None
yindo added the pull-request label 2026-02-20 17:51:20 -05:00
yindo closed this issue 2026-02-20 17:51:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#5180