惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
博客园_首页
T
Tailwind CSS Blog
美团技术团队
博客园 - 叶小钗
Microsoft Security Blog
Microsoft Security Blog
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
InfoQ
MongoDB | Blog
MongoDB | Blog
The Cloudflare Blog
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Y
Y Combinator Blog

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders
GitHub - Delavalom/graft: Go framework for building AI ag...
2026-04-12 · via Hacker News - Newest: "AI"

Go Reference Go Report Card License: MIT CI

A Go framework for building AI agents and LLM-powered applications. Multi-provider support (OpenAI, Anthropic, Google Gemini, AWS Bedrock), type-safe tools via generics, agent handoffs, guardrails, MCP integration, and graph orchestration — all with zero vendor SDK dependencies.

Why Graft?

Graft LangChainGo Raw API calls
Vendor SDKs None — raw net/http Multiple SDKs You manage HTTP
Type safety Generic tools from Go structs Runtime casting Manual parsing
Agent handoffs Built-in, automatic Manual wiring DIY
Providers OpenAI, Anthropic, Gemini, Bedrock Varies by wrapper One at a time
Guardrails Input, output, and tool validation Limited None
MCP Client + server built-in Not available Not available
Graph orchestration LangGraph-style DAG execution Chain-based None
Durable execution Temporal, Hatchet, Trigger.dev Not available DIY
Dependencies Only OpenTelemetry 50+ transitive deps Depends

Graft is inspired by OpenAI Swarm — lightweight, composable, and designed for Go developers who want full control without framework lock-in.

Install

go get github.com/delavalom/graft

Quick Start

package main

import (
    "context"
    "fmt"
    "os"

    "github.com/delavalom/graft"
    "github.com/delavalom/graft/provider/openai"
)

func main() {
    model := openai.New(
        openai.WithAPIKey(os.Getenv("OPENROUTER_API_KEY")),
        openai.WithBaseURL("https://openrouter.ai/api/v1"),
        openai.WithModel("anthropic/claude-sonnet-4.6"),
    )

    greetTool := graft.NewTool("greet", "Greet someone by name",
        func(ctx context.Context, p struct {
            Name string `json:"name" description:"The person's name"`
        }) (string, error) {
            return fmt.Sprintf("Hello, %s!", p.Name), nil
        },
    )

    agent := graft.NewAgent("assistant",
        graft.WithInstructions("You are a helpful assistant. Use the greet tool when asked to greet someone."),
        graft.WithTools(greetTool),
    )

    runner := graft.NewDefaultRunner(model)
    result, err := runner.Run(context.Background(), agent, []graft.Message{
        {Role: graft.RoleUser, Content: "Please greet Alice"},
    })
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error: %v\n", err)
        os.Exit(1)
    }
    fmt.Println(result.LastAssistantText())
}

Features

  • Multi-provider: OpenAI, Anthropic, Google (Gemini) — all via raw HTTP, no vendor SDKs
  • Type-safe tools: Define tools as typed Go functions with auto-generated JSON schemas
  • Agent handoffs: Route conversations between specialized agents
  • Guardrails: Input validation (max tokens, content filtering) and output validation (JSON schema)
  • MCP integration: Connect to MCP servers as a client, or expose graft tools as an MCP server
  • Graph orchestration: LangGraph-style DAG execution with conditional routing and streaming
  • Session persistence: Multi-turn conversations with memory and file-backed stores
  • Pluggable tracing: Braintrust, LangSmith, OpenTelemetry, or bring your own
  • Durable execution: Temporal, Hatchet, and Trigger.dev integrations
  • Streaming: SSE HTTP handler adapter for real-time responses
  • Provider routing: Fallback and round-robin strategies across providers

Architecture

User messages -> Agent -> Runner.Run() -> LanguageModel.Generate()
  -> Tool calls?  -> Execute tools -> Append results -> Loop back
  -> Handoff?     -> Switch active agent -> Loop back
  -> No tool calls? -> Return Result

Packages

Package Description
graft Core types: Agent, Runner, Tool, Message, Guardrail, Handoff, Hook
provider/openai OpenAI, OpenRouter, Ollama, LM Studio
provider/anthropic Anthropic Messages API
provider/google Google Generative Language API (Gemini)
provider/bedrock AWS Bedrock (Converse API) — Claude, Titan, Llama, Mistral
provider Router (fallback/round-robin) and middleware chain
guardrail Built-in guardrails: MaxTokens, ContentFilter, SchemaValidator
mcp Model Context Protocol client and server
graph Graph-based orchestration with conditional edges
state Session persistence (memory and file stores)
tracing Pluggable tracing: Braintrust, LangSmith, OpenTelemetry
temporal Temporal durable workflow integration
hatchet Hatchet durable function integration
trigger Trigger.dev REST API integration
stream SSE HTTP handler adapter
otel OpenTelemetry instrumentation wrappers

Examples

Example Description
basic Simple agent with a tool
handoff Agent-to-agent routing
streaming HTTP streaming with SSE
multi-provider Fallback across providers
guardrails Input/output validation
mcp-client Connect to an MCP server and use its tools
mcp-server Expose graft tools as an MCP server
graph ReAct graph orchestration
tracing Pluggable tracing with Braintrust
state Persistent multi-turn sessions
temporal Durable execution with Temporal
hatchet Durable functions with Hatchet
trigger Background tasks with Trigger.dev
bedrock AWS Bedrock with Converse API

Run any example:

export OPENROUTER_API_KEY=your-key
go run ./examples/basic/

Design Principles

Functional options everywhere: Consistent API across agents, providers, and runners.

agent := graft.NewAgent("name",
    graft.WithInstructions("..."),
    graft.WithTools(tool1, tool2),
    graft.WithGuardrails(guardrail.MaxTokens(1000)),
)

Type-safe tools: Struct fields become JSON schema automatically.

tool := graft.NewTool("search", "Search for items",
    func(ctx context.Context, p struct {
        Query string `json:"query" description:"Search query"`
        Limit int    `json:"limit" description:"Max results"`
    }) (string, error) {
        // ...
    },
)

Composable runners: Wrap runners to add behavior without changing the agent.

base := graft.NewDefaultRunner(model)
traced := tracing.NewTracedRunner(base, braintrustProvider)
persistent := state.NewSessionRunner(traced, store, sessionID)

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

License

MIT