Documentation
¶
Index ¶
- func AppendSystemPromptExtra(ctx context.Context, text string) context.Context
- func WithSkillCatalog(ctx context.Context, catalog SkillCatalog) context.Context
- func WithSystemPromptExtra(ctx context.Context, text string) context.Context
- func WithWorkspaceID(ctx context.Context, workspaceID string) context.Context
- func WorkspaceIDFrom(ctx context.Context) (string, bool)
- type Assembler
- type AttachmentPreparer
- type Config
- type RankedSkill
- type RealizedSkill
- type SkillBodyResolver
- type SkillCandidate
- type SkillCatalog
- type SkillListMode
- type SkillRelevanceProvider
- type SkillRelevanceRequest
- type SkillRelevanceResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendSystemPromptExtra ¶
AppendSystemPromptExtra adds a distinct, high-salience per-turn instruction without discarding one already installed by the caller. Re-adding the same instruction is a no-op, which matters for contexts inherited by subagents.
func WithSkillCatalog ¶ added in v0.0.2
func WithSkillCatalog(ctx context.Context, catalog SkillCatalog) context.Context
WithSkillCatalog installs a defensive copy of the workspace-resolved skill listing for prompt assembly.
func WithSystemPromptExtra ¶
WithSystemPromptExtra carries per-turn caller-supplied system-prompt text on ctx (e.g. an agent.synthesize one-shot's options.system/instructions). The assembler renders it as the last, highest-salience system-prompt section. A general seam — the distribution sets it per turn; empty text -> no-op. Mirrors the other per-turn ctx seams (WithEphemeral / WithExcludedTools).
func WithWorkspaceID ¶ added in v0.0.2
WithWorkspaceID carries the resolved logical workspace into prompt assembly. The turn runner installs it after applying its configured default.
Types ¶
type Assembler ¶
type Assembler struct {
// contains filtered or unexported fields
}
func NewAssembler ¶
func (Assembler) Build ¶
func (a Assembler) Build(ctx context.Context, bootstrap []bootstrap.File, history []protocol.ChatMessage) ([]protocol.ChatMessage, error)
type AttachmentPreparer ¶
type AttachmentPreparer interface {
PrepareAttachments(ctx context.Context, messages []protocol.ChatMessage) ([]sysprompt.AttachmentSummary, error)
}
AttachmentPreparer materializes the non-image files referenced in the turn's messages (side effect: blobs to disk) and returns their summaries for the system prompt, so the model is told what it was given and can open it with its file tools. Images are handled separately by the turn.AttachmentResolver, not here. The oss core ships no implementation (it can't fetch a vfs_ref); a distribution wires one over its own transport. A nil provider -> no attachment section (today's behavior). A returned error is non-fatal: Build logs it and omits the section rather than failing the turn.
type Config ¶
type Config struct {
MaxHistoryMessages int
MaxTextPartBytes int
// MaxContextTokens, when > 0, caps the estimated tokens of the assembled
// context (system prompt + history). History is trimmed to fit the budget
// remaining after the system prompt. 0 disables token budgeting (count/byte
// caps still apply, plus the turn loop's reactive overflow recovery).
MaxContextTokens int
// Compactor, when set, is the pluggable strategy used to fit history to the
// per-call budget (evict/summarize/classic composites). nil -> the historical
// ReduceWithReport drop-oldest behavior, byte-for-byte unchanged.
Compactor compaction.Compactor
// InvokedSkillTTL bounds how many turns a load_skill invocation stays listed
// in the "## Loaded skills" prompt section. 0 -> defaultInvokedSkillTTL.
InvokedSkillTTL int
// AttachmentPreparer, when set, materializes the current turn's non-image
// attachments and returns their summaries for the "## Attached documents/files"
// prompt sections. nil -> no attachment section (today's behavior).
AttachmentPreparer AttachmentPreparer
// PromptNotes is the selected authoritative source of reusable workspace
// instructions. nil disables the section. Provider and validation failures
// fail prompt assembly rather than silently dropping or cross-falling back.
PromptNotes promptnotes.WorkspaceProvider
// SkillRelevance, when set, ranks/selects the skills listed each turn and may
// nominate skills to auto-realize (inject their body). nil -> the full Skills
// catalog is listed in the cacheable prefix and nothing is auto-realized.
SkillRelevance SkillRelevanceProvider
// SkillBodies resolves a skill's body for auto-realization. nil -> auto-realize
// is disabled even when a provider nominates skills. Typically the skill registry.
SkillBodies SkillBodyResolver
// AutoRealizeStaleTurns: a nominated skill already loaded via load_skill within
// this many turns is considered still in-context and is NOT re-injected (dedup).
// 0 -> defaultAutoRealizeStaleTurns.
AutoRealizeStaleTurns int
// MaxAutoRealizeBytes caps the total body bytes injected by auto-realize per
// turn. 0 -> defaultMaxAutoRealizeBytes.
MaxAutoRealizeBytes int
// System-prompt inputs (see internal/sysprompt).
Base string
Tools []sysprompt.ToolSummary
Subagents bool // spawn_subagent available → emit delegation guidance
// SkillLoadTool reports that the load_skill tool is registered, so the skills
// listing instructs the model to load by name (not read_file the path).
SkillLoadTool bool
Skills []sysprompt.SkillSummary
// SkillLoadWarnings surfaces the untrusted skill-load warnings collected by
// skills.DiscoverWithWarnings (malformed name, over-cap SKILL.md, dropped
// duplicate). Rendered as an escaped, explicitly-untrusted prompt section.
SkillLoadWarnings []string
MemoryTools bool
MaxFileBytes int
WorkspaceDir string
Model string
SandboxID string
Now func() time.Time
}
type RankedSkill ¶
RankedSkill is one entry in a provider's relevance listing. Note is an optional short hint surfaced next to the skill in the prompt ("matches the current task").
type RealizedSkill ¶
RealizedSkill is a skill whose body is (or recently was) in context because it was loaded via load_skill, with its age in turns (0 = this turn). The provider uses it to avoid re-nominating already-loaded skills; the assembler uses it to dedup auto-realization (a fresh, already-loaded skill is not re-injected).
type SkillBodyResolver ¶
SkillBodyResolver returns a skill's SKILL.md body by name for auto-realization. The harness's skill registry satisfies it. A nil resolver disables auto-realization even when a provider nominates skills.
type SkillCandidate ¶
SkillCandidate is one skill the model may use, as the provider sees it: the listing metadata only (name + description), never the body — relevance is judged from the description and the conversation, and bodies are large.
type SkillCatalog ¶ added in v0.0.2
type SkillCatalog struct {
Skills []sysprompt.SkillSummary
Bodies SkillBodyResolver
LoadWarnings []string
}
SkillCatalog is the workspace-resolved skill surface for one turn. It overrides the assembler's static/default catalog only on the context carrying it, so one long-lived runner can safely serve multiple logical workspaces.
type SkillListMode ¶
type SkillListMode int
SkillListMode controls how a provider's ranked listing interacts with the full catalog in the prompt.
const ( // ListRefine reorders the catalog by the ranked order and annotates the ranked // entries; catalog skills the provider did not rank still appear, after. ListRefine SkillListMode = iota // ListReplace shows ONLY the ranked skills; unranked catalog skills are hidden. ListReplace )
type SkillRelevanceProvider ¶
type SkillRelevanceProvider interface {
RankSkills(ctx context.Context, req SkillRelevanceRequest) (SkillRelevanceResult, error)
}
SkillRelevanceProvider selects and ranks the skills relevant to the current turn, and may nominate skills to auto-realize (inject their body into context without a load_skill tool call). It is the seam a MemoryLayer-backed strategy plugs into; the default (nil provider) lists the full catalog and auto-realizes nothing — unchanged behavior.
Implementations should be fast and best-effort: RankSkills errors are swallowed by the assembler, which falls back to the full catalog listing. Ranking must not mutate the request.
type SkillRelevanceRequest ¶
type SkillRelevanceRequest struct {
// Available is the full catalog the model may use (listing metadata only).
Available []SkillCandidate
// History is the recent conversation the provider judges relevance against.
History []protocol.ChatMessage
// Realized names skills already loaded via load_skill this session, with age.
Realized []RealizedSkill
// Turn is the in-flight turn number (monotonic, survives compaction).
Turn int
}
SkillRelevanceRequest is the per-turn input to a provider.
type SkillRelevanceResult ¶
type SkillRelevanceResult struct {
// Listed, when non-empty, is the relevance-ordered listing for the prompt's
// skills section. Empty preserves the full catalog listing unchanged.
Listed []RankedSkill
// Mode decides how Listed interacts with the full catalog (refine vs replace).
Mode SkillListMode
// Realize names skills to inject (body) this turn. The assembler resolves each
// body via the SkillBodyResolver, skips any that are already realized+fresh
// (dedup) or unresolvable, and caps the total injected bytes — so a provider
// may nominate freely.
Realize []string
// Suppressed counts catalog skills the provider omitted from Listed because they
// are prerequisites of a shown skill (they auto-load with it). The assembler
// excludes these from the "+N more available" hint — a covered prerequisite is
// not a coverage gap. 0 when the provider does no prerequisite suppression.
Suppressed int
}
SkillRelevanceResult is a provider's per-turn output.