File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -579,6 +579,13 @@ func WithParentID(parentID string) Opt {
579579 }
580580}
581581
582+ // WithID sets the session ID. If not set, a UUID will be generated.
583+ func WithID (id string ) Opt {
584+ return func (s * Session ) {
585+ s .ID = id
586+ }
587+ }
588+
582589// WithExcludedTools sets tool names that should be filtered out of the agent's
583590// tool list for this session. This prevents recursive tool calls in skill
584591// sub-sessions.
@@ -647,11 +654,7 @@ func (s *Session) OwnCost() float64 {
647654
648655// New creates a new agent session
649656func New (opts ... Opt ) * Session {
650- sessionID := uuid .New ().String ()
651- slog .Debug ("Creating new session" , "session_id" , sessionID )
652-
653657 s := & Session {
654- ID : sessionID ,
655658 CreatedAt : time .Now (),
656659 SendUserMessage : true ,
657660 }
@@ -660,6 +663,12 @@ func New(opts ...Opt) *Session {
660663 opt (s )
661664 }
662665
666+ if s .ID == "" {
667+ s .ID = uuid .New ().String ()
668+ }
669+
670+ slog .Debug ("Creating new session" , "session_id" , s .ID )
671+
663672 return s
664673}
665674
You can’t perform that action at this time.
0 commit comments