Best Practice when collecting specific information from a user #2194
Replies: 1 comment
Keep After validating the incoming fields, the collection tool can do this: collected = dict(tool_context.state.get("inputs", {}))
collected.update(validated_fields)
tool_context.state["inputs"] = collected
required = ("arg_1", "arg_2", "arg_3")
missing = [key for key in required if collected.get(key) is None]
return {"collected": collected, "missing": missing}The In the agent instructions, ask for the returned missing fields and clarify ambiguous answers. Keep the validation and completeness checks in Python, and reuse the same session ID across turns so previously collected inputs remain available. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey everyone,
I wanted to get your views for a specific use-case I'm considering and would be useful to understand from other people how they'd approach this problem.
Let's say, I have a tool that performs some sort of calculations:
Now the input of this tool, should be coming from user, who is expected to provide this info, in a Q/A fashion. i.e. the agent should ask questions to the user, in order to collect this info (
arg_1,arg_2,arg_3, ...). As the user will start providing this info, the agent should somehow retain the fact that some of the information is provided already, and should stop asking further questions if all info is provided by the user.What is the best way for achieving this? Would it make sense to construct an object, that is gradually filled in, within the session's state? Any alternatives other than just relying fully on the prompt?
All reactions