AddAttachedFile records absPath as a file the user attached to this session. The path must be absolute; relative paths are silently dropped (with a debug log) since they would be ambiguous to sub-agents started in a fresh working directory. Empty paths and duplicates already present in AttachedFiles
(absPath string)
| 722 | // so that delegated agents can read the same files without having to scan the |
| 723 | // workspace or guess from a bare filename. |
| 724 | func (s *Session) AddAttachedFile(absPath string) { |
| 725 | if absPath == "" { |
| 726 | return |
| 727 | } |
| 728 | if !filepath.IsAbs(absPath) { |
| 729 | slog.Debug("ignoring non-absolute attached file path", "session_id", s.ID, "path", absPath) |
| 730 | return |
| 731 | } |
| 732 | s.mu.Lock() |
| 733 | defer s.mu.Unlock() |
| 734 | if slices.Contains(s.AttachedFiles, absPath) { |
| 735 | return |
| 736 | } |
| 737 | s.AttachedFiles = append(s.AttachedFiles, absPath) |
| 738 | } |
| 739 | |
| 740 | // AttachedFilesSnapshot returns a copy of the session's attached file paths. |
| 741 | // Callers may freely mutate the returned slice without affecting the session. |