feat: pickle the residual non-portable cases (callables, dynamic Pydantic models, session save/load)
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the listed files: mellea/stdlib/components/genstub.py, mellea/backends/tools.py, mellea/stdlib/context/compactor.py, mellea/stdlib/session.py, and mellea/core/base.py; read issue #1535 and test/core/test_pickle.py for the existing behavior. The work spans callables, dynamic Pydantic models, custom compactors, session state, and long linked contexts, each needing a serialization or rebind strategy. Done means these residual cases are handled or documented and covered by tests, with backend reattachment documented for session loading.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What feature would you like to be added?
Issue #1535 already made the common pickle cases work: ModelOutputThunk/ComputedModelOutputThunk now drop their in-flight _gen machinery and backend-native raw/logits on pickle, and — because a Context is just a linked list of its contents and a Component is a Protocol — this transitively made SimpleContext/ChatContext and simple/data-only components (e.g. Message, CBlock) picklable too, all verified in test/core/test_pickle.py.
This issue covers only the residual hard cases #1535 deliberately left out — the ones blocked by user- and backend-supplied objects rather than core machinery, each of which needs its own re-bind/rebuild strategy:
What to change
mellea/stdlib/components/genstub.py
Make GenerativeFunction/Function picklable — _func (raw callable, portable only if top-level) and _response_model (a dynamically-created Pydantic model, which does not pickle by default) need a __getstate__/__setstate__ or a rebuild-on-load strategy. Simple components already pickle.
mellea/backends/tools.py
Tool objects reach a pickled thunk through four paths, each needing a re-bind/rebuild strategy:
ModelToolCall.func(the boundMelleaTool) on tool calls.ModelOption.TOOLSin_call.model_optionsand_generate_log.model_options, when a tool was offered but never called. A thunk with no tool calls therefore does not always pickle._generate_log.extra["tools_available"], which holds the same tool objects.@tool-decorated functions.MelleaTool._call_toolis the original function, and pickle resolves it by qualified name. The decorator rebinds that name to theMelleaTool, so pickling fails withPicklingError: it's not the same object, even when the tool is never called. A plain function wrapped withMelleaTool.from_callablepickles fine.
Async tools also wrap the function in a local closure (tool_call in from_callable), which pickle cannot serialize by reference. Not yet verified; expected to fail regardless of the decorator.
Strategy: either pickle the tool by module + qualified name and re-bind on load, or drop the callable and keep only the JSON schema, requiring a re-bind before loaded tools can run. Leaning toward the first, since it keeps tool identity without serializing code.
mellea/stdlib/context/compactor.py
A ChatContext whose _compactor holds a non-top-level pin_predicate (lambda/closure) or an arbitrary custom InlineCompactor still silently blocks context pickling. Document and/or handle. (A ChatContext with a built-in compactor already pickles via #1535.)
mellea/stdlib/session.py
Add a high-level save()/load() session API (to/from a path) that serializes context + relevant state, backend excluded, with a documented re-attach step. New capability, not touched by #1535.
mellea/core/base.py
Consider _previous linked-list recursion limits for very long conversations (RecursionError risk) — an iterative __reduce__ if needed. The per-node pickling itself already works.
Why it's out of scope for #1535
#1535 targets the core picklability machinery (resetting _gen/raw/logits on the thunk, which cascades to Contexts and simple Components). Each item above depends on a caller/backend-supplied callable, a dynamically-built Pydantic model, or a new session-level API — distinct design work, and the issue itself notes it "may need to be converted into an epic."
Why is this feature needed?
Covers out of scope portion of #1535
Any alternative solution that you may want to share?
No response
Anything else we need to know?
No response
- Lingua principale
- Python
- Stelle
- 1.8k
- Fork
- 161
- Merge medio
- 4g 3h
- PR unite (30g)
- 45
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di generative-computing/mellea
-
bug: `mellea.plugins.builtin_debug.generation.log_generation_post_call` shows model as unknownApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
generative-computing/mellea#1864 ·
I maintainer di solito rispondono entro 3 giorni
-
bug: instruct() and react() replay tool-call turns without tool_callsForse già presa @simonyang08 l’ha presa 20 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
generative-computing/mellea#1784 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Silently mangled docstrings: lone backslash line-continuations in non-raw docstrings collapse command examplesForse già presa @madhusudhan1260 l’ha presa 18 giorni fa. Apertagood first issue p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
generative-computing/mellea#1780 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 3 giorni
-
area/telemetry enhancement p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
generative-computing/mellea#1210 ·
I maintainer di solito rispondono entro 3 giorni
-
Add requirement priorityApertaarea/requirement area/stdlib enhancement p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
generative-computing/mellea#31 · 2 commenti ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di generative-computing/mellea
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Maintainer] task area:visualizer
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
RailtownAI/railtracks#1824 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
apache/datafusion#27688 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
mloda-ai/mloda-registry#1664 ·
I maintainer di solito rispondono entro 1 giorno