@@ -97,7 +97,47 @@ session = await client.create_session({
9797<details >
9898<summary ><strong >Go</strong ></summary >
9999
100- <!-- docs-validate: skip -->
100+ <!-- docs-validate: hidden -->
101+ ``` go
102+ package main
103+
104+ import (
105+ " context"
106+ copilot " github.com/github/copilot-sdk/go"
107+ )
108+
109+ func main () {
110+ ctx := context.Background ()
111+ client := copilot.NewClient (nil )
112+ client.Start (ctx)
113+
114+ session , _ := client.CreateSession (ctx, &copilot.SessionConfig {
115+ Model: " gpt-4.1" ,
116+ CustomAgents: []copilot.CustomAgentConfig {
117+ {
118+ Name: " researcher" ,
119+ DisplayName: " Research Agent" ,
120+ Description: " Explores codebases and answers questions using read-only tools" ,
121+ Tools: []string {" grep" , " glob" , " view" },
122+ Prompt: " You are a research assistant. Analyze code and answer questions. Do not modify any files." ,
123+ },
124+ {
125+ Name: " editor" ,
126+ DisplayName: " Editor Agent" ,
127+ Description: " Makes targeted code changes" ,
128+ Tools: []string {" view" , " edit" , " bash" },
129+ Prompt: " You are a code editor. Make minimal, surgical changes to files as requested." ,
130+ },
131+ },
132+ OnPermissionRequest: func (req copilot.PermissionRequest , inv copilot.PermissionInvocation ) (copilot.PermissionRequestResult , error ) {
133+ return copilot.PermissionRequestResult {Kind: copilot.PermissionRequestResultKindApproved }, nil
134+ },
135+ })
136+ _ = session
137+ }
138+ ```
139+ <!-- /docs-validate: hidden -->
140+
101141``` go
102142ctx := context.Background ()
103143client := copilot.NewClient (nil )
@@ -287,7 +327,51 @@ response = await session.send_and_wait({
287327<details >
288328<summary ><strong >Go</strong ></summary >
289329
290- <!-- docs-validate: skip -->
330+ <!-- docs-validate: hidden -->
331+ ``` go
332+ package main
333+
334+ import (
335+ " context"
336+ " fmt"
337+ copilot " github.com/github/copilot-sdk/go"
338+ )
339+
340+ func main () {
341+ ctx := context.Background ()
342+ client := copilot.NewClient (nil )
343+ client.Start (ctx)
344+
345+ session , _ := client.CreateSession (ctx, &copilot.SessionConfig {
346+ Model: " gpt-4.1" ,
347+ OnPermissionRequest: func (req copilot.PermissionRequest , inv copilot.PermissionInvocation ) (copilot.PermissionRequestResult , error ) {
348+ return copilot.PermissionRequestResult {Kind: copilot.PermissionRequestResultKindApproved }, nil
349+ },
350+ })
351+
352+ session.On (func (event copilot.SessionEvent ) {
353+ switch event.Type {
354+ case " subagent.started" :
355+ fmt.Printf (" ▶ Sub-agent started: %s \n " , *event.Data .AgentDisplayName )
356+ fmt.Printf (" Description: %s \n " , *event.Data .AgentDescription )
357+ fmt.Printf (" Tool call ID: %s \n " , *event.Data .ToolCallID )
358+ case " subagent.completed" :
359+ fmt.Printf (" ✅ Sub-agent completed: %s \n " , *event.Data .AgentDisplayName )
360+ case " subagent.failed" :
361+ fmt.Printf (" ❌ Sub-agent failed: %s — %v \n " , *event.Data .AgentDisplayName , event.Data .Error )
362+ case " subagent.selected" :
363+ fmt.Printf (" 🎯 Agent selected: %s \n " , *event.Data .AgentDisplayName )
364+ }
365+ })
366+
367+ _ , err := session.SendAndWait (ctx, copilot.MessageOptions {
368+ Prompt: " Research how authentication works in this codebase" ,
369+ })
370+ _ = err
371+ }
372+ ```
373+ <!-- /docs-validate: hidden -->
374+
291375``` go
292376session.On (func (event copilot.SessionEvent ) {
293377 switch event.Type {
0 commit comments