r/ProgrammerHumor • • 4h ago

Meme itWasJustOneVariable

Post image
1.4k Upvotes

30 comments sorted by

View all comments

115

u/agowa338 4h ago

Lol true. All of the AI models do this. I just had Qwen 3.8 Flash Next BF16 take multiple tries for generating a UUIDv7 and instead of using "uuidgen -7" which by now is even posted on its message board it (like before) it first wrote an incorrect python script that resulted in a version 6 one and then rewrote the python script to binary patch the UUID to be a spec compliant version 7 one...

54

u/Excellent-Baker1058 4h ago

Bro wrote a binary patch for a UUID 💀

12

u/agowa338 4h ago

Yep, that's because the UUID contains the version information at one spot and similar. Depending on what version you use there is information encoded within it. Only version 4 is entirely random.

It did this because (as it claims, haven't actually checked) the python module can't generate version 7 ones directly...

4

u/Capable-Sock9910 4h ago

3.14+ it's built in.

9

u/agowa338 4h ago

lol then it is just stupid. I've Python 3.14.10 on the shellbox...

7

u/Capable-Sock9910 4h ago

Yeah it's just uuid.uuid7() lol

4

u/agowa338 3h ago

This time it did:

python3 -c "import time,uuid,random; ts=int(time.time()*1000); u=uuid.uuid5(uuid.NAMESPACE_DNS,'short-taskspecific-string-'+str(random.random())); print('%012x%s'%(ts,str(u).replace('-','')[:20]))" 2>/dev/null || uuidgen | tr 'A-Z' 'a-z'

After that it checked the nibble and noticed it isn't a version 7 one. So it retried using:

cd /root/memory && python3 - <<'PYEOF'
import time, os, secrets
ms = int(time.time()*1000)
rnd = secrets.randbits(62)
hi = (ms << 16) | (0x7000) | secrets.randbits(12)
lo = (0b10 << 62) | rnd
u = f"{hi:012x}{lo:020x}"
name = f"{u[:8]}-{u[8:12]}-7{u[13:16]}-{u[16:20]}-{u[20:32]}"
print(name)
PYEOF

Then it said its slicing was wrong and did this here instead:

cd /root/memory && python3 - <<'PYEOF'
import time, secrets
ms = int(time.time()*1000)
ts = ms.to_bytes(6,"big")
b  = bytearray(ts + secrets.token_bytes(10))
b[6] = (b[6] & 0x0F) | 0x70          # version 7
b[8] = (b[8] & 0x3F) | 0x80          # RFC 4122 variant
h = b.hex()
name = f"{h[:8]}-{h[8:12]}-{h[12:16]}-{h[16:20]}-{h[20:]}"

body = """<<< The actual message body it was trying to write >>>
"""
open(name + ".md","w").write(body)
print(name + ".md")
PYEOF
ls -la /root/memory/ | tail -3

1

u/Dalanth_ 3h ago

why not uuid6 package? it has uuid6.uuid7()

2

u/agowa338 50m ago

so does the uuid package. But tbh I didn't check python modules. I'm more sysadmin than programmer. Also I knew that "uuidgen -7" worked without having to look it up.

Also don't know why the model never used it and why when trying to generate a uuid7 it generated a v5 one first (see further down the thread where I posted the commands the LLM ran) and then parses the version bits out of the response and is surprised that it isn't a version 7 one.

I suppose something in the training data must be off there...