Check Required Parameters Are Present
Problem Statement
Before dispatching a tool call, verify every required parameter is present. Report the missing ones so the agent can ask for them.
Background
A tool schema lists a set of required parameter names. Validation returns the sorted list of required names absent from the provided arguments. An empty list means the call is ready to execute.
Your Task
Implement:
def missing_params(args, required):
- args: dict of provided arguments.
- required: list of required parameter names.
- Return the sorted list of required names not in args.
Input Format
- args (dict), required (list of strings).
Output Format
- A sorted list of strings.
Sample
print(missing_params({"city": "NYC"}, ["city", "date"]))
Output:
['date']
Example
print(missing_params({"city": "NYC"}, ["city", "date"]))['date']
- Identify the provided arguments and the required parameters: the input dictionary contains the key
"city", and the required list is["city", "date"]. - Check each required parameter against the provided arguments to determine presence:
"city"is found in the arguments, while"date"is absent. - Collect the missing parameters into a list, resulting in
["date"]. - Sort the list of missing parameters alphabetically to ensure a consistent output order; since there is only one element, the list remains
["date"]. - The final output is
['date']
Constraints
- Compare only names (values may be anything, including None).
- A required name present with any value counts as provided.
- Return the missing names sorted ascending.