Context
#382 (ab6640e) added sharpi run --tools <file.json> (advertise OpenAI tool defs via the chat template) and --tool-grammar (constrain argument bytes). Today the CLI parses and prints the model's tool calls after generation, single-shot — it does not execute them or take a second turn. The full request→call→result→answer loop only exists in samples/SharpInference.Sample.ToolCall (hand-wired).
Proposed (optional / future)
Let sharpi run close the agentic loop:
- After parsing tool calls, dispatch each to a handler, append
role="tool" result messages, re-render the prompt, and run a second (and subsequent) turn until the model stops calling tools or a --max-tool-turns cap is hit.
- Handler options:
--tool-exec <command> — run an external program per call (call JSON on stdin, result on stdout), or
- a small built-in demo set (mirrors the sample's
get_weather/calculate) for --tool-demo.
- Interactive mode: surface the parsed-call display per turn (today it's single-prompt
-p only; the constraint + advertising already apply each turn).
Notes / scope
- Keep it opt-in and orthogonal to
--tool-grammar (the loop works constrained or not).
- This is a product/UX decision more than a correctness gap — the constraint itself is complete. File-as-backlog; may be declined if the sample is considered sufficient.
Refs #382 (ab6640e); existing flow: samples/SharpInference.Sample.ToolCall.
Context
#382 (
ab6640e) addedsharpi run --tools <file.json>(advertise OpenAI tool defs via the chat template) and--tool-grammar(constrain argument bytes). Today the CLI parses and prints the model's tool calls after generation, single-shot — it does not execute them or take a second turn. The full request→call→result→answer loop only exists insamples/SharpInference.Sample.ToolCall(hand-wired).Proposed (optional / future)
Let
sharpi runclose the agentic loop:role="tool"result messages, re-render the prompt, and run a second (and subsequent) turn until the model stops calling tools or a--max-tool-turnscap is hit.--tool-exec <command>— run an external program per call (call JSON on stdin, result on stdout), orget_weather/calculate) for--tool-demo.-ponly; the constraint + advertising already apply each turn).Notes / scope
--tool-grammar(the loop works constrained or not).Refs #382 (
ab6640e); existing flow:samples/SharpInference.Sample.ToolCall.