bug(backends): tool-call JSON nested under a non-first dict key is silently dropped by find_func
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
バグは mellea/backends/tools.py の 510〜511 行付近の find_func にあります。d.values() をループする処理が最初の値で return してしまいます。issue に示されているとおり、ツール呼び出しが最初のキーではない dict を用いて parse_tools で再現してください。完了条件は、後のキーの下にあるエンベロープされた呼び出しが返されること、最初のキーの場合も引き続き動作すること、そして両方のキー順序をカバーするテストが通ることです。
索引モデルが issue の本文から書いたものです。
説明
What happened?
find_func in mellea/backends/tools.py searches a parsed JSON object for a {name, arguments} tool call. When the top-level object has no name/arguments of its own, it recurses into the object's values — but returns inside the loop, so only the first value is ever searched:
# mellea/backends/tools.py:510-511
for v in d.values():
return find_func(v)
return None, None
If a model wraps its tool call in an envelope where the call is not the first value — e.g. {"meta": 1, "call": {"name": "f", "arguments": {...}}} — parse_tools returns [] and the tool call is silently dropped. The identical envelope with keys in the other order works, so extraction depends on arbitrary key ordering in the model's output.
This feeds to_tool_calls (mellea/backends/utils.py), which is used by LocalHFBackend.post_processing — so a local-HF model emitting an enveloped tool call loses the call entirely (no error, the reply just has no tool_calls).
What did you expect to happen?
All values of the envelope dict should be searched, and {"meta": 1, "call": {...}} should yield the same tool call as {"call": {...}, "meta": 1}.
How can we reproduce it?
from mellea.backends.tools import parse_tools
# call is the first value -> found
print(parse_tools('{"call": {"name": "f", "arguments": {"x": 1}}, "meta": 1}'))
# [('f', {'x': 1})]
# same call under a later key -> dropped
print(parse_tools('{"meta": 1, "call": {"name": "f", "arguments": {"x": 1}}}'))
# [] <-- expected [('f', {'x': 1})]
The nested object is never reached by the fix-up scan either: json_extraction advances index to the end of the outer object after raw_decode, so the inner { is not re-scanned.
Mellea version
0.10.0.dev0
Any environmental details we need to know?
Affects the local HF path (LocalHFBackend.post_processing -> to_tool_calls -> _parse_tool_calls -> find_func); any caller of parse_tools/to_tool_calls is affected. No model needed to reproduce — pure parsing bug.
Additional context
Suggested fix is small — search all values and return the first hit:
for v in d.values():
result = find_func(v)
if result != (None, None):
return result
return None, None
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 161
- 平均マージ
- 4日 4時間
- マージ済み PR(30日)
- 47
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
generative-computing/mellea のほかの issue
-
bug(cli): intrinsic_uploader builds path_in_repo with os.path.join, producing backslashes on Windowsオープン
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
generative-computing/mellea#1870 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1時間未満 初心者へのやさしさ 82/100
generative-computing/mellea#1869 ·
メンテナーはふだん 3 日以内に返信
-
bug: `mellea.plugins.builtin_debug.generation.log_generation_post_call` shows model as unknown対応中かも @mvanhorn が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
generative-computing/mellea#1864 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
bug: instruct() and react() replay tool-call turns without tool_calls対応中かも @simonyang08 が 22 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
generative-computing/mellea#1784 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Silently mangled docstrings: lone backslash line-continuations in non-raw docstrings collapse command examples対応中かも @madhusudhan1260 が 19 日前に担当しました。 オープンgood first issue p2
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
generative-computing/mellea#1780 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
generative-computing/mellea の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/dbt-clickhouse#829 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
volcengine/OpenViking#8432 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信