.NET: [Issue]: Function invocation middleware receives tool results as JsonElement, which the docs do not mention
メンテナーはふだん 1 日以内に返信
@LHB0317 がすでに取り組んでいます。
2026年11月2日 から。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 72/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp
調査の方向性
不足しているのは FunctionInvocationDelegatingAgentBuilderExtensions.Use の XML ドキュメントコメントで、そこではデリゲートが関数呼び出しの結果を表すタスクを返すことしか書かれていません。そのコメントと FunctionInvocationContext 型を読み、Result プロパティが存在しないことを確認してください。そのうえで、継続処理が、ツールの結果をシリアル化した JsonElement を生成すること、そしてシリアル化可能な値を返すと、モデルが見る内容が置き換わることを述べる文を1つ追加してください。ドキュメントコメントに実行時の型が記載され、生成された API ドキュメントにもそれが反映されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Category
Documentation
Problem
AIAgentBuilder.Use(...) function-invocation middleware receives every tool result as a JsonElement, whatever the tool declares, and no documentation says so. The only statement is on FunctionInvocationDelegatingAgentBuilderExtensions.Use: the delegate "returns a task representing the result of the function invocation". The runtime type is not mentioned anywhere, so the natural implementation of a middleware that inspects or rewrites a result silently does nothing.
Evidence
Measured with Microsoft.Agents.AI.Harness 1.27.0, one tool per shape, reading result.GetType().Name inside the middleware:
| tool returns | middleware receives |
|---|---|
string |
JsonElement containing "a plain string" |
int |
JsonElement containing 42 |
a record Poco(string Name, int Value) |
JsonElement containing {"name":"x","value":1} |
int[] |
JsonElement containing [1,2,3] |
The guard a developer writes first therefore never fires:
.Use((AIAgent _, FunctionInvocationContext ctx,
Func<FunctionInvocationContext, CancellationToken, ValueTask<object?>> next,
CancellationToken ct) =>
{
var result = await next(ctx, ct);
if (result is not string text || text.Length <= cap) return result; // never truncates
return Truncate(text);
})
Rewriting does work once the type is known: returning a string from the middleware reached the provider as 22 characters instead of 868,893, on both the streaming and non-streaming paths. FunctionInvocationContext also exposes no Result property, so the value exists only as the continuation's return value.
The underlying behaviour looks deliberate, serialising once instead of deserialising and re-serialising, so this is reported as a documentation gap rather than a defect in the pipeline.
Desired Outcome
The Use documentation should state what the continuation returns: a JsonElement holding the serialized tool result, and that returning a serializable value from the middleware replaces what the model sees. One sentence is enough; a typed helper such as ctx.GetResult<T>() would be nicer but is not what this issue asks for.
Language
.NET
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
AI assistance. The analysis, the probe program and this report were prepared with an AI coding assistant. The type table above was produced by running the probe against the published package; nothing is inferred. API names and versions were checked against the package and the repository's main branch.
Verification. Measured locally before filing:
- OS: Windows 10.0.26300.9711
- SDK: .NET SDK 10.0.402, runtime 10.0.9
- Package:
Microsoft.Agents.AI.Harness1.27.0 - How:
dotnet runon a console project that registers one tool per shape, runs a scriptedIChatClient, and prints the runtime type of the middleware's continuation result - Output:
JsonElementfor all four shapes, as tabulated above
- 主要言語
- Python
- スター
- 14.5k
- フォーク
- 2.6k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 335
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/agent-framework のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
microsoft/agent-framework#9946 ·
メンテナーはふだん 1 日以内に返信
-
Python: [Bug]: native Windows --files paths skip changed-package tasks対応中かも @ktz03 が 6 日前に担当しました。 オープンneeds-maintainer-triage python triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/agent-framework#9742 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
.NET triage
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
microsoft/agent-framework#9704 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Python: FileSessionStore.set fails on Windows for long session IDs because its temp file name is 38 characters longer than the snapshot対応中かも @Sonica-B が 7 日前に担当しました。 オープンpython ready-for-implementation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/agent-framework#9682 · 担当者 2 名 ·
メンテナーはふだん 1 日以内に返信
-
Python: foundry-hosting drops request `metadata` from the stored response — `_create_response_event_stream` never passes `request` to `ResponseEventStream`対応中かも @its-amann が 7 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/agent-framework#9529 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
microsoft/agent-framework の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws/sagemaker-python-sdk#6554 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
huggingface/diffusers#15170 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] LLM conflict check ignores MNEMOSYNE_LLM_MAX_TOKENS, so reasoning models return empty repliesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
mnemosyne-oss/mnemosyne#1325 ·
メンテナーはふだん 1 日以内に返信
-
enhancement meshtastic-2.8
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pskillen/meshflow-api#459 ·