basic-tools

command
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This sample demonstrates a tool whose answer is more than one value: a slow deployment that streams progress while it runs and attaches a chart to what it returns. The runtime helpers in ai/tool do the work without changing the tool's signature (*ai.ToolContext embeds the context they take):

  • tool.AttachParts attaches the chart, so the tool returns a plain *Rollout instead of an *ai.MultipartToolResponse. The signature stops having to announce that the tool sometimes has more to say.
  • tool.SendChunk streams progress while the rollout runs, so a slow tool does not look like a hang.
  • tool.Fail returns an error to the model instead of failing the flow. Ask for a service that does not exist ("Ship checkout to production.") and the model reads the names of the real ones and calls the tool again.

Streaming is best-effort: with a caller that is not streaming, SendChunk is a no-op, so the tool still works when nobody is listening, and the returned *Rollout is always the authoritative answer. Streamed chunks are not written to history, since progress is for showing, not for the model to read.

Run it:

go run .

Or with the Dev UI, which renders the attached chart and keeps a trace of the whole rollout at http://localhost:4000/traces:

curl -sL cli.genkit.dev | bash    # install the Genkit CLI, once
genkit start -- go run .

Or over HTTP. Streaming needs ?stream=true, otherwise the progress goes nowhere and only the final report comes back:

curl -N -X POST 'http://localhost:8080/deployFlow?stream=true' \
  -H "Content-Type: application/json" \
  -d '{"data": {"request": "Ship checkout-api to production."}}'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL