gopheragent
Health Uyari
- License — License: Apache-2.0
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 5 GitHub stars
Code Gecti
- Code scan — Scanned 10 files during light audit, no dangerous patterns found
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Go/Golang multi-agent LLM framework — ReAct loops, parallel tool calls, streaming, sub-agents, and pluggable Anthropic / OpenAI / Gemini providers.
GopherAgent is a Golang multi-agent LLM framework — deterministic ReAct
loops, parallel tool execution, streaming, sub-agents, and multi-model routing.
Your PM writes a YAML file. Your engineer registers a Go tool. GopherAgent wires
them together at runtime — no recompile, no redeploy.
# agent.yaml — your PM creates this
agent:
name: "Customer Support"
system_prompt: |
You are a customer support agent. Look up orders before answering.
Be polite and concise. Escalate billing issues to a human.
tools_required:
- "lookup_order"
- "web_search"
// main.go — your engineer writes this once
catalog := builder.NewGlobalCatalog()
catalog.Register(&LookupOrderTool{db: db})
catalog.Register(webSearchTool)
loop, _, _, _ := builder.BuildFromYAML("agent.yaml", catalog, provider, nil)
loop.RunIteration(ctx, sessionKey, userMessage)
That's it. Change the YAML, get a different agent. No code changes.
Install
go get github.com/hung12ct/gopheragent
What you get
- YAML-defined agents — file or
//go:embed, with knowledge-base injection. - Skills with progressive disclosure — an Agent Skills
loader over anyio/fs.FS; descriptions sit in the prompt, full instructions
load only when a skill is used. - Deterministic ReAct loop — dependency-aware parallel tool scheduling with
<output_of:ID>refs, anti-loop detection, token-budget-aware pruning, and a
prompt-cache-friendly history window with incremental compaction
(WithHistoryWindow+WithCompactor) that keeps months-long sessions at a
flat request size without losing the thread. - Streaming & HITL — SSE streaming, human approvals (durable across
restarts withDeferApprovals+Resume), plan mode, and self-critique
that keeps the best-scoring pass instead of the last one. - Honest terminals — a
context_traceevent says exactly which messages
pruning rewrote and why; adegradedterminal reports "the artifact landed,
the bookkeeping did not" instead of forcing a turn into success or failure. - Custom tools — one interface, schema derived from a Go struct; a middleware
chain for logging, timing, rate limiting, and tracing. - MCP servers —
pkg/tools/mcptoolsturns any MCP server's tools into
registry tools, approval-gated by default and bounded against oversized
listings, schemas and results. - Multi-provider — OpenAI, Anthropic, Gemini, Vertex, OpenRouter, and OpenAI-compatible
backends, each in its own subpackage; multi-model routing; sampling controls. - Speech to text —
pkg/audiotranscribes with Whisper or Gemini behind one
interface, ahead of the loop, so any provider can drive an audio-fed agent and
a long recording is uploaded once rather than re-sent every turn. - Sub-agents & async — sub-agent streaming, conversation forking, background
workers, first-class task tracking. - Cross-session memory — a post-session consolidator distills transcripts
into notes the loader prepends to future sessions. - Observability — OpenTelemetry traces + metrics (one trace per turn, nested
LLM/tool spans, GenAI-convention token metrics, W3C trace propagation),
zero-cost and export-off until an endpoint is configured. - Audit log (experimental) —
pkg/auditlogships who-did-what records (tool runs,
approvals, policy verdicts, data changes) over OTLP logs — validated,
HMAC-signed and sequenced for tamper detection, blocking or batched,
optionally fail-closed. - Evaluation — grade trajectory + answer + HITL with
pkg/evaland a
CI-readygopherevalsCLI.
MCP servers
pkg/tools/mcptools connects to a Model Context Protocol
server over any SDK transport (stdio, streamable HTTP, in-memory) and registers
its tools. It is a separate package, so programs that don't import it don't
link the MCP SDK.
s, err := mcptools.Connect(ctx, &mcp.CommandTransport{Command: exec.Command("my-mcp-server")},
mcptools.WithPrefix("fs_"))
if err != nil {
return err
}
defer s.Close()
if err := s.RegisterAll(ctx, reg); err != nil {
log.Printf("some MCP tools were skipped: %v", err) // the valid ones are registered
}
- Approval by default. Every remote tool requires confirmation: configure
agent.WithHITLor aPermissionAllowrule, or calls are auto-denied. Tool
descriptions and results come from the server, so treat them as untrusted
input that may attempt prompt injection.WithRequireApproval(false)lifts
the gate; withWithSpeculativeToolsremote tools the server marksreadOnlyHintmay then run speculatively. The hint is the server's claim:
a server that lies about it gets an abandoned call executed anyway. - Prefix untrusted servers with
WithPrefixso their names cannot collide
with local tools. - One-time snapshot. Tools are listed once; list-changed notifications are
ignored deliberately so the tool set (and the provider prompt cache) stays
stable. Rebuild the registry yourself if you need updates. - Bounded. 512 tools, 64 KiB per tool definition and 256 KiB per result by
default (WithLimits); for very large servers put atools.Selectorin front.
Documentation
| Guide | Use it for |
|---|---|
| Getting started | Install, the YAML builder, persistent sessions |
| Tools | Built-in tools, writing custom tools, middleware |
| Skills | Progressive disclosure — catalog in the prompt, instructions on demand |
| Permissions & HITL | Confirmation gates, permission DSL, autonomous approvals |
| Providers | Providers, multi-model routing, sampling, multimodal |
| Observability | OpenTelemetry traces & metrics, collectors, debugging a conversation |
| Audit log | Who-did-what audit events over OTLP: setup, agent integration, event schema |
| Evaluation | Grade an agent with pkg/eval + gopherevals |
Full API reference: pkg.go.dev.
Examples
| Example | What it shows |
|---|---|
examples/demo |
Full chat UI — web research, memory sidebar, Python execution, live HITL, SSE streaming, OTLP export |
examples/agent_eval |
Agent evaluation — trajectory + answer + judge graders, JUnit/Markdown reports, CI gate |
examples/creative_studio |
AI Creative Director — DALL-E 3 images + Veo 2 video clips generated inline |
examples/media_chat |
Media Q&A — upload image/video/doc, native multimodal history, multi-turn references |
examples/hitl_server |
Human-in-the-loop approvals over HTTP (async bridge) |
examples/mcp_client |
MCP server tools in a registry — in-process server, prefixing, HITL-gated agent calls |
examples/yaml_agents |
Multiple YAML-defined agents sharing a catalog, plus a skills-driven assistant |
cd examples/demo
printf "LLM_PROVIDER=openai\nOPENAI_API_KEY=sk-...\n" > .env
go run .
# open http://localhost:8888
License
Apache 2.0
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi