MCPcopy Index your code
hub / github.com/github/copilot-sdk / Send

Method Send

go/session.go:402–426  ·  view source on GitHub ↗

Send sends a message to this session and waits for the response. The message is processed asynchronously. Subscribe to events via [Session.On] to receive streaming responses and other session events. Parameters: - options: The message options including the prompt and optional attachments. Returns

(ctx context.Context, options MessageOptions)

Source from the content-addressed store, hash-verified

400// log.Printf("Failed to send message: %v", err)
401// }
402func (s *Session) Send(ctx context.Context, options MessageOptions) (string, error) {
403 traceparent, tracestate := getTraceContext(ctx)
404 req := sessionSendRequest{
405 SessionID: s.SessionID,
406 Prompt: options.Prompt,
407 DisplayPrompt: options.DisplayPrompt,
408 Attachments: options.Attachments,
409 Mode: options.Mode,
410 AgentMode: options.AgentMode,
411 Traceparent: traceparent,
412 Tracestate: tracestate,
413 RequestHeaders: options.RequestHeaders,
414 }
415
416 result, err := s.client.Request(ctx, "session.send", req)
417 if err != nil {
418 return "", fmt.Errorf("failed to send message: %w", err)
419 }
420
421 var response sessionSendResponse
422 if err := json.Unmarshal(result, &response); err != nil {
423 return "", fmt.Errorf("failed to unmarshal send response: %w", err)
424 }
425 return response.MessageID, nil
426}
427
428// SendPrompt is a convenience wrapper for [Session.Send] that takes a plain
429// prompt string instead of a [MessageOptions] struct. Equivalent to:

Callers 2

SendPromptMethod · 0.95
SendAndWaitMethod · 0.95

Calls 2

getTraceContextFunction · 0.70
RequestMethod · 0.45

Tested by

no test coverage detected