Simplifying the AI Agent Loop with Function Calling Flashcards

(20 cards)

1
Q

What problem does function calling solve in AI agents?

A

It eliminates the need to parse unstructured text responses by having the model return structured function calls instead.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why was manual parsing difficult before function calling?

A

LLM responses varied in format and required engineering strict templates and error-handling logic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does function calling guarantee about tool execution?

A

The model returns a structured JSON function call with a function name and arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the agent do when it receives a function call?

A

It matches the tool_name to a Python function and executes it with the provided arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens if no function call is included in the LLM’s response?

A

The agent treats the output as plain text and prints it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In the simplified loop, how are tools passed into the LLM?

A

As a list of JSON Schema tool definitions in the tools= parameter of the completion call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is stored in the agent’s memory after executing a tool?

A

The action taken (assistant role) and the result of that action (user role).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What triggers the agent loop to end?

A

The LLM calling the terminate tool.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the list_files tool do?

A

Returns a list of files in the current directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the read_file tool do?

A

Reads the content of a file and returns it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why do we define tools using JSON Schema?

A

So the LLM knows valid parameters and can format tool calls correctly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What dictionary maps tool names to their Python functions?

A

The tool_functions dictionary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does the simplified loop detect a tool call?

A

By checking response.choices[0].message.tool_calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why is function calling more reliable than prompt-engineered parsing?

A

Because function calls are generated in structured, machine-readable format.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What type of error should you catch when parsing function call arguments?

A

json.JSONDecodeError.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why does error-handling still matter with function calling?

A

The LLM can sometimes produce malformed JSON or invalid arguments.

17
Q

What does the agent do with each iteration’s result?

A

Appends it to memory so the LLM can use updated context in the next step.

18
Q

How many iterations can the loop run before stopping?

A

Up to the maximum defined by max_iterations.

19
Q

How does function calling unify conversation + actions?

A

It allows the LLM to mix function calls with normal text responses seamlessly.

20
Q

What is the agent’s first input based on the example loop?

A

The user’s task, collected through input().