docs(agents): add Go language guide#302
Conversation
Co-authored-by: Christopher Gill <chrisraygill@gmail.com>
Co-authored-by: Chris Ray Gill <chgill@google.com>
…der docs (#295) Co-authored-by: chrisraygill <15097183+chrisraygill@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request adds comprehensive documentation for the experimental Agents API in Genkit Go, including code examples for defining agents, tools, HTTP serving, and advanced orchestration. The review feedback correctly identifies compilation errors in the Go code snippets where mux.HandleFunc is used instead of mux.Handle to register an http.Handler on a standard http.ServeMux.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // mount each route onto a standard net/http mux. | ||
| mux := http.NewServeMux() | ||
| for _, route := range genkitx.AgentRoutes(weatherAgent) { | ||
| mux.HandleFunc(route.Pattern(), route.Handler()) |
There was a problem hiding this comment.
In Go's net/http package, mux.HandleFunc registers a handler function for the given pattern, expecting a function with the signature func(http.ResponseWriter, *http.Request). Since route.Handler() returns an http.Handler interface, you should use mux.Handle instead of mux.HandleFunc to avoid a compilation error.
mux.Handle(route.Pattern(), route.Handler())
|
|
||
| // One agent's routes... | ||
| for _, route := range genkitx.AgentRoutes(weatherAgent) { | ||
| mux.HandleFunc(route.Pattern(), route.Handler()) |
There was a problem hiding this comment.
In Go's net/http package, mux.HandleFunc registers a handler function for the given pattern, expecting a function with the signature func(http.ResponseWriter, *http.Request). Since route.Handler() returns an http.Handler interface, you should use mux.Handle instead of mux.HandleFunc to avoid a compilation error.
mux.Handle(route.Pattern(), route.Handler())
|
|
||
| // ...or every registered agent at once. | ||
| for _, route := range genkitx.AllAgentRoutes(g) { | ||
| mux.HandleFunc(route.Pattern(), route.Handler()) |
There was a problem hiding this comment.
In Go's net/http package, mux.HandleFunc registers a handler function for the given pattern, expecting a function with the signature func(http.ResponseWriter, *http.Request). Since route.Handler() returns an http.Handler interface, you should use mux.Handle instead of mux.HandleFunc to avoid a compilation error.
mux.Handle(route.Pattern(), route.Handler())
…/NamedPrompt Match the reworked ai/exp API: FromInline becomes InlinePrompt, and FromPrompt splits into SameNamedPrompt (the prompt named like the agent) and NamedPrompt(name, input) for referencing any registered prompt by name. Adds the shared-prompt-across-agents example.
Mirror the Go API rework: DefineAgent takes an InlinePrompt slice literal and DefinePromptAgent backs an agent with a registry prompt (default same-named, or WithNamedPrompt), aligning the Go guide with the existing JS defineAgent/definePromptAgent split.
No description provided.