Skip to content

Commit

Permalink
fix get_tool_return (#11346)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchase17 committed Oct 3, 2023
1 parent 49b34e2 commit 88bad37
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/langchain/langchain/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,11 +1229,14 @@ def _get_tool_return(
"""Check if the tool is a returning tool."""
agent_action, observation = next_step_output
name_to_tool_map = {tool.name: tool for tool in self.tools}
return_value_key = "output"
if len(self.agent.return_values) > 0:
return_value_key = self.agent.return_values[0]
# Invalid tools won't be in the map, so we return False.
if agent_action.tool in name_to_tool_map:
if name_to_tool_map[agent_action.tool].return_direct:
return AgentFinish(
{self.agent.return_values[0]: observation},
{return_value_key: observation},
"",
)
return None
Expand Down

0 comments on commit 88bad37

Please sign in to comment.