Skip to content

feat(prebuilt): add preModelHook and postModelHook #1212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dqbd
Copy link
Collaborator

@dqbd dqbd commented May 23, 2025

Closes #1222

Base automatically changed from dqbd/remove-message-all to main May 23, 2025 21:30
@dqbd dqbd requested a review from sydney-runkle May 27, 2025 16:06
Comment on lines +694 to +704
if (isAIMessage(lastMessage) && lastMessage.tool_calls?.length) {
return "tools" as const;
}

if (isToolMessage(lastMessage)) {
return "entrypoint" as const;
}

if (responseFormat != null) {
return "generate_structured_response" as const;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic needs to be more complex than this - I think we need to account for pending tool calls. Like what if you have an AIMessage followed by a ToolMessage, but the AIMessage had 2 tool calls, so one is still pending...

https://github.com/langchain-ai/langgraph/blob/19ca6b416bd317346f4d0f5b472dea3fd39af0f0/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py#L718-L740

Copy link

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some tests to confirm the structure of the graph when all combinations of pre, post, tools, and response_format are included in the graph?

Generally, looking good, thanks for tackling these features!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: add pre_model_hook and post_model_hook to createReactAgent function
2 participants