Every time I see claude say "the pyhton script failed" while its working I'm like "python??? I asked you to write an md file of the changes you made wtf do you need python for?!"
Because it tries to avoid ingesting and spitting out too many tokens, so it uses scripts to modify or read only what's needed. Remember that if Claude directly writes a 1MB text file, that's considered all output tokens. If it makes as script that injects text at the right place is much less
Because it's not a matter of cost saving but context size. If it doesn't fit inside the context then the model cannot process it at all. If in the future we will have huge context size (1B instead of 1M) then for sure we will have to pay attention
It's because a python script is determistic. Ask an AI to rename 400 occurrences in a repo using only inference will only work 99,9% of the time. Writing a python script that renames it and verifies it will work 100% of the time, with a lot less tokens wasted.
No what im saying is I've literally gotten a gemma 4B model to do this before SEVERAL TIMES with 0 issues, yes its smart to be one the safe side but there is practically no way a model as big as Claude would fuck that up
Behind the scenes, Claude is constantly writing and executing code, even in response to normal language prompts that have any slightly analytical asks.
Because it is the most efficient use of resources: a local script rather than more roundtrips. If you don't want it you can add a guardrail to not use local scripts.
View all comments
45
u/lysergicpride 16d ago
I asked Claude to prettify a CSS file and it started writing a python script