streaming

command
v2.8.0-dev.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

streaming — built-in tools + terminal chat rendering

What this shows

An agent wired with the standard built-in tools (read_file, list_dir, bash, ...) behind a permissions gate, driven from a command-line prompt and rendered as an interactive chat session via runner.WriteEvents. When stdout is a terminal, tool calls render in cyan and partial assistant text in green; pipe the output and the same code path emits plain text with no escape codes.

The permissions mode is set to yolo so tool calls auto-approve — the example has no human in the loop. Real apps keep ask and wire a prompter into permissions.FromConfig.

Run it

Needs real provider credentials; the provider auto-detects from env when --provider is omitted:

GEMINI_API_KEY=...    go run ./examples/streaming "what's in main.go in this directory?"
ANTHROPIC_API_KEY=... go run ./examples/streaming --provider anthropic "list the .go files here"

Pick a prompt that forces tool use ("how many lines of go code in this repo?" → bash) to see the formatter work.

Key APIs

  • runner.WriteEvents / runner.WithColor / runner.IsTerminalgithub.com/go-steer/core-agent/v2/pkg/runner
  • tools.Build + tools.Defaultgithub.com/go-steer/core-agent/v2/pkg/tools
  • permissions.FromConfig / permissions.ModeYologithub.com/go-steer/core-agent/v2/pkg/permissions
  • agent.New / agent.WithToolsgithub.com/go-steer/core-agent/v2/pkg/agent

What you should see

> what's in main.go in this directory?
→ read_file {"path": "main.go"}
main.go is the streaming example: it builds the default toolset, ...

with the → tool lines colored when run in a terminal.

Next

Documentation

Overview

Example: drive the agent with the standard built-in tools (read_file, list_dir, bash, etc.) and render the response as an interactive chat session via runner.WriteEvents.

Tool calls render in cyan, partial assistant text in green when the output is a terminal (auto-detected via runner.IsTerminal). Pipe the output (e.g. `... | cat`) and you'll get plain text — same code path, no escape codes leak through.

Usage:

GEMINI_API_KEY=...   go run ./examples/streaming "what's in main.go in this directory?"
ANTHROPIC_API_KEY=... go run ./examples/streaming --provider anthropic "list the .go files here"

Pick a prompt that requires tool use to see the formatter shine:

  • "what files are in this directory?" → list_dir
  • "summarize main.go" → read_file
  • "how many lines of go code in this repo?" → bash

Jump to

Keyboard shortcuts

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