Documentation
¶
Overview ¶
Package selection defines the externalized selector interface that narrows a candidate set of skills or tools down to the items most relevant for the current turn.
PromptKit owns pack semantics (eligibility, query derivation, when to select, fallback on error). A Selector owns the ranking algorithm: it may use embeddings, a rerank service, BM25, an LLM judge, or plain rules. PromptKit hands it a query and candidates and receives IDs. No vectors or scores cross the interface boundary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
Candidate describes one item a Selector may choose to surface. IDs are stable identifiers (skill name, tool name); the rest is descriptive context for the ranker.
type ExecClient ¶
type ExecClient struct {
// contains filtered or unexported fields
}
ExecClient is a Selector that delegates ranking to an external process. Spawning goes through a Sandbox so the process can run on-host, in a sidecar, or wherever the sandbox dictates.
func NewExecClient ¶
func NewExecClient(cfg ExecClientConfig) *ExecClient
NewExecClient constructs an ExecClient from the given config. Sandbox defaults to the built-in direct backend when nil.
func (*ExecClient) Init ¶
func (c *ExecClient) Init(SelectorContext) error
Init is a no-op for ExecClient. The subprocess owns whatever resources it needs; PromptKit holds no state on its behalf.
func (*ExecClient) Name ¶
func (c *ExecClient) Name() string
Name returns the configured selector name.
func (*ExecClient) Select ¶
Select serializes the request, spawns the subprocess via the sandbox, and parses selected IDs from stdout. On any failure (process error, timeout, invalid JSON) it returns the error unchanged; callers are expected to treat a non-nil error as "include all eligible" rather than crashing the conversation.
type ExecClientConfig ¶
type ExecClientConfig struct {
Name string
Command string
Args []string
Env []string
TimeoutMs int
Sandbox sandbox.Sandbox
}
ExecClientConfig configures an exec-backed Selector. The subprocess reads a single JSON object on stdin and writes a JSON object on stdout (see wire protocol below). When Sandbox is nil, the built-in direct backend is used.
type Query ¶
type Query struct {
Text string
Kind string // "skill" | "tool"
PackID string
AgentID string
K int // desired max results; selector may return fewer
}
Query carries the context PromptKit has assembled for this selection round. Kind distinguishes skills from tools so one Selector implementation can serve both hook points.
type Selector ¶
type Selector interface {
Name() string
Init(ctx SelectorContext) error
Select(ctx context.Context, q Query, candidates []Candidate) ([]string, error)
}
Selector narrows a candidate set. Returning an error or an empty result tells PromptKit to fall back to "include all eligible"; Selectors must never panic. Implementations should be safe for concurrent use.
type SelectorContext ¶
type SelectorContext struct {
Embeddings providers.EmbeddingProvider
}
SelectorContext is handed to Init. It carries shared infrastructure selectors may opt into — most notably the configured embedding provider, so in-process selectors can reuse the same instance RAG uses instead of constructing their own. Any field may be nil.