Help us shape the future of Go! Take the 2026 Go Developer Survey

sessioncontext

package
v1.151.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sessioncontext provides read-only tools that let an agent discover previous sessions and pull one in as context for the current session, without the manual export/import (HTML export + @mention) workflow.

The toolset is a metadata stub — the runtime owns the handlers (pkg/runtime/sessioncontext_handlers.go) so they can reach the live session store and exclude the session that is currently running.

Index

Constants

View Source
const (
	ToolNameListSessions = "list_sessions"
	ToolNameReadSession  = "read_session"
)
View Source
const (
	// DefaultListLimit is the number of sessions list_sessions returns when the
	// caller does not specify a limit.
	DefaultListLimit = 20
	// MaxListLimit caps how many sessions list_sessions will return in one call
	// so a large history cannot flood the context window.
	MaxListLimit = 100
	// DefaultMaxChars bounds the size of a rendered transcript so pulling in a
	// long session cannot blow the current context window. When a transcript is
	// larger, the oldest messages are dropped and a note records the omission.
	DefaultMaxChars = 24000
)

Variables

This section is empty.

Functions

func ClampLimit

func ClampLimit(limit int) int

ClampLimit normalizes a caller-supplied limit: non-positive falls back to the default, and anything above the cap is reduced to it.

func CreateToolSet

func CreateToolSet() (tools.ToolSet, error)

func RenderTranscript

func RenderTranscript(h Header, msgs []chat.Message, maxChars int) string

RenderTranscript renders a previous session as a readable transcript. When the rendered text would exceed maxChars, the oldest messages are dropped (the most recent ones are the most useful for continuing work) and a note records how many were omitted. maxChars <= 0 selects DefaultMaxChars.

Types

type Header struct {
	ID          string
	Title       string
	CreatedAt   time.Time
	NumMessages int
}

Header carries the session metadata rendered above a transcript.

type ListSessionsArgs

type ListSessionsArgs struct {
	Limit int `` /* 129-byte string literal not displayed */
}

type ReadSessionArgs

type ReadSessionArgs struct {
	SessionID string `` /* 157-byte string literal not displayed */
}

type SessionInfo

type SessionInfo struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	CreatedAt   string `json:"created_at"`
	NumMessages int    `json:"num_messages"`
	Starred     bool   `json:"starred,omitempty"`
}

SessionInfo is the per-session payload returned by list_sessions.

type ToolSet

type ToolSet struct{}

func New

func New() *ToolSet

New builds a toolset for tests and embedders.

func (*ToolSet) Instructions

func (t *ToolSet) Instructions() string

func (*ToolSet) Tools

func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error)

Tools advertises metadata for handlers implemented by the runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL