langchain
langchain copied to clipboard
Tools and return_intermediate_steps
So as far as I can't tell, there is no way to return intermediate steps from tools to be combined at the agent level, making them a black box (discounting tracing). For example, an agent using the SQLDatabaseChain can't capture the SQL query used by the SQLChain.
The tool interface is just str -> str, which keeps it simple, but perhaps it would be a good idea to add a 'return_intermediate_steps' param and have the return be Union[str, Dict[str, Any]), or something similar in the same spirit to how agents and chains operate.
I'm happy to work on this, but given it would be a substantial change in the code, I'd like to get some discussion on the feature before taking a stab at it (and also to ensure I haven't missed a way to already achieve this :D)
+1, I hope to have this feature soon
I see that the agent executor not accepts return_intermediate_step = True but I'm still unclear how to use this.
When setting this you cannot use agent.run(...) anymore as it causes: ValueError: run not supported when there is not exactly one output key. Got ['output', 'intermediate_steps'].
Nor can I directly run agent(input=...) when using a memory, cause this will call .memory.save_context(inputs, outputs) when done causing ValueError: One output key expected, got dict_keys(['output', 'intermediate_steps']).
+1 for someone who can give an example on how to use this :D
Ok I've realized my confusion as this issue is talking about intermediate steps for Tools.
I've moved my comments on return_intermediate_step usage in agents to: #3091