Skip to content

Commit 88bad37

Browse files
authored
fix get_tool_return (#11346)
1 parent 49b34e2 commit 88bad37

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libs/langchain/langchain/agents/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,11 +1229,14 @@ def _get_tool_return(
12291229
"""Check if the tool is a returning tool."""
12301230
agent_action, observation = next_step_output
12311231
name_to_tool_map = {tool.name: tool for tool in self.tools}
1232+
return_value_key = "output"
1233+
if len(self.agent.return_values) > 0:
1234+
return_value_key = self.agent.return_values[0]
12321235
# Invalid tools won't be in the map, so we return False.
12331236
if agent_action.tool in name_to_tool_map:
12341237
if name_to_tool_map[agent_action.tool].return_direct:
12351238
return AgentFinish(
1236-
{self.agent.return_values[0]: observation},
1239+
{return_value_key: observation},
12371240
"",
12381241
)
12391242
return None

0 commit comments

Comments
 (0)