v1.7.0
Make tool-result offloading actually fire
OffloadingAIFunction tested "result as string" and returned early when it was
null. AIFunctionFactory marshals return values through System.Text.Json, so a
tool declared as returning string hands back a JsonElement and that test was
null every single time. Offloading has therefore never run: MaxToolResultChars
and the whole read_tool_result / head_tool_result / tail_tool_result /
grep_tool_result family have been inert for every built-in tool.
Demonstrated by passing a null store with a 100-char threshold and a 5 000-char
result: it returned the result inline and did not throw, so the offload branch
was never entered.
Use ToolResultText.AsText, added in the previous commit for the same reason.
Non-string JSON offloads on its raw text - a large object costs the same
context as a large string.
Note this changes live behaviour for the first time. At the default 16 000
chars a wide grep or a large read_file now returns a placeholder instead of
inlining, and the model has to fetch the content. Verified end to end that the
payload survives byte for byte and that grep_tool_result retrieves it, since
those consumers had never actually been exercised on this path. Raising
MaxToolResultChars tunes it without reverting the fix.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com