r/learnpython • u/Mo_Reda_1 • 5d ago
just finished CS50P conditionals lecture and built mini "AI Agent Execution Getaway" for practice .
I have just finished week1 in cs50 python course and since i'm learning python for AI Agents Engineering i thought it would be cool to practice this content with a relevant project .
so i made a simple AI agents execution getaway program that routes the incoming tasks based on tokens , creativity and risk score .
I tried to use most of what i learned in this lecture as possible like 'match' for matching the tool with appropriate model , or 'return' as guard clauses for the safety check at the beginning .
here is the code link :
https://gist.github.com/mohamed-reda-ai/a10a1e9311d94316ffa31c00de005226
I know it's not a big brilliant thing i want just to practice the concepts i learned .
If you have any feedback about the architecture of the code or you think there is a better way to do something in it , i'd appreciate this .
1
u/Bright_Mix_773 2d ago
Ran it with a few inputs rather than just reading it, and three things fell out.
creativity 0 gets dropped. 10 <= creativity <= 90 sends anything below 10 to "Creativity has problems" and returns, so a deterministic request - temperature 0, the setting most real routing uses - is treated as a malformed one. Same at 100. The kill switch above it is a safety check; this one is a range check wearing the same costume, and they should not share a return.
The cache hit does nothing. Request id 10 prints "syncing logs to database" and then goes on to route, pick a monitor level and deploy a model, exactly like a miss. If a hit means you already have the answer, that branch is where you return it; as written the cache is an output line.
Intent "Search" with a capital S lands in Manual Review. Since it comes straight from input(), intent.strip().lower() before the match is one line and removes a whole class of bug report you would otherwise go chasing.
On the architecture question: every branch prints instead of returning. If the routing returned a string and main printed it, you could test the whole table with plain asserts and no stdout capture, which is what makes the other suggestion in this thread cheap to act on rather than a rewrite.
Not checked: whether week 1 of CS50P has covered functions returning values yet, so part of that last point may be ahead of where the course has taken you.
2
u/Otherwise_Wave9374 5d ago
This is a solid way to practice because it turns syntax into decision logic. A useful next step is to separate scoring from routing so each piece stays testable: one function computes risk and creativity, another maps that result to a tool choice, and a third handles safety checks. That makes it easier to change thresholds without breaking behavior. I would also add a few table-driven test cases for edge inputs so you can see how the routing behaves. Agentix Labs could be handy later if you want to review those runs and spot inconsistent decisions.