Recover tool calls wrapped in a markdown code fence
まだ誰も着手していません。
評価
調査の方向性
internal/agent/agent.go の normalizeMessage から始めてください。strings.HasPrefix(stripped, "{") のガードと <tool_call> の分岐が、内容がツール呼び出しかどうかを決めています。その判定の前に、先頭と末尾のトリプルバッククォートのフェンスを取り除き、再度トリムして既存のロジックに流す小さなステップを追加してください。完了条件は、internal/agent/agent_test.go の新しいケースが通ること、フェンス付き JSON に対して Turn が Rounds == 1 を返すこと、そして散文およびツール呼び出しではないフェンスのテストが変更されていないことです。
索引モデルが issue の本文から書いたものです。
説明
What
normalizeMessage recovers tool calls a model writes as plain text, but the entry guard only accepts content whose trimmed form starts with { or <tool_call>. When a model wraps the JSON in a markdown code fence (```json ... ```), the guard bails out and the call is silently dropped — rounds=0, and the raw JSON (or the fence) gets printed to the user as if it were the answer.
Evidence
Real qwen2.5-coder:7b session, prompted to run a command:
great now can you run a command in the terminal to echo the contents of job.go?
stats rounds=0 prompt_tok=1456 ...
{"name": "run_command", "arguments": {"command": "cat", "arguments": ["job.go"]}}
The call is well-formed and safe to run (it would hit the confirmation prompt). It is only missed because of the ```json prefix.
Where
internal/agent/agent.go, normalizeMessage — the strings.HasPrefix(stripped, "{") guard and the <tool_call> branch.
Proposed fix
Before the existing gate, strip a markdown code fence if present:
- If the trimmed content starts with three backticks, drop that first line (the fence plus an optional language tag such as
jsonorjson5), and drop a trailing three-backtick line if present. - Then
TrimSpaceand fall through to the current logic. - Handle the fence appearing around or inside
<tool_call>tags too, whichever ordering is simplest.
Keep the "starts with {" requirement after stripping — that is what keeps prose safe.
Acceptance criteria
- A fenced JSON tool call runs through
Turn(Rounds == 1) and reaches the tool with the correct arguments. - New tests in
internal/agent/agent_test.go: fenced withjsontag, fenced bare, fenced with trailing fence, fenced inside<tool_call>. - Existing negative cases still pass untouched: prose, and a fenced block that is not a tool call.
go build ./...,go vet ./...,go test ./..., andgofmt -l .all clean.
Notes
- Keep it a small, separate branch in
normalizeMessage, matching the style there. - Do not loosen the guard to "content contains
{anywhere" — that would turn any answer containing a JSON snippet into a tool call.
- 主要言語
- Go
- スター
- 1
- フォーク
- 2
- 平均マージ
- 1時間 31分
- マージ済み PR(30日)
- 7
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Edwin-metcalf/MetCode のほかの issue
-
documentation enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Edwin-metcalf/MetCode#19 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Edwin-metcalf/MetCode#16 ·
-
testing
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Edwin-metcalf/MetCode#9 ·
-
Add a Makefileオープンenhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Edwin-metcalf/MetCode#8 ·
-
Add a --host flagオープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Edwin-metcalf/MetCode#7 ·
Edwin-metcalf/MetCode の issue をすべて見る
似ている issue
-
area/import kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
kind/documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
kubernetes-sigs/dra-driver-nvidia-gpu#1569 ·
メンテナーはふだん 1 日以内に返信
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
openclaw/openclaw-enterprise#2571 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信