Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Recover tool calls wrapped in a markdown code fence

オープン 初心者向け
#18 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
ai

調査の方向性

internal/agent/agent.go の normalizeMessage から始めてください。strings.HasPrefix(stripped, "{") のガードと <tool_call> の分岐が、内容がツール呼び出しかどうかを決めています。その判定の前に、先頭と末尾のトリプルバッククォートのフェンスを取り除き、再度トリムして既存のロジックに流す小さなステップを追加してください。完了条件は、internal/agent/agent_test.go の新しいケースが通ること、フェンス付き JSON に対して Turn が Rounds == 1 を返すこと、そして散文およびツール呼び出しではないフェンスのテストが変更されていないことです。

索引モデルが issue の本文から書いたものです。

説明

bug good first 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 json or json5), and drop a trailing three-backtick line if present.
  • Then TrimSpace and 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 with json tag, 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 ./..., and gofmt -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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Edwin-metcalf/MetCode のほかの issue

Edwin-metcalf/MetCode の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。