MCPcopy
hub / github.com/docker/docker-agent / New

Function New

pkg/session/session.go:1020–1039  ·  view source on GitHub ↗

New creates a new agent session

(opts ...Opt)

Source from the content-addressed store, hash-verified

1018
1019// New creates a new agent session
1020func New(opts ...Opt) *Session {
1021 s := &Session{
1022 SendUserMessage: true,
1023 }
1024
1025 for _, opt := range opts {
1026 opt(s)
1027 }
1028
1029 // Generate the ID and creation time after options run so that
1030 // WithClock/WithIDGen (and WithID) can influence them. WithID short-
1031 // circuits the generator when an explicit ID was provided.
1032 if s.ID == "" {
1033 s.ID = s.newID()
1034 }
1035 s.CreatedAt = s.now()
1036
1037 slog.Debug("Creating new session", "session_id", s.ID)
1038 return s
1039}
1040
1041func markLastMessageAsCacheControl(messages []chat.Message) {
1042 if len(messages) > 0 {

Calls 3

newIDMethod · 0.95
nowMethod · 0.95
DebugMethod · 0.80