Skip to content

Commit 5c1fa83

Browse files
fix: get correct message count per turn for conversational agents [JAR-9610] (#746)
Co-authored-by: Maxwell Du <60411452+maxduu@users.noreply.github.com>
1 parent b31019e commit 5c1fa83

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.9.15"
3+
version = "0.9.16"
44
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath_langchain/agent/react/llm_node.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def create_llm_node(
8484

8585
async def llm_node(state: StateT):
8686
messages: list[AnyMessage] = state.messages
87-
agent_ai_messages = sum(1 for msg in messages if isinstance(msg, AIMessage))
87+
initial_count = state.inner_state.initial_message_count or 0
88+
current_turn_messages = messages[initial_count:]
89+
agent_ai_messages = sum(
90+
1 for msg in current_turn_messages if isinstance(msg, AIMessage)
91+
)
8892
if agent_ai_messages >= llm_messages_limit:
8993
raise AgentRuntimeError(
9094
code=AgentRuntimeErrorCode.TERMINATION_MAX_ITERATIONS,

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)