I have
been able to complete the AI coding agent project , which really helped me understand agentic AI from a practical point of view.
To put the agent to the test, I introduced an intentional bug in a simple Calculator class by setting the operator precedence incorrectly:
class Calculator:
def __init__(self):
self.operators = {
"+": lambda a, b: a + b,
"-": lambda a, b: a - b,
"*": lambda a, b: a * b,
"/": lambda a, b: a / b,
}
self.precedence = {
"+": 3, # should be 1, set to 3 so 3 + 5 * 2 = 16
"-": 1,
"*": 2,
"/": 2,
}
As expected, this flaw caused the calculator to fail basic math. For instance, the expression 3 + 5 * 2 returned 16 instead of the correct value of 13:
(venv313) C:\Users\dsun\Denis_files\python_proj\ai_apps\aicodeagent>python calculator\main.py " 3 + 5 * 2 "
{
"expression": " 3 + 5 * 2 ",
"result": 16
}
What defines an "agent" is its ability to autonomously use tools and iterate based on its findings. In this setup, the agent was equipped with four primary functions:
available_functions = types.Tool(
function_declarations=[
schema_get_files_info,
schema_get_file_content,
schema_run_python_file,
schema_write_file,
]
)
The following "conversation" log illustrates the agent's decision-making process as it navigated the codebase and applied the fix automatically:
(venv313) C:\Users\dsun\Denis_files\python_proj\ai_apps\aicodeagent>python main.py " 3 + 5 * 2 should not be 16 please fix the code problem under calculator folder"
User: " 3 + 5 * 2 should not be 16 please fix the code problem under calculator folder" Model: "I want to call get_files_info..." - Calling function: get_files_info Tool: "Here's the result of get_files_info..." Model: "I want to call get_files_info..." - Calling function: get_files_info Tool: "Here's the result of get_files_info..." Model: "I want to call get_file_content..." - Calling function: get_file_content Tool: "Here's the result of get_file_content..." Model: "I want to call get_files_info..." - Calling function: get_files_info Tool: "Here's the result of get_files_info..." Model: "I want to call get_file_content..." - Calling function: get_file_content Tool: "Here's the result of get_file_content..." Model: "I want to call write_file..." - Calling function: write_file Tool: "Here's the result of write_file..." Model: "I want to call run_python_file..." - Calling function: run_python_file Tool: "Here's the result of run_python_file..." Model: "Great! The output is 13, which means the fix was successful. The calculator now correctly evaluates the expression "3 + 5 * 2". "With the agent's intervention complete, the bug was resolved without any manual code editing:
(venv313) C:\Users\dsun\Denis_files\python_proj\ai_apps\aicodeagent>python calculator\main.py " 3 + 5 * 2 "
{
"expression": " 3 + 5 * 2 ",
"result": 13
}
In summary,this experiment highlighted the most critical aspect of agentic AI: the feedback loop. By allowing the agent to run code, analyze errors, and rewrite files, we move beyond simple text generation into the realm of autonomous problem-solving. To me, this project was a vital stepping stone in understanding how AI can act as a true collaborator in the development process.