.NET: [Issue]: Function invocation middleware receives tool results as JsonElement, which the docs do not mention
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
- Área
- documentation
Línea de trabajo
El vacío está en el comentario de documentación XML de FunctionInvocationDelegatingAgentBuilderExtensions.Use, que solo indica que el delegado devuelve una tarea que representa el resultado de la invocación de la función. Lee ese comentario y el tipo FunctionInvocationContext para confirmar que no existe una propiedad Result. Después añade una frase que diga que la continuación produce un JsonElement con el resultado serializado de la herramienta y que devolver un valor serializable reemplaza lo que ve el modelo. Está terminado cuando el comentario de documentación indica el tipo en tiempo de ejecución y la documentación de API generada lo refleja.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 14.3k
- Forks
- 2.5k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 342
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/agent-framework
-
Python: [Bug]: native Windows --files paths skip changed-package tasksPosiblemente ocupada @ktz03 la tomó hace 4 días. Abiertoneeds-maintainer-triage python triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/agent-framework#9742 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
.NET triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/agent-framework#9704 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Python: FileSessionStore.set fails on Windows for long session IDs because its temp file name is 38 characters longer than the snapshotPosiblemente ocupada @Sonica-B la tomó hace 5 días. Abiertopython ready-for-implementation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/agent-framework#9682 · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
Python: foundry-hosting drops request `metadata` from the stored response — `_create_response_event_stream` never passes `request` to `ResponseEventStream`Posiblemente ocupada @its-amann la tomó hace 5 días. Abiertopython triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/agent-framework#9529 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Python: raw-data content mappings lose annotations and attachment metadataQuizá libre de nuevo @moonbox3 la tomó hace 32 días y no hay ningún pull request abierto. Abiertopython triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/agent-framework#8632 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/agent-framework
Issues similares
-
predict_file with crop_model duplicates predictions once per imagePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
weecology/DeepForest#1445 ·
-
agent-ready priority: medium status: ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
melodic-software/claude-code-plugins#11864 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PolicyEngine/policyengine-uk#2785 ·
Los mantenedores suelen responder en 2 días
-
correction metadata
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
acl-org/acl-anthology#10724 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
use-agent-os/agent-os#3739 ·
Los mantenedores suelen responder en 1 día