Skip to content
The AI Agent Factory

Chapter 13. Programming Fundamentals in the AI Era: TypeScript and Python

Approved by
Panaversity ·
5 min read

The point

What is inside a script an agent writes for you? Choices. Which invoices count as late? Is an invoice due on Saturday paid on Friday? The agent makes most of these while it writes, and tells you about a few. Then the code repeats each one every time it runs. If you know what each option does, you make them. If not, the agent does.

Where do I make those choices? Mostly before any code exists. In your brief (Chapter 5), you name the rules that matter, and your "Done when" lists the answers the tests must give. In the agent's plan, you judge whether it is heading the right way. When you discuss the design, as a system designer would, you say how the work is split into parts, what each part promises, and why.

When can I trust the agent's code? When the tests you decided give the answers you expected, not when the agent says it works. For code that runs once, if a mistake would cost little, that is enough. For code that moves money, or runs again next week, also read the lines that carry a rule (13.10).

After this chapter you can plan a short program with a coding agent, and make its main choices yourself. You can say what the code will do before you run it. When it breaks, you can read the error and tell the agent exactly what broke.

Every example is in TypeScript, the language of Brightline's scripts, and in Python, which much of the code you will meet later uses. Use the tabs to pick one. If this is your first programming language, follow one, and come back for the other later. The lab uses both.

Why it matters

Renee manages the office of a building-supply company in Toledo, Ohio. In March she asks a coding agent for a script that lists the invoices due by each Friday's payment run. The script works. The agent's reply ends with a note: two invoices fall due on the weekend after the run, and she must decide whether to pay them on Friday. She adds both to that week's payments herself. After that she runs the script on her own every Friday.

In May, a $12,900.00 invoice from a freight company falls due on a Saturday. The script leaves it off Friday's list, because Saturday is after Friday, and nothing on the screen says so. Renee pays the list. The freight invoice waits a week for the next run. On Thursday the freight company stops working with them until it is paid, so Friday's deliveries do not come.

The agent's code was right, and it named the choice. Renee made the choice once, for one week. The note stayed in the chat. The script had no rule for weekends, so every Friday after that, it made the choice for her. So what do you need to know to make these choices yourself, so that they last?

Owner
Panaversity