Agentic AI Module 4 Ungraded Lab - how does function call task

In the ungraded lab for Module 4 of the Agentic AI course, I don’t understand how the find_references() function calls the {task} when it is being executed.

The function is roughly:

def find_references(task, model, return_messages):
  """Perform task etc."""

  prompt="""
  You are a research tool etc. do this

  Task: {task} """

more code...

My understanding at this point is that the {task} has to still be defined. Fine.

Then to test this function, you run code that defines the {task}:

research_task = "Find 2 recent papers about developments in black hole science"
research_result = find_references(research_task)

utils.print_html(etc.)

So, how is the function find_references() which should be looking for something named {task} able to find research_task?

Does it not matter that task and research_task are not the same?

Hello,

This is propable is a pure python programming knowledge. task here is a variable name and it is a string. You pass a string variable named research_taskto the function. In the function, it receives the string and its value store in the task local variable (pass by value, taskand research_task are 2 separated variables)

Maybe this link can help you understand how python function work: Python Functions - GeeksforGeeks

You can also prompt to ask some chatbot how is python function work.

Hope this help!