GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — harness/sessionprompt.go at main · majorcontext/harness Expand file tree/ Copy pathsessionprompt.goMore file actions 61 lines (56 loc) · 2 KB / Copy pathsessionprompt.goFile metadata and controls61 lines (56 loc) · 2 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 package harness import ( "context" "fmt" "slices" "strings" "sync/atomic" "github.com/majorcontext/harness/internal/prompt" "github.com/majorcontext/harness/internal/session" "github.com/majorcontext/harness/protocol" ) // promptReader returns the function that reads the system prompt of session id as a new session would: the default // segments or the blocks of the override, the skills, and the body of the agent profile. profile is the profile that // the first read uses, when the caller has read it. func (r *Runtime) promptReader(id string, c protocol.SessionCreated, profile *prompt.Profile) func(context.Context) prompt.Info { var first atomic.Pointer[prompt.Profile] first.Store(profile) return func(ctx context.Context) prompt.Info { read := r.prompt(r.listSkills(ctx, id)) if c.SystemBlocks != nil { read.Segments, read.Instructions = slices.Clone(c.SystemBlocks), nil if read.SkillList != "" { read.Segments = append(read.Segments, read.SkillList) } } if c.Agent != "" { if t := strings.Trim(r.profile(c.Agent, first.Swap(nil)).Prompt, "\n"); t != "" { read.Segments = append(slices.Clone(read.Segments), t) } } return read } } // checkBreakpoint fails a session that is created whose cache selection names no block of its system prompt. func (r *Runtime) checkBreakpoint(ctx context.Context, id string, c protocol.SessionCreated, created bool, read func(context.Context) prompt.Info, own session.Ownership) error { i := c.SystemCacheBreakpoint if i == nil || !created { return nil } n := len(c.SystemBlocks) if c.SystemBlocks == nil { n = len(read(ctx).Segments) } if *i < 0 || *i >= n { session.Discard(own, id, r.log) return fmt.Errorf("%w: system_cache_breakpoint must name a system block", ErrInvalidRequest) } return nil } func copySystem(req protocol.CreateSession, c *protocol.SessionCreated) { c.SystemBlocks = slices.Clone(req.SystemBlocks) if req.SystemCacheBreakpoint != nil { i := *req.SystemCacheBreakpoint c.SystemCacheBreakpoint = &i } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |