0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
So we've got some function calling working, but it's not fair to call our program an "agent" yet for one simple reason:
It has no feedback loop.
A key part of an "Agent", as defined by AI-influencer-hype-bros, is that it can continuously use its tools to iterate on its own results. So we're going to build two things:
This is a pretty big step, take your time!
generate_content
, handle the results of any possible tool use:
(aiagent) wagslane@MacBook-Pro-2 aiagent % uv run main.py "how does the calculator render results to the console?"
- Calling function: get_files_info
- Calling function: get_file_content
Final response:
Alright, I've examined the code in `main.py`. Here's how the calculator renders results to the console:
- **`print(to_print)`:** The core of the output is done using the `print()` function.
- **`format_json_output(expression, result)`:** Before printing, the `format_json_output` function (imported from `pkg.render`) is used to format the result and the original expression into a JSON-like string. This formatted string is then stored in the `to_print` variable.
- **Error handling:** The code includes error handling with `try...except` blocks. If there's an error during the calculation (e.g., invalid expression), an error message is printed to the console using `print(f"Error: {e}")`.
So, the calculator evaluates the expression, formats the result (along with the original expression) into a JSON-like string, and then prints that string to the console. It also prints error messages to the console if any errors occur.
You may or may not need to make adjustments to your system prompt to get the LLM to behave the way you want. You're a prompt engineer now, so act like one!
Run and submit the CLI tests.
The Boot.dev CLI requires you to be signed in to submit your solution!
Copy/paste one of the following commands into your terminal:
Run
bootdev run ad0f349e-4426-4658-b3f5-7e7bbce2ae48
Submit
bootdev run ad0f349e-4426-4658-b3f5-7e7bbce2ae48 -s
To run and submit the tests for this lesson, you must have an active Boot.dev membership
Become a member to view solution
Using the Bootdev CLI
The Bootdev CLI is the only way to submit your solution for this type of lesson. We need to be able to run commands in your environment to verify your solution.
You can install it here. It's a Go program hosted on GitHub, so you'll need Go installed as well. Instructions are on the GitHub page.