bug: instruct() and react() replay tool-call turns without tool_calls
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc ChatFormatter.to_chat_messages trong mellea/formatters/chat_formatter.py (các dòng 78-86) để xem các lượt assistant được xây dựng từ Instruction._parse và ReactThought._parse như thế nào. Xác nhận rằng ModelOutputThunk với tool_calls mất chúng khi tin nhắn tiếp theo là vai trò tool. Xong nghĩa là lệnh gọi instruct() thứ hai gửi lượt assistant với tool_calls của nó, thỏa mãn các provider nghiêm ngặt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Found while testing LLM provider integrations in agent frameworks: an automated tool flags candidates and each one is reproduced before it is reported. Reproduced on e6249a5 against local fake endpoints; no real provider was called.
With a ChatContext, a tool loop built on instruct() sends the tool-calling assistant turn back without its tool_calls, so the tool message after it answers nothing. react() does the same. On strict providers the loop dies at its second step.
session = MelleaSession(OpenAIBackend(model_id="gpt-5.1"), ctx=ChatContext())
options = {ModelOption.TOOLS: [weather_tool]}
result = session.instruct("What is the weather in Paris?", model_options=options, tool_calls=True, strategy=None)
for message in call_tools(result, session.backend):
session.ctx = session.ctx.add(message)
session.instruct("Answer using the tool results above.", model_options=options, tool_calls=True, strategy=None)
The second request carries:
[{"role": "user", "content": "What is the weather in Paris?"},
{"role": "assistant", "content": ""},
{"role": "tool", "content": "18C", "tool_call_id": "call_1"},
{"role": "user", "content": "Answer using the tool results above."}]
OpenAI answers that shape with a 400, Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'. (same error on an orphaned tool message in agent-framework#9851). Through LiteLLMBackend, the gemini/ and vertex_ai/ routes never get as far as a request: LiteLLM raises litellm.APIConnectionError: Missing corresponding tool call for tool response message. The anthropic/ route sends a tool_result with no tool_use before it, which Anthropic's tool docs rule out and which comes back as unexpected tool_use_id found in tool_result blocks (example).
Ollama's OpenAI layer has no pairing check, which may be why this hasn't surfaced there, but the model still never sees its own call. The same loop written with session.chat() sends the turn correctly.
Expected: the assistant turn keeps its tool_calls whichever component produced it.
Cause: the fix for #1349 made Message._parse keep tool calls, but Instruction._parse and ReactThought._parse return only the text, so ChatFormatter.to_chat_messages builds a plain Message from an empty string. That is the empty assistant turn #1349 described, still present for instruct(). reasoning_content and Gemini's extra_content are lost with it, so the replay rule from #1201 never applies here.
Fix idea: after building the list in to_chat_messages, when a ModelOutputThunk has tool_calls and the next message has role tool, rebuild that turn with Message._parse. The check on the next message matters, because calls the caller never ran would otherwise go out as dangling tool_calls, and strict providers reject those too.
- 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
-
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
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 18/100
generative-computing/mellea#1863 ·
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ự
-
bug game: 0100FF500E34A000 game: 0400FF500E34A001 mac packing
Độ 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 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
jxxghp/MoviePilot#7576 ·
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 88/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 64/100
jbaruch/software-factory#266 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
cron: raise a distinct error when next_fire finds no match in its search bound (from #813 item 5)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày