Skip to content

Instantly share code, notes, and snippets.

View clutchski's full-sized avatar

Matt Perpick clutchski

View GitHub Profile
@clutchski
clutchski / test_litellm.py
Created March 27, 2026 16:55
ADK Python + Braintrust Gateway: LlmAgent with LiteLLM, parallel tool use across providers
"""Test ADK LlmAgent with LiteLLM through the Braintrust gateway.
Uses LlmAgent (not raw model calls) with tools, routing all providers
through the Braintrust gateway via LiteLLM's api_base parameter.
"""
import asyncio
import datetime
import os
from zoneinfo import ZoneInfo
@clutchski
clutchski / test_agent.py
Created March 26, 2026 20:36
ADK Python + Braintrust Gateway: Gemini class calling 3 providers (Gemini, Claude, GPT)
"""Test multiple models through the Braintrust gateway using ADK's Gemini class.
The gateway handles protocol translation, so we route Gemini through
the gateway and it can call any provider's models.
"""
import asyncio
import os
from functools import cached_property
@clutchski
clutchski / test_tools.py
Created March 26, 2026 20:26
ADK Python + Braintrust Gateway: parallel tool use bug repro
"""Test tool use with multiple models through the Braintrust gateway.
Known bug: OpenAI models fail on parallel tool calls -- tool_call_id mismatch
on the second turn when the gateway translates back from Anthropic format.
"""
import os
os.environ["ANTHROPIC_BASE_URL"] = "https://gateway.braintrust.dev"
os.environ["ANTHROPIC_API_KEY"] = os.environ["BRAINTRUST_API_KEY"]
@clutchski
clutchski / test_agent.py
Created March 26, 2026 20:26
ADK Python + Braintrust Gateway: simple multi-provider calls (no tools)
"""Test multiple models through the Braintrust gateway using ADK's AnthropicLlm.
The gateway handles protocol translation, so we use AnthropicLlm for both
Anthropic and OpenAI models.
"""
import os
os.environ["ANTHROPIC_BASE_URL"] = "https://gateway.braintrust.dev"
os.environ["ANTHROPIC_API_KEY"] = os.environ["BRAINTRUST_API_KEY"]
@clutchski
clutchski / test_agent.py
Created March 26, 2026 20:26
ADK Python + Braintrust Gateway: multi-provider model calls
"""Test multiple models through the Braintrust gateway using ADK's AnthropicLlm.
The gateway handles protocol translation, so we use AnthropicLlm for both
Anthropic and OpenAI models.
"""
import os
os.environ["ANTHROPIC_BASE_URL"] = "https://gateway.braintrust.dev"
os.environ["ANTHROPIC_API_KEY"] = os.environ["BRAINTRUST_API_KEY"]
@clutchski
clutchski / gist:209af31eb8899334e09b9738204e9f9d
Last active October 10, 2025 20:18
braintrust-go-sdk-v0.0.11-v0.0.12-migration-guide

Braintrust-x-Go Migration Guide: v0.0.11 to v0.0.12

There are a few backwards incompatible changes in v0.0.12. Here's a guide to quickly resolving the issues.

TL;DR: Use eval.Run()

The simplest migration is to use eval.Run() instead of eval.New(). eval.Run() exists in both v0.0.11 and v0.0.12 and is unaffected by the changes.

func main() {
import argparse
from collections import defaultdict
import os
import sys
import time
import requests
import json
@clutchski
clutchski / headers.rb
Last active June 7, 2019 20:24
two methods for adding custom headers in ruby / rails
#
# If you wna to copy headers directly onto tags as spans, there's a short hand method
# that works via configuration.
#
Datadog.configure do |c|
c.use :rack, headers: {
request: [
'x-customer-mobile-screen',
'x-customer-mobile-userflow'
https://meetings.webex.com/collabs/meetings/join?uuid=M2PIP2E2WX4UHWZENIOGYAOJ7E-SVEP
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4e3777]
goroutine 75260 [running]:
github.com/DataDog/dd-go/trace/dogtrace.closeChildAndAppend(0xc2238df5f0, 0xc22e3b9d40)
/home/jenkins/workspace/lamar-prod/src/github.com/DataDog/dd-go/trace/dogtrace/span.go:76 +0x282
github.com/DataDog/dd-go/trace/dogtrace.(*Span).Layer(0xc2238df5f0, 0xbc11d0, 0x6, 0xc217bc5ba8)
/home/jenkins/workspace/lamar-prod/src/github.com/DataDog/dd-go/trace/dogtrace/span.go:91 +0xf4
main.(*Lamar).GetActiveContexts(0xc2080bc700, 0xc2238df5f0, 0x1b4b, 0x1d9204b, 0x56451b1c, 0x56452350, 0x0, 0x0, 0x0, 0x0, ...)
/home/jenkins/workspace/lamar-prod/src/github.com/DataDog/dd-go/apps/lamar/core.go:119 +0x31f