Collapse `Message`/`ToolMessage` handling into generic `Component` handling
Maintainer thường phản hồi trong vòng 3 ngày
@AngeloDanducci đang làm issue này rồi.
Từ ngày 17/8/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Context
Follow-up to #1542 (allow components to declare their chat role via format_for_llm) and its umbrella #1030 (message serialization). During that work we explored whether the special-cased Message/ToolMessage handling could be collapsed into the generic Component handling - i.e. move message serialization entirely onto the TemplateRepresentation -> Message path so a plain custom Component could express everything a Message can.
The blocker: collapsing Message into Component would regress the #1389 ToolMessage work.
#1389 made tool results round-trip to OpenAI-compatible providers as spec-strict role: "tool" messages with a matching tool_call_id. TemplateRepresentation has since grown role, tool_calls, tool_call_id, and thinking, so a plain Component can already produce a serialization-shaped role: "tool" Message via message_from_template_representation. But ToolMessage still carries live, typed, non-serializable state that TemplateRepresentation cannot express, and that state is consumed by code paths other than the OpenAI serializer.
-
mellea/stdlib/components/chat.pylines 261-296 (ToolMessage) -ToolMessagestores_tool(the fullModelToolCall),_tool_output(the raw Python return value of the tool, not a string),arguments, andname.TemplateRepresentationonly carries serialization (tool_calls: list[dict],tool_call_id: str) - it has no channel for a liveModelToolCallor a typed tool-output object. AComponent->Messageconversion therefore cannot reconstruct aToolMessage; the typed state is lost. -
mellea/stdlib/functional.py(transform/atransform, ~lines 484, 498-507, 1263, 1277-1286, 1377, 1408) - these paths depend on the liveToolMessagestate, not on its serialized form:type(output._tool_output) is type(obj)matches the raw return value by Python type, andchosen_tool._tool.args/chosen_tool._tool.nameread theModelToolCalldirectly. If tool results were only ever plainMessages reconstructed from aTemplateRepresentation,transformwould lose its type-matching and argument-introspection and regress. -
mellea/formatters/chat_formatter.py(case Message(): return c) andmellea/stdlib/components/chat.py(as_chat_history/as_generic_chat_history) - theMessageshort-circuit returns the object verbatim, soToolMessagesubtype identity (and its_tool.tool_call_id) survives to the backend payload. A collapse that routed every turn throughTemplateRepresentationwould drop this short-circuit and, with it, the subtype.
What a real collapse would require (for the future design discussion)
- A way for the intermediate representation to carry live objects, not just serialization - e.g. an optional
ModelToolCall/ raw tool-output slot onTemplateRepresentation, or a separate live-state channel. This is a departure from theimages/audio/roleprecedent, which are all serialization-shaped - A decision on whether a component declaring tool semantics should materialize a
ToolMessage(sofunctional.transform's type-matching keeps working) rather than a plainMessage, and how it would supply the raw_tool_output - Keeping the
functional.pytransform/atransformcontract (_tool_outputtype-match,_tool.args/_tool.nameintrospection) intact through whatever new path replaces theMessageshort-circuit
Notes
- Open question for the design discussion: is
TemplateRepresentationthe right home for live/typed state at all, or shouldMessage/ToolMessageremain a deliberately-special "already-materialized" case that bypasses the intermediate representation (the currentcase Message(): return cshort-circuit)? The exploration leans toward the latter being intentional, not accidental - Related: #1030 (umbrella), #1389 (tool-result
role: "tool"/tool_call_id), #1542 (component-declared role)
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 161
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của generative-computing/mellea
-
bug: `mellea.plugins.builtin_debug.generation.log_generation_post_call` shows model as unknownĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
generative-computing/mellea#1864 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug: instruct() and react() replay tool-call turns without tool_callsCó thể đã có người làm @simonyang08 đã nhận 21 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
generative-computing/mellea#1784 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Silently mangled docstrings: lone backslash line-continuations in non-raw docstrings collapse command examplesCó thể đã có người làm @madhusudhan1260 đã nhận 18 ngày trước. Đang mởgood first issue p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
generative-computing/mellea#1780 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
area/telemetry enhancement p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
generative-computing/mellea#1210 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Add requirement priorityĐang mởarea/requirement area/stdlib enhancement p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
generative-computing/mellea#31 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của generative-computing/mellea
Issue tương tự
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shardsĐang mởstatus/accepted type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/apm#5309 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug vector-store
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
EverMind-AI/Raven#1413 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
Maintainer thường phản hồi trong vòng 2 ngày