work
15 次代码提交
| 作者 | SHA1 | 备注 | 提交日期 | |
|---|---|---|---|---|
|
|
7a0ca65b68 | Expose agent run IDs on responses (#3044) | ||
|
|
5e9accfd45 | Add agent OpenTelemetry run observability (#3027) | ||
|
|
ab2c092693 | Add agent model retry and timeout resilience (#3017) | ||
|
|
3e885308a0 |
lint: clear the golangci-lint backlog and enforce a blocking lint in CI (#2995)
Fixes #2988. Brings 'golangci-lint run ./...' to zero issues (was ~373): - errcheck: explicitly ignore fire-and-forget calls with '_ =' (and a small errcheck.exclude-functions list for response writes — json Encoder.Encode, http ResponseWriter.Write, fmt.Fprint*); genuine cases handled. - unused: remove dead code (unexported decls and dead test helpers) and the imports they orphaned. - staticcheck: ST1005 error strings, ST1016 receiver names, S1000/S1017/S1019/ S1023 simplifications, SA4004/SA4006/SA4010 dead code, SA1021 net.IP.Equal, SA6002 (store *[]byte in sync.Pool). - govet: fix a context leak (lostcancel) in internal/util/mdns and move t.Fatal/Fatalf out of goroutines (testinggoroutine) in tests. - ineffassign, unconvert: mechanical fixes. CI: the Lint workflow now runs a blocking full-tree 'golangci-lint run' on pushes and PRs (dropped only-new-issues now that the tree is clean). Verified: go build, go vet, test compilation, and unit tests for the behaviourally-touched packages all pass. Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
ca87efef2f |
feat(agent): expose run metadata + structured guardrail reasons to tool wrappers (#2981)
goreleaser / goreleaser (push) Has been cancelled
Closes the remaining ask in #2980 without adding a parallel callback API. ToolResult.Refused tags a guardrail block with a reason (ai.RefusedLoop / RefusedMaxSteps / RefusedApproval) so a wrapper can switch on it instead of parsing the message. ai.RunInfo (RunID, ParentID, Agent) rides on the context passed to the tool handler, giving wrappers run correlation and delegation lineage. Before/after/retry/failure were already covered by AgentWrapTool; this adds the metadata. Docs + tests included. Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
c7657f73f4 |
Refactor agent plan storage, update docs, and release v6 (#2977)
goreleaser / goreleaser (push) Has been cancelled
* test(harness): read agent plan from the scoped store
The store-scoping change moved an agent's plan from the default table
key agent/{name}/plan to its own table (database "agent", table {name},
key "plan"). The plan-delegate harness tests still read the old key and
failed with 'not found'; read through store.Scope(mem, "agent", name)
like the agent does.
* docs: orient agents-first across README, landing, and docs overview
Lead with agents (then services and flows), surface MCP + A2A as the
interop story, and frame agents as services. Landing hero and feature
grid reordered agents-first with an A2A gateway card.
* v6: module path go-micro.dev/v6, TLS secure by default, NewService
Cut v6. Three breaking changes, bundled so the major bump is paid once:
- Module path go-micro.dev/v5 -> go-micro.dev/v6 across all imports + go.mod.
- TLS verification on by default (was off). MICRO_TLS_SECURE removed;
MICRO_TLS_INSECURE=true opts out for self-signed/dev.
- micro.NewService(name, opts...) is the canonical service constructor,
symmetric with NewAgent/NewFlow; micro.New kept as a deprecated alias;
the old name-less NewService(opts...) removed. Generators emit NewService.
Also ports the JWT auth token provider in-module (go-micro.dev/v6/auth/jwt/token
on golang-jwt/jwt/v5), dropping the v5-pinned github.com/micro/plugins/v5/auth/jwt
and the deprecated dgrijalva/jwt-go.
Docs/README/landing updated to v6 and @latest; v5->v6 migration guide added;
CHANGELOG cut as [6.0.0]. Blog posts left at their historical versions.
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
f42c9d1d69 |
feat(a2a): agents can serve A2A directly, no gateway required (#2975)
Refactor the A2A handler into a reusable dispatcher + Invoke seam and expose NewAgentHandler(card, invoke) + Card(). An agent now serves its own A2A endpoint with AgentA2A(addr) / WithA2A — handling tasks in-process (no RPC hop, no separate gateway). The gateway and embedded agent share the same handler; the only difference is RPC vs in-process invocation. Docs, README, and changelog cover both deployment modes. Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
9fdcc24cce |
Implement durable execution and scoped state management for flows (#2972)
* docs: design note for flow steps + Checkpoint durable execution
* docs: fold in durable-execution decisions (State struct, single Step, run retention, retry)
* docs: rename State.Payload to State.Data
* feat(flow): ordered steps + Checkpoint durable execution
A flow can now be an ordered list of steps (a task with stages) instead
of a single LLM turn. State carries typed Data plus a Stage marker; each
step is checkpointed before and after via a pluggable Checkpoint
(store-backed by default), so a run survives a crash and resumes where it
stopped without re-running completed steps. Flow-level Retry with a
per-step override; runs retained for audit unless DeleteOnSuccess.
Step actions: Call (RPC), LLM (augmented turn), Dispatch (to an agent),
or any StepFunc. Single-step and agent-dispatch flows are unchanged.
* feat(flow): top-level re-exports + durable flow example
Expose the step/checkpoint API from the micro package (FlowSteps,
FlowStep, FlowState, FlowRetry, FlowWithCheckpoint, FlowCall/LLM/Dispatch,
Checkpoint, StoreCheckpoint) and add a runnable, key-free example
demonstrating crash + resume.
* docs: document durable flow steps (guide, README, CLI help)
* docs: blog post + changelog for durable workflows
* fix(flow): scope checkpoint keys by flow name (flow/{name}/runs/{id})
Run keys were flow/runs/{id} — a single global keyspace shared by every
flow on the default store. Namespace them by flow name so each flow's
state is kept apart. StoreCheckpoint now takes a scope argument (the flow
passes its name by default).
* feat(store): Scope handle; scope agent and flow state by name
Add store.Scope(s, database, table) — a store handle that confines every
operation to a database/table without mutating the shared store, so
co-located components don't clobber each other's table (the failure mode
of the global Init(Table(...)) approach).
Use it to keep each agent's memory and plan in its own table
(agent/{name}) and each flow's runs in its own (flow/{name}), instead of
one global table partitioned only by key prefix. Services already scope
by service name.
* feat: consistent state model — service store scoping, flow registry, list/history CLI
- service: scope store via store.Scope (database service / table name),
retiring the Init(store.Table(name)) global-mutation hack; bridge the
default store so handlers using store.DefaultStore stay isolated.
- flow: register in the registry as type=flow while running (with trigger
and step count), deregister on Stop. Live discovery, like agents.
- cli: micro flow list (registry), micro flow runs <name> (durable store),
micro agent history <name> (durable store). list = running, runs/history
= durable, mirroring the service model.
* test: mini-universe end-to-end harness + scheduled GitHub Action
internal/harness/universe boots a small but real go-micro world — four
services, a durable checkout flow that crashes at payment and resumes,
and a guardrailed agent with a tool wrapper reached over RPC — drives the
scenario, asserts the end state (10 checks), and shuts down. Everything
is real except the LLM (mocked), so it's deterministic and needs no key;
-provider anthropic runs it live. Exits non-zero on failure, so it's an
end-to-end test, not just a demo.
Adds .github/workflows/universe.yml (push/PR/daily/dispatch) running the
universe + existing harnesses on the mock provider, plus an opt-in job
that runs live when ANTHROPIC_API_KEY is set. 'make harness' runs them
locally.
* ci: run the live universe job against AtlasCloud (ATLASCLOUD_API_KEY)
* ci: run the live universe job only on schedule or manual dispatch
The deterministic mock job still runs on push/PR/daily; the live
(AtlasCloud) job runs daily and on manual workflow_dispatch only, so
changes don't burn API credits on every PR but can still be checked
against a real model on demand.
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
e079e083da |
feat(agent): loop detection guardrail + document/blog agent guardrails (#2968)
Add LoopLimit: refuse a tool call repeated with identical arguments in one Ask, with a self-heal message so the model changes approach. Catches the no-progress loop that MaxSteps (count) and the gateway circuit breaker (failures) miss. Enforced at the same tool-handler choke point as MaxSteps/ApproveTool; on by default (lenient 3); AgentLoopLimit(0) to disable. Tests cover repeats, distinct calls, disabled, and default-on. Docs: new Agent Guardrails guide (MaxSteps/LoopLimit/ApproveTool, the ApproveTool integration seam for external policy engines, and the gateway's RateLimit/CircuitBreaker), nav + README + AGENT_DESIGN updates, and blog/23 'Agent Guardrails'. Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
9dae4e34b7 |
Enhance README with sponsorship CTA and improve agent architecture (#2961)
* docs: add 'become a sponsor' call-to-action linking to Discord Now that there are a couple of sponsors, invite more: a short CTA under the Sponsors section in the README and on the landing page, pointing to the Discord to get in touch. * fix(health): remove duplicate RegistryCheck declaration Two PRs (#2957 and #2958) each added a RegistryCheck to the health package, leaving the package uncompilable on master (RegistryCheck redeclared: health/registry.go vs health/health.go). Keep the health.go implementation — it honors the check's context timeout so a hung registry (e.g. an unreachable etcd) reports down instead of blocking the probe — and remove the duplicate registry.go and its test. registry_check_test.go already covers healthy/down/nil/timeout/not-ready. * feat(agent): pluggable memory and custom tools Make agents compose the way services do — pluggable pieces with working defaults — by adding the two abstractions an agent needs beyond the model: - Memory: a pluggable interface for conversation memory. The default is store-backed and durable across restarts (the previous hardcoded behavior, now behind an interface); supply your own with WithMemory (in-memory, database, semantic store). NewMemory / NewInMemory provided. - Custom tools: WithTool registers any function as a tool the agent can call, so agents are no longer limited to orchestrating RPC services. Both exposed at the micro package (AgentMemory, AgentTool, NewMemory, NewInMemory). Behavior-preserving refactor of the agent's history into the default Memory; tests cover persistence, in-memory, clear, custom tool dispatch and errors. README + AGENT_DESIGN document the pluggable composition (model / memory / tools / guardrails). * blog: 'Doubling Down on Agents' (#20) The vision post for making agents a first-class framework the way services were: opinionated, batteries-included, pluggable. Frames an agent as a composition of model + memory + tools + guardrails with working defaults; introduces the new pluggable memory and custom tools; makes the microagents argument (an agent for everything, distributed like microservices); and lays out the three primitives — services, agents, workflows — as one substrate, with an honest list of the gaps still to fill (knowledge/retrieval, streaming, explicit loop). --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
e416ea4a75 |
Enhance agent workflows with guardrails and documentation updates (#2952)
* docs: map go-micro onto Anthropic's workflows-vs-agents taxonomy - new guide 'Agents and Workflows': adopts Anthropic's Building Effective Agents vocabulary — workflow (predefined path) = flow, agent (dynamic self-direction) = agent — maps the augmented-LLM building block and the five workflow patterns onto go-micro, and shows routing (chat router) and orchestrator-workers (conductor + plan/delegate) are already native. - flow package doc reframed as a workflow (predefined path) per the same taxonomy, with guidance on flow vs agent. - nav + README link the new guide. * feat: agent guardrails — step limit and tool approval hook Anthropic's Building Effective Agents stresses stopping conditions and human-in-the-loop checkpoints for autonomous agents. Add both as plain options enforced at the tool-handler choke point — no provider changes, no new abstraction: - MaxSteps(n): bound tool executions per Ask; beyond the limit, actions are refused and the model is told to stop and summarize. - ApproveTool(fn): gate each action before it runs; returning false blocks it and surfaces the reason to the model. The internal plan tool is never gated. Exposed at the micro package (AgentMaxSteps, AgentApproveTool, ApproveFunc). Tests cover the limit, blocking, and that plan is not gated. Guardrails section of the agents-and-workflows guide updated from 'active work' to documented options. * feat: flow can dispatch to an agent (flow triggers, agent reasons) Unify the engine without collapsing the workflow/agent distinction. A Flow with Agent set hands each event's rendered prompt to a named registered agent over RPC (Agent.Chat) instead of running its own LLM step — so the workflow stays the deterministic trigger and the agent is the reasoning engine, with its plan, delegate, memory, and guardrails. A plain flow is unchanged (single augmented-LLM step). - flow.Agent(name) / micro.FlowAgent(name); flow stores the client and skips model setup when dispatching. - test: dispatch routes to comms.Agent.Chat with the rendered prompt and records the reply. - guide: 'Flow triggers, Agent reasons' section. --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
cb33decd97 |
Add built-in plan and delegate tools for agents with examples (#2949)
* feat: add plan and delegate as built-in agent tools Give agents two self-capabilities, expressed as plain tools wired into the existing tool handler — no harness or graph, consistent with "services are the only abstraction": - plan: record/update an ordered plan, persisted to store-backed memory and surfaced in the system prompt on later turns (externalized planning). - delegate: hand a self-contained subtask to another agent. Delegate-first — if the target names a registered agent it is called via RPC; otherwise a focused ephemeral sub-agent is created with agent.New + Ask in a fresh, isolated context (loads/persists no history, no built-in tools, so it cannot re-delegate). Both are added automatically to any non-ephemeral agent, so existing micro.NewAgent services and micro chat routing get them for free. Tests are hermetic (memory store + memory registry). * feat: add agent-plan-delegate example and document plan/delegate - examples/agent-plan-delegate: coordinator that plans multi-step work, creates tasks with its own tools, and delegates notification to a separate registered comms agent over RPC. - integration tests driving the full Ask loop through a fake provider: plan tool exposure + persistence, ephemeral delegation with isolated context, delegate-first RPC routing to a registered agent. - docs: README (Building Agents + features + examples), AGENT_DESIGN (Built-in Capabilities), agent-patterns guide (Pattern 9), CLAUDE.md. * docs: blog post and guide for plan & delegate - blog/17: "Plan & Delegate: Deep Agents in Go" — what the feature is, how plan and delegate work, and a runnable getting-started path. - guides/plan-delegate: reference guide with the smallest-agent snippet, plan/delegate semantics, and the multi-agent example; linked in nav. - example: auto-detect provider/key from common env vars (ANTHROPIC_API_KEY, OPENAI_API_KEY, ...) so 'export KEY && go run main.go' just works. - onboarding: getting-started paths now include go mod init / go get and a clone-and-run path, so a reader can actually run it from a cold start. * refactor: reframe plan/delegate blog and clean up sub-agent construction - blog/17 retitled "Agents That Plan and Delegate" and reframed around intent (plan = state intent, delegate = direct it), positioned as the next beat after blog 15/16 and tied to the existing store + agent RPC rather than re-announcing them. "Deep agents" now a single in-passing nod, matching how blog 14 references LangChain. - agent: add unexported newEphemeral constructor for sub-agents instead of type-asserting the public Agent interface to set an internal field; matches the options-only construction idiom used elsewhere. * feat: expose plan & delegate in the micro chat fallback Add agent.Builtins(opts...) — returns the built-in tools plus a handler, so the plan/delegate capabilities can be wired into a tool loop that isn't a running Agent. micro chat's direct-service fallback now reuses it (single source of truth, no duplicated handler logic), so planning and delegation are available there too, not just for registered agents. Adds a test for the accessor; notes CLI availability in the guide. --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
1bc886fa82 |
Introduce Agent abstraction and integrate with chat router (#2939)
* docs: Agent interface design sketch Proposes Agent as a top-level abstraction alongside Service in the micro package. Agent manages services — scoped tools, system prompt, conversation memory, registry-discoverable. Design only, no implementation. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: Agent as a first-class abstraction Introduce micro.NewAgent() alongside micro.New() — Agent is to intelligence what Service is to capability. Agent interface: - Chat(ctx, message) (*Response, error) — core interaction method - Run() — registers in registry, subscribes to broker, blocks - Stop() — graceful shutdown - Scoped tools — only sees endpoints of its assigned services - Persistent memory — conversation history stored in store - Agent-to-agent — communication via broker topics Top-level API: agent := micro.NewAgent("task-mgr", micro.AgentServices("task"), micro.AgentPrompt("You manage tasks."), micro.AgentProvider("anthropic"), ) agent.Run() https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: wire agents into chat router, add micro agent CLI, expose Flow Three top-level abstractions: micro.New("task") — Service (capability) micro.NewAgent("task-mgr") — Agent (intelligence) micro.NewFlow("onboard-user") — Flow (event-driven orchestration) micro chat as router: - Discovers agents from registry on startup - Single agent: routes directly - Multiple agents: LLM classifies intent, dispatches to right agent via route_to_agent tool - No agents: falls back to current direct-service behaviour - Banner shows discovered agents micro agent CLI: - micro agent list — shows registered agents and their services - micro agent describe <name> — shows agent details from registry https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: move flow to top level, update docs for three abstractions Package structure now consistent: service/ — Service (capability) agent/ — Agent (intelligence) flow/ — Flow (event-driven orchestration) ai/flow/ kept as backward-compatible re-export. Updated across all surfaces: - CLAUDE.md: added agent/ and flow/ to project structure - README: added "Building Agents" section with NewAgent() examples, updated features table (Agents, Flows, Chat router), CLI table (agent list, agent describe), docs links - Website: features grid shows Services, Agents, Flows as the three pillars alongside generation, MCP, and pluggable architecture - micro.go: Flow imported from top-level flow/ package https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * docs: rewrite getting-started, fix ai-integration import paths Getting started now covers all three abstractions: - Service (write handlers, micro run, templates) - Agent (micro.NewAgent, scoped tools, memory, CLI) - Flow (event-driven LLM orchestration) Leads with prompt-based generation, then manual service creation. ai-integration.md: fixed flow import path from go-micro.dev/v5/ai/flow to go-micro.dev/v5/flow, updated stack diagram to show agent/flow/chat. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * blog: Introducing micro.NewAgent() Post 16 — announces Agent as a first-class abstraction. Shows the API (NewAgent, AgentServices, AgentPrompt, AgentProvider), scoped tools, persistent memory, multi-service agents, multi-agent systems, and the three-abstraction comparison table (Service/Agent/Flow). https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: fix agent registration, blog post 16 Agent registration: - Add node with address so mDNS can discover agents - Store type and services in node metadata (mDNS requirement) - Connect broker before subscribing, non-fatal if broker unavailable - Print registration confirmation on Run() Agent/chat discovery: - Check both service-level and node-level metadata for type=agent (mDNS stores metadata on nodes, not services) Blog post 16: "Introducing micro.NewAgent()" — announces the Agent abstraction with code examples, comparison table, multi-agent patterns. Tested end-to-end: micro run → micro agent list discovers the agent → micro chat routes to it → agent calls service endpoints. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: agents are proper services with RPC Chat endpoint Refactored agent to use server.Server instead of fake registry entries. An agent now: - Creates a real RPC server with server.Name(agentName) - Registers an Agent.Chat handler callable via standard RPC - Sets server metadata type=agent, services=x,y for discovery - No more fake addresses or broker hacks micro chat calls agents via RPC (client.Call) instead of creating local agent instances. The registry stays clean — agents are real services with real endpoints. Removed broker dependency from agent options. Agent-to-agent communication is just RPC like everything else. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: agent uses proto-defined RPC interface Added agent/proto/agent.proto with Agent service definition: rpc Chat(ChatRequest) returns (ChatResponse) Agent now implements the generated AgentHandler interface and registers via pb.RegisterAgentHandler. The Chat endpoint is a standard proto-based RPC callable by any go-micro client. Renamed the programmatic API from Chat() to Ask() to avoid collision with the proto handler method name. micro chat calls agents via standard RPC with JSON-encoded request/response — no special types needed on the caller side. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd * feat: generate agent alongside services, update all docs micro run --prompt now generates an agent binary that manages all the generated services. The agent reads MICRO_AI_PROVIDER and MICRO_AI_API_KEY from the environment. micro run propagates these when started with --prompt. Run banner shows services and agents separately. Updated README, getting-started guide, and landing page to show the complete flow: generate → services + agent start → micro chat routes to agent → agent orchestrates services. https://claude.ai/code/session_01QTp4SshuVmLAvvEGJe4TJd --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
8c8380dcd4 | delete agent package | ||
|
|
7faab93f9e | Add agent => bot |