runtime-config

command
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

RuntimeConfig Example

Demonstrates the Polyglot Exec Protocol and RuntimeConfig — declarative SDK setup with external tools, evals, and hooks written in Python.

What This Shows

  • RuntimeConfig YAML — one line (sdk.WithRuntimeConfig("./runtime.yaml")) replaces 50+ lines of programmatic setup
  • Exec tools — a Python sentiment analysis tool, bound by name in RuntimeConfig
  • Exec evals — Python-based tone and quality checks, run via sdk.Evaluate()
  • Exec hooks — a content policy filter (provider/filter) and audit logger (session/observe)
  • Pack stays agnostic — the pack defines tool schemas and eval types by name; it never references Python, file paths, or credentials

Files

agent.pack.json     ← What the agent does (portable, platform-agnostic)
runtime.yaml        ← How to run it (environment-specific bindings)
main.go             ← SDK usage
tools/
  sentiment.py      ← Exec tool: keyword-based sentiment analysis
evals/
  tone-check.py     ← Exec eval: professional tone scoring
  response-quality.py ← Exec eval: word count, completeness, repetition
hooks/
  content-policy.py ← Provider hook (filter): blocks prohibited topics
  audit-logger.py   ← Session hook (observe): logs lifecycle events

Run

# No API keys needed — uses mock provider
go run .

Expected Output

=== Part 1: Conversation with RuntimeConfig ===
Assistant: Mock response from mock model mock-model
Assistant: Mock response from mock model mock-model

=== Part 2: Standalone Evals (exec eval handlers) ===
  [PASS] tone-check           score=1.00  Detected tone: professional ...
  [PASS] response-quality     score=1.00  Quality score: 1.00 — no issues found

=== Part 3: Eval a poor response ===
  [PASS] tone-check           score=0.70  Detected tone: professional ...
  [FAIL] response-quality     score=0.30  Quality score: 0.30 — issues: too short ...

=== Part 4: Inline evals with exec handlers ===
  [PASS] custom-tone          score=0.90  Detected tone: professional ...
  [PASS] has-greeting         score=0.67  missing patterns: hi

How It Works

  1. The pack (agent.pack.json) defines a sentiment_analysis tool with a JSON schema, and two evals (tone_check, response_quality) by type name
  2. The RuntimeConfig (runtime.yaml) binds those names to Python scripts
  3. At runtime, the SDK spawns Python subprocesses per invocation — JSON on stdin, JSON on stdout
  4. The pack never knows whether implementations are Go, Python, HTTP, or anything else

Documentation

Overview

Package main demonstrates RuntimeConfig with external tools, evals, and hooks.

This example shows:

  • Declarative SDK setup via sdk.WithRuntimeConfig() (one line replaces 50+ lines of Go)
  • Exec tools: a Python sentiment analysis tool bound via RuntimeConfig YAML
  • Exec evals: Python-based tone and quality checks, evaluated with sdk.Evaluate()
  • Exec hooks: a content policy filter (provider/filter) and audit logger (session/observe)
  • The pack defines tool/eval names; RuntimeConfig binds them to Python scripts

The pack is platform-agnostic — it never knows whether tools/evals are Go, Python, or HTTP. The RuntimeConfig is environment-specific — swap runtime.yaml per environment.

Run with:

go run .

No API keys needed — uses a mock provider.

Jump to

Keyboard shortcuts

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