Oneirocom / Magick

Magick is a cutting-edge toolkit for a new kind of AI builder. Make Magick with us!
https://magickml.com
Other
686 stars 112 forks source link

adds an automatically expanding array of spellRunners for each spell #1276

Closed benbot closed 1 year ago

benbot commented 1 year ago

What Changed:

SpellRunners (the class that runs spells) can't really handle multiple spell runs at the same time. They are pretty stateful, so that causes race conditions to pop up and results in weird behavior from agents that are receiving many messages at a time.

This changes how the SpellManager gets SpellRunners to run spells. Before we had a mapping of SpellId -> SpellRunner, but now we have a mapping of SpellId -> Array

When we try to get a SpellRunner, we get the first "ready" runner in the array a spellId maps to. If we don't find one, we create a new SpellRunner and add it to that array.

This we we have an automatically growing pool of spell runners

In the future we'll probably want this pool to auto clean itself, but it's likely the SpellRunner abstraction won't stick around, so this should be good enough for now.

How to test:

Make a spell with 2 generate text nodes chained into each other. Hook that spell up to discord and send a ton of messages to it.

Observe that it eventually responds to all messages.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
magick-client ✅ Ready (Inspect) Visit Preview Aug 31, 2023 1:55pm
magick-docs ✅ Ready (Inspect) Visit Preview Aug 31, 2023 1:55pm