Skip to content

feat(cli): sharpi run --tools — execute tools + multi-turn agentic loop (#382 follow-up) #384

Description

@pekkah

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:

  1. 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.
  2. 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.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions