I'm trying to use Missionary to implement batching, where a batching "transducer" takes several long-running Missionary tasks, executes them concurrently, and emits a vector of available results that arrived during successive batching time windows, until all tasks are completed/failed/cancelled (ideally with dynamically growing time windows).
I figured I can use m/sample for this. This is based on an example from the b.44 docs, which almost does what I want:
; using 200ms batching time windows:
(m/? (m/reduce conj (m/sample vector (m/reductions {} 0 (sleep-emit [200 200 200 200 200]))
(sleep-emit [50 100 150 200 250 300 350])))) ; long-running tasks here
However, I want to produce [[0 [50 100 150] [200 [200 250 300] [400 [350]] etc. until all results are are completed, cancelled or failed. Maybe I can do an m/group-by here?
I tried putting an (interval 200) (from docs) in there, but I don't understand the result. Will put example in comments.
There is probably a cleaner way. (This is for my MCP library, Modex, where so I can batch the result of various tool calls that arrived in a short time window.)Here is the pattern with group-by
(defn batch [delay [_ flow]]
(m/reduce conj
(m/eduction (take-while (complement #{::timeout}))
(m/ap (m/amb= (m/?> flow) (m/? (m/sleep delay ::timeout)))))))
(defn batches [delays flow]
(m/ap (m/? (m/?> (m/zip batch (m/seed delays) (m/group-by {} flow))))))
(comment
((m/reduce (fn [_ x] (prn x)) nil
(batches (iterate (partial + 1000) 0)
(m/observe (fn [!] (def push! !) #()))))
prn prn)
(push! :alpha)
(push! :bravo)
(push! :charlie)
(push! :delta)
(push! :echo)
)I'm willing to pay for better docs & examples for Missionary b.44 that would be suitable for LLM context. The Missionary repo as context is not sufficient to get good results out of Claude 3.7 Sonnet or Gemini 2.5 Pro.
I'm also interested in this, but I doubt it can be done with just a system prompt. I think there would need to be (RL) post-training involved. I've just been dumping the whole docs and the missionary for dummies blog into context.
how much? 😛
& can you provide an eval?
I'll put up $100 via crypto. Maybe someone else wants to pitch in? If using the docs an LLM can answer my question above and come up with Leo's response (without knowing the solution upffont – just the building blocks), I'll pay. Just translating the common core.async patterns would already help. I tried building a spreadsheet computation using Missionary some time ago with the help of Claude, and it failed miserably, so I ended up doing it manually. It kept hallucinating Missionary calls, but I haven't retried this using Cursors + Missionary repo as docs yet.