i asked Akiko to create a role called bleh 3 and give it to me. she created bleh 3 and gave me bleh 2.
it wasn't a fluke. every time, she granted the role that was created before the one i asked for.
why
she has tools like create_role and add_role. when i ask for both in one message, the model plans both calls in a single response. so the second call's arguments get written before the first call has run. at that point the newest role ID the model has seen is the previous one, so that's the one it hands to add_role.
bleh 2 got a fresh ID and add_role was handed the ID of the earlier bleh. bleh 3 got a fresh ID and add_role was handed bleh 2's.
running the calls in order doesn't help. the arguments were already written.
the fix
create_role now reports the ID it really made, as structured data and not by parsing a sentence. the engine keeps a list of things created in the current batch. if another role or channel action in the same batch points at something else, it gets refused with the real ID in the error, so the model retries with the right one.
i refuse instead of quietly swapping in the new ID. "create role A, then take role B off me" is a real request that points at an existing role, and redirecting it would do the wrong thing, which is the exact bug i was fixing.
the real problem was bigger
while i was in there i counted her tools. six. none of them could look anything up on a server. no way to ask "what is this role's ID". a model that needs an ID and can't ask doesn't leave it blank. it writes the most believable number it can find.
in one test run it used the ID of a role from a run 48 minutes earlier, a user ID that was just 1234567890123456789, and a channel from 2022 that it never created. it sent a message there, made an invite, and deleted the channel.
i'd written five guards for five different ways of inventing an ID, and each one found a new way. so i stopped guarding and added three lookup tools. guards stop wrong answers. a lookup removes the reason to guess.
if your bot is making up IDs, give it a way to look them up :3
Akiko's free to add: https://upload.motzumoto.com/devto
Top comments (0)