1// From gollem.nvim/internal/sidecar: a coding agent with the full codetool2// toolset, human-in-the-loop approval, tool events bussed to the editor.3agent := core.NewAgent[string](model, append(4 codetool.AgentOptions(cwd), // edit, grep, bash, LSP, read, write5 core.WithToolApproval[string](approvalFn),6 core.WithEventBus[KafkaMessage](bus), // tool events → editor UI7 core.WithRunCondition[string](core.MaxRunDuration(24 * time.Hour)),8)...)910stream, _ := agent.RunStream(ctx, "remove deprecated call sites")11defer stream.Close()1213// Go 1.23+ iterators. Debounced text deltas repaint the assistant pane.14for text, err := range streamutil.StreamTextDebounced(stream, 50*time.Millisecond) {15 if err != nil { return err }16 editor.SetAssistantPane(text)17}
1// From brainrot-detection: typed structured output, validated at the schema boundary.2type Classification struct {3 IsBrainrot bool `json:"is_brainrot"`4 Confidence string `json:"confidence" jsonschema:"enum=high|medium|low"`5 Reason string `json:"reason"`6}78agent := core.NewAgent[Classification](provider,9 core.WithSystemPrompt[Classification](10 "You are a parental content filter for a 6-year-old..."),11)1213res, _ := agent.Run(ctx, "Title: Skibidi Toilet Ep. 73\nChannel: ...")14if res.Output.IsBrainrot {15 sonos.PlayWarning() // +30% volume over the soundbar16 time.Sleep(10 * time.Second)17 if stillBrainrot() { tv.PowerOff() } // LG WebOS → off18}
1// Streaming: one unified iterator across Anthropic / OpenAI / Vertex.2stream, _ := agent.RunStream(ctx, "Write a haiku about goroutines.")34for ev, err := range stream.StreamEvents() {5 if err != nil { continue }6 d, ok := ev.(core.PartDeltaEvent)7 if !ok { continue }8 switch x := d.Delta.(type) {9 case core.TextPartDelta:10 fmt.Print(x.ContentDelta)11 case core.ToolCallPartDelta:12 log.Printf("args=%s", x.ArgsJSONDelta)13 }14}