Documentation
¶
Index ¶
- Constants
- func BuildSystemPrompt(knowledgeBases []*KnowledgeBaseInfo, webSearchEnabled bool, ...) string
- func BuildSystemPromptWithOptions(knowledgeBases []*KnowledgeBaseInfo, webSearchEnabled bool, ...) string
- func GetProgressiveRAGSystemPrompt(cfg *config.Config) string
- func GetPureAgentSystemPrompt(cfg *config.Config) string
- func HistoryAsSent(history []chat.Message, retainRetrievalHistory bool) []chat.Message
- func HistoryTokenBudget(cfg *types.AgentConfig) int
- func WikiGranularityGuidance(granularity string) string
- type AgentEngine
- func (e *AgentEngine) DescribeDataURIImages(ctx context.Context, imageDataURIs []string) []string
- func (e *AgentEngine) EnableSuspension(request json.RawMessage)
- func (e *AgentEngine) Execute(ctx context.Context, sessionID, messageID, query string, ...) (*types.AgentState, error)
- func (e *AgentEngine) GetSkillsManager() *skills.Manager
- func (e *AgentEngine) HasCollaboration() bool
- func (e *AgentEngine) HasPendingInput(ctx context.Context, sessionID, messageID string) bool
- func (e *AgentEngine) RenderUserTurnContent(sessionID, query string) string
- func (e *AgentEngine) RestrictSuspensionToCollaboration()
- func (e *AgentEngine) Resume(ctx context.Context, sessionID, messageID string, llmContext []chat.Message, ...) (*types.AgentState, error)
- func (e *AgentEngine) SetAppConfig(cfg *appconfig.Config)
- func (e *AgentEngine) SetAssistantName(name string)
- func (e *AgentEngine) SetBackgroundRun(run BackgroundRun)
- func (e *AgentEngine) SetCollaboration(b *collaboration.Binding)
- func (e *AgentEngine) SetContextCheckpointSink(sink types.ContextCheckpointSink)
- func (e *AgentEngine) SetImageDescriber(fn ImageDescriberFunc)
- func (e *AgentEngine) SetMemoryPrompt(prompt string)
- func (e *AgentEngine) SetPageContext(page *PageContextInfo)
- func (e *AgentEngine) SetPinnedMentions(mcpServices []*PinnedMCPServiceInfo, skills []*PinnedSkillInfo)
- func (e *AgentEngine) SetQuestionOrigin(origin *QuestionOriginInfo)
- func (e *AgentEngine) SetRunMode(mode types.RunMode)
- func (e *AgentEngine) SetRunNote(note string)
- func (e *AgentEngine) SetSkillsManager(manager *skills.Manager)
- func (e *AgentEngine) SetSteerSink(sink types.SteerSink)
- func (e *AgentEngine) SetWorkspaceLayout(layout sandbox.WorkspaceLayout)
- type BackgroundRun
- type BuildSystemPromptOptions
- type CollaborationDelivery
- type ImageDescriberFunc
- type KnowledgeBaseInfo
- type PageContextAgent
- type PageContextInfo
- type PageContextMCPService
- type PageContextMessage
- type PageContextModel
- type PageContextReference
- type PageContextWikiIssue
- type PageContextWikiPage
- type PendingCall
- type PendingRound
- type PinnedMCPServiceInfo
- type PinnedSkillInfo
- type PlaceholderDefinition
- type QuestionOriginInfo
- type RecentDocInfo
- type RunSnapshot
- type SelectedDocumentInfo
- type SystemPromptSection
Constants ¶
const ( // DefaultAgentTemperature is the default temperature for the agent DefaultAgentTemperature = 0.7 // DefaultAgentMaxIterations is the default maximum number of iterations for the agent DefaultAgentMaxIterations = 20 // DefaultUseCustomSystemPrompt is the default whether to use custom system prompt for the agent DefaultUseCustomSystemPrompt = false )
const ( WikiGranularityGuidanceFocused = `` /* 1244-byte string literal not displayed */ WikiGranularityGuidanceStandard = `` /* 1045-byte string literal not displayed */ WikiGranularityGuidanceExhaustive = `` /* 800-byte string literal not displayed */ )
Granularity guidance blocks injected into WikiCandidateSlugPrompt. The pipeline resolves a KnowledgeBase's configured granularity to one of these strings via WikiGranularityGuidance().
The three levels form a spectrum from "only the document's main subjects" to "every named thing you see". Moving down the list monotonically increases the candidate slug count, the downstream chunk-citation cost, and the noise-to-signal ratio of the wiki index.
const RunSnapshotVersion = 1
RunSnapshotVersion is the format version written into RunSnapshot.
const WikiCandidateSlugPrompt = `` /* 4877-byte string literal not displayed */
WikiCandidateSlugPrompt (Pass 0 of the chunk-cited pipeline) asks the LLM to scan a document and output the SKELETON of all entities/concepts it contains: name, slug, aliases, a short description, and a short details tiebreaker. The heavy lifting — linking each slug to concrete supporting chunks — is done in a second pass (see WikiChunkCitationPrompt). Because this prompt no longer has to carry full facts per item, it stays cheap even for long docs.
const WikiChunkCitationPrompt = `` /* 2431-byte string literal not displayed */
WikiChunkCitationPrompt (Pass 1..N of the chunk-cited pipeline) asks the LLM to read a batch of chunks and, for each candidate entity/concept, list the chunk IDs that substantively discuss it. This keeps per-slug "facts" in their verbatim form (the chunk text) instead of asking the LLM to paraphrase. Block order matters for provider prefix caching: the static rules, output schema and the per-document-stable <candidate_slugs> are placed BEFORE the per-batch <chunks> block. Within one document only ChunksXML changes between batches, so every batch after the first shares the long [rules | candidate_slugs] prefix and avoids re-billing the static rules.
const WikiDeduplicationPrompt = `` /* 5555-byte string literal not displayed */
WikiDeduplicationPrompt asks the LLM to identify duplicate entities/concepts between newly extracted items and existing wiki pages.
const WikiIndexIntroPrompt = `` /* 607-byte string literal not displayed */
WikiIndexIntroPrompt generates the introduction for a NEW index page (first time only).
const WikiIndexIntroUpdatePrompt = `` /* 850-byte string literal not displayed */
WikiIndexIntroUpdatePrompt incrementally updates an existing index introduction.
const WikiKnowledgeExtractPrompt = `` /* 5532-byte string literal not displayed */
WikiKnowledgeExtractPrompt extracts both entities and concepts in a single LLM call. Returns a JSON object with "entities" and "concepts" arrays. This replaces the former separate WikiEntityExtractPrompt and WikiConceptExtractPrompt.
const WikiPageModifyContinuationPrompt = `Your previous message was cut off because it reached the ` +
`output length limit, so the page is incomplete.
Continue the SAME message from exactly where it stopped:
1. Do NOT repeat anything you already wrote — not the SUMMARY line, not the headings, not the ` +
`rows, not the opening of the row you were in the middle of.
2. Your reply is appended verbatim to what you already wrote. Its first characters must be exactly ` +
`the characters that follow the last character of your previous message. If you stopped in the ` +
`middle of a Markdown table row, finish that row first.
3. Keep the same structure, formatting, ordering, and language as the part you already wrote.
4. Output the continuation ONLY: no preamble, no apology, no explanation, no closing code fence.
5. If the page was in fact already complete, reply with exactly: (complete)`
WikiPageModifyContinuationPrompt resumes a page rewrite that the provider cut off at the completion budget (finish_reason=length). Long enumerations are the shape that hits the cap: a certificate ledger with a hundred-plus holder rows is emitted row by row, and the provider stops the model mid-table, so the page is persisted one third short. The partial page is replayed as an assistant turn and this prompt asks for the remainder — WITHOUT the replay the model answers the original question again from the top, which is the #3446 spiral the agent loop works around.
const WikiPageModifySystemPrompt = `` /* 3148-byte string literal not displayed */
WikiPageModifySystemPrompt contains only rules shared by every page update. Keeping page identity and source data out of this message gives providers a long byte-stable prefix to cache across a reduce batch.
const WikiPageModifyUserPrompt = `` /* 3143-byte string literal not displayed */
WikiPageModifyUserPrompt contains the per-batch and per-page data. The document- level source context deliberately comes first: all pages generated from one source then share the longest possible prefix before page metadata diverges.
const WikiSummaryPrompt = `` /* 2086-byte string literal not displayed */
WikiSummaryPrompt generates a summary page for a newly ingested document.
Filename and title are intentionally NOT passed to the LLM: documents uploaded to WeKnora often carry filenames that say nothing about the content (e.g. scanned PDFs named after the scanner model "MX5280.pdf"), and feeding such filenames to the model invites hallucinated summaries when the actual extracted content is thin. The model must rely solely on the document content provided below.
const WikiTaxonomyPlanPrompt = `` /* 2303-byte string literal not displayed */
WikiTaxonomyPlanPrompt assigns a directory path (category) to every entity / concept page produced by ONE ingest batch in a single call, so the whole set lands on one coherent tree that reuses existing folders — instead of each page inventing its own folders in parallel (which diverges worst on the founding batch, when the KB still has no folders to anchor on). The result is applied in reduce only to pages that don't already have a category, so user edits and previously-filed pages are never churned.
Variables ¶
This section is empty.
Functions ¶
func BuildSystemPrompt ¶
func BuildSystemPrompt( knowledgeBases []*KnowledgeBaseInfo, webSearchEnabled bool, systemPromptTemplate ...string, ) string
BuildSystemPrompt builds the progressive RAG system prompt This is the main function to use - it uses a unified template with dynamic web search status
func BuildSystemPromptWithOptions ¶
func BuildSystemPromptWithOptions( knowledgeBases []*KnowledgeBaseInfo, webSearchEnabled bool, options *BuildSystemPromptOptions, systemPromptTemplate ...string, ) string
BuildSystemPromptWithOptions builds the system prompt with additional options like skills
func GetProgressiveRAGSystemPrompt ¶
GetProgressiveRAGSystemPrompt returns the Progressive RAG Agent system prompt from config templates. The template must be defined in config/prompt_templates/agent_system_prompt.yaml with mode "rag". Returns empty string if config is nil or template not found.
func GetPureAgentSystemPrompt ¶
GetPureAgentSystemPrompt returns the Pure Agent system prompt from config templates. The template must be defined in config/prompt_templates/agent_system_prompt.yaml with mode "pure". Returns empty string if config is nil or template not found.
func HistoryAsSent ¶
HistoryAsSent is stored history as the engine sends it. Unless the agent retains retrieval history, KB and Wiki tool results from earlier turns are redacted, so the model does not reuse retrieval data the knowledge base may have outgrown. The history loader prices turns with it too, so its token budget is spent on what reaches the model, not on a wiki page that goes out as one line.
func HistoryTokenBudget ¶
func HistoryTokenBudget(cfg *types.AgentConfig) int
HistoryTokenBudget is how much stored history one run of cfg may load: the whole context window, deliberately more than the compaction threshold.
The loader drops the oldest turns that do not fit, and what it drops is lost: it is neither replayed nor summarized. With a budget equal to the threshold the loader always trimmed first, so whenever one turn was larger than the system prompt plus the new question the request never crossed the threshold, nothing was summarized, and the session became a sliding window that never got a checkpoint. Loading up to the window leaves the overflow to the first round's compaction instead, which summarizes it and persists a checkpoint. The compactor bounds its own summarizer input, so a history this large cannot make the summarization request itself overflow.
func WikiGranularityGuidance ¶
WikiGranularityGuidance returns the guidance text to inject into the WikiCandidateSlugPrompt template for the given granularity. Accepts the raw string value stored in WikiConfig.ExtractionGranularity; callers do NOT need to Normalize() first — unknown values fall through to standard.
Types ¶
type AgentEngine ¶
type AgentEngine struct {
// contains filtered or unexported fields
}
AgentEngine is the core engine for running ReAct agents.
History persistence note: the engine is stateless across turns. Conversation history is rebuilt from the DB once per turn by the caller (see service.LoadAgentHistory) and passed into Execute as llmContext. The engine therefore does not maintain its own cache, system-prompt store, or cross-turn buffer.
func NewAgentEngine ¶
func NewAgentEngine( config *types.AgentConfig, chatModel chat.Chat, toolRegistry *agenttools.ToolRegistry, eventBus *event.EventBus, knowledgeBasesInfo []*KnowledgeBaseInfo, selectedDocs []*SelectedDocumentInfo, sessionID string, systemPromptTemplate string, ) *AgentEngine
NewAgentEngine creates a new agent engine
func NewAgentEngineWithSkills ¶
func NewAgentEngineWithSkills( config *types.AgentConfig, chatModel chat.Chat, toolRegistry *agenttools.ToolRegistry, eventBus *event.EventBus, knowledgeBasesInfo []*KnowledgeBaseInfo, selectedDocs []*SelectedDocumentInfo, sessionID string, systemPromptTemplate string, skillsManager *skills.Manager, ) *AgentEngine
NewAgentEngineWithSkills creates a new agent engine with skills support
func (*AgentEngine) DescribeDataURIImages ¶ added in v0.9.0
func (e *AgentEngine) DescribeDataURIImages(ctx context.Context, imageDataURIs []string) []string
DescribeDataURIImages turns user-uploaded data URIs into text with the configured VLM. A chat model that cannot see images uses this instead of dropping the upload. Uploads ask for a full read; tool results keep the prompt that came with the tool call.
func (*AgentEngine) EnableSuspension ¶ added in v0.9.0
func (e *AgentEngine) EnableSuspension(request json.RawMessage)
EnableSuspension lets prompts raised by this run suspend it instead of blocking. request is the caller's types.ResumableAgentRequest, saved with the run so another replica can rebuild it. Must be called before Execute.
func (*AgentEngine) Execute ¶
func (e *AgentEngine) Execute( ctx context.Context, sessionID, messageID, query string, llmContext []chat.Message, imageURLs ...[]string, ) (*types.AgentState, error)
Execute executes the agent with conversation history and streaming output All events are emitted to EventBus and handled by subscribers (like Handler layer)
func (*AgentEngine) GetSkillsManager ¶
func (e *AgentEngine) GetSkillsManager() *skills.Manager
GetSkillsManager returns the skills manager
func (*AgentEngine) HasCollaboration ¶ added in v0.9.0
func (e *AgentEngine) HasCollaboration() bool
HasCollaboration reports whether this execution belongs to a collaboration.
func (*AgentEngine) HasPendingInput ¶ added in v0.9.0
func (e *AgentEngine) HasPendingInput(ctx context.Context, sessionID, messageID string) bool
HasPendingInput reports whether a steered user message is waiting for the run that owns messageID. Blocking tools poll it so the user is not kept waiting behind them. It reads the queue without consuming it.
func (*AgentEngine) RenderUserTurnContent ¶
func (e *AgentEngine) RenderUserTurnContent(sessionID, query string) string
RenderUserTurnContent builds the user-turn payload for the current LLM call (runtime_context + must_use + query). Used by Execute and finalize paths only; not written to rendered_content / history.
func (*AgentEngine) RestrictSuspensionToCollaboration ¶ added in v0.9.0
func (e *AgentEngine) RestrictSuspensionToCollaboration()
RestrictSuspensionToCollaboration keeps durable collaboration waits while prompts raised by ordinary tools block in-process, as the operator configured.
func (*AgentEngine) Resume ¶ added in v0.9.0
func (e *AgentEngine) Resume( ctx context.Context, sessionID, messageID string, llmContext []chat.Message, snapshot []byte, answered *types.AgentPrompt, ) (*types.AgentState, error)
Resume continues a run that was suspended on a prompt, now answered. It rebuilds the transcript from the snapshot, finishes the interrupted round with the answer delivered to the blocked call, then carries on with the ReAct loop. The run may suspend again; completion is emitted either way.
func (*AgentEngine) SetAppConfig ¶
func (e *AgentEngine) SetAppConfig(cfg *appconfig.Config)
SetAppConfig sets the application config for prompt template resolution. This allows the engine to read default prompts from config/prompt_templates/ YAML files.
func (*AgentEngine) SetAssistantName ¶ added in v0.9.0
func (e *AgentEngine) SetAssistantName(name string)
SetAssistantName records the name the workspace gave the assistant; empty keeps the one in the system prompt.
func (*AgentEngine) SetBackgroundRun ¶ added in v0.9.0
func (e *AgentEngine) SetBackgroundRun(run BackgroundRun)
SetBackgroundRun wires background-work context for this run. Nil (the default) disables it. Must be called before Execute.
func (*AgentEngine) SetCollaboration ¶ added in v0.9.0
func (e *AgentEngine) SetCollaboration(b *collaboration.Binding)
SetCollaboration attaches runtime-owned collaboration state to the engine.
func (*AgentEngine) SetContextCheckpointSink ¶
func (e *AgentEngine) SetContextCheckpointSink(sink types.ContextCheckpointSink)
SetContextCheckpointSink enables persisting compaction checkpoints. Nil (the default) keeps every compaction local to the turn that ran it.
func (*AgentEngine) SetImageDescriber ¶
func (e *AgentEngine) SetImageDescriber(fn ImageDescriberFunc)
SetImageDescriber sets the VLM function for generating text descriptions of images in tool results. When set and the chat model cannot view images, tool result images are described while their tool call runs and the descriptions are appended to the tool message content.
func (*AgentEngine) SetMemoryPrompt ¶
func (e *AgentEngine) SetMemoryPrompt(prompt string)
SetMemoryPrompt supplies the long-term memory envelope for this run. Empty input leaves the system prompt untouched.
func (*AgentEngine) SetPageContext ¶ added in v0.9.0
func (e *AgentEngine) SetPageContext(page *PageContextInfo)
SetPageContext records the WeKnora page the user has open for this turn; nil clears it.
func (*AgentEngine) SetPinnedMentions ¶
func (e *AgentEngine) SetPinnedMentions(mcpServices []*PinnedMCPServiceInfo, skills []*PinnedSkillInfo)
SetPinnedMentions sets per-turn @mention scope for MCP services and skills.
func (*AgentEngine) SetQuestionOrigin ¶
func (e *AgentEngine) SetQuestionOrigin(origin *QuestionOriginInfo)
SetQuestionOrigin records the knowledge source of a suggested question the user picked for this turn; nil clears it.
func (*AgentEngine) SetRunMode ¶ added in v0.9.0
func (e *AgentEngine) SetRunMode(mode types.RunMode)
SetRunMode says whether the run's client can render and answer prompts such as ask_user, whether or not the run may also suspend.
func (*AgentEngine) SetRunNote ¶ added in v0.9.0
func (e *AgentEngine) SetRunNote(note string)
SetRunNote adds note to the end of this run's system prompt.
func (*AgentEngine) SetSkillsManager ¶
func (e *AgentEngine) SetSkillsManager(manager *skills.Manager)
SetSkillsManager sets the skills manager for the engine
func (*AgentEngine) SetSteerSink ¶
func (e *AgentEngine) SetSteerSink(sink types.SteerSink)
SetSteerSink wires the optional steer channel. Nil (the default) disables mid-run injection entirely — every existing call site keeps working. The sink satisfies types.SteerSink structurally.
func (*AgentEngine) SetWorkspaceLayout ¶
func (e *AgentEngine) SetWorkspaceLayout(layout sandbox.WorkspaceLayout)
SetWorkspaceLayout injects the session's real workspace into the system prompt. Host sessions must pass the user directory so the model does not keep listing /workspace.
type BackgroundRun ¶ added in v0.9.0
type BackgroundRun interface {
RoundStart(ctx context.Context) (background.Delivery, error)
BeforeFinal(ctx context.Context) (background.Delivery, error)
TakeSeen() []string
}
BackgroundRun is the run-scoped source of background-work context. The engine asks it what to tell the model at the two boundaries steer uses, and which finished items tools showed the model during a step. *background.RunNotices implements it.
type BuildSystemPromptOptions ¶
type BuildSystemPromptOptions struct {
SelectedTools []string // Actual registered tools for this turn, after capability filtering
SkillsMetadata []*skills.SkillMetadata
ShellExecEnabled bool
SkillInstallMode bool
Language string // User language name for {{language}} placeholder (e.g. "Chinese (Simplified)")
Config *config.Config // Config for reading prompt templates; nil leaves the default base empty
MemoryPrompt string
ProtocolPrompt string
WorkspaceLayout sandbox.WorkspaceLayout
}
BuildSystemPromptOptions contains optional parameters for BuildSystemPrompt
type CollaborationDelivery ¶ added in v0.9.0
type CollaborationDelivery struct {
BeforeStep int `json:"before_step"`
// BeforeUsers distinguishes finishing-boundary events from the next poll,
// which happens after that round's queued user messages have been delivered.
BeforeUsers bool `json:"before_users,omitempty"`
Events []collaboration.Event `json:"events"`
}
CollaborationDelivery keeps mailbox input at its original round boundary. It is model context, not a user-visible execution step.
type ImageDescriberFunc ¶
ImageDescriberFunc generates a text description of an image. Signature matches vlm.VLM.Predict so it can be injected without importing the vlm package.
type KnowledgeBaseInfo ¶
type KnowledgeBaseInfo struct {
ID string
Name string
Type string // Knowledge base type: "document" or "faq"
Description string
DocCount int
// Capabilities lists the retrieval surfaces this KB exposes. Any subset of
// {"wiki", "chunks"}. "chunks" is present when the KB has vector and/or
// keyword (BM25) indexing enabled. This is the *deterministic* source of
// truth the agent should consult before picking a retrieval strategy —
// significantly more reliable than running probing searches.
Capabilities []string
RecentDocs []RecentDocInfo // Recently added documents (up to 10)
// Profile is the generated description (gist, merged topics, typical
// questions) derived from document profiles. It complements the manual
// Description: that one says what the KB is for, this one says what is
// actually in it. nil when never generated.
Profile *types.KnowledgeBaseProfile
}
KnowledgeBaseInfo contains essential information about a knowledge base for agent prompt
type PageContextAgent ¶ added in v0.9.0
PageContextAgent is a tenant-visible agent; IDs remain raw in model context.
type PageContextInfo ¶ added in v0.9.0
type PageContextInfo struct {
Page string // known page identifier, e.g. "settings_models"; may be empty
Section string // part of the page in view, e.g. "tools"; only with Page
Agent *PageContextAgent
KnowledgeBaseID string
KnowledgeBaseName string
Document *SelectedDocumentInfo // nil unless a document is open
WikiPage *PageContextWikiPage // nil unless a Wiki page is open
WikiIssues []*PageContextWikiIssue
Model *PageContextModel
MCPService *PageContextMCPService
Message *PageContextMessage
// Title, View and Selection come from the page as the client reports it;
// they are what the user sees, not verified resources.
Title string
View string
Selection *types.PageSelection
}
PageContextInfo contains only resources verified as visible in this turn.
func (*PageContextInfo) Empty ¶ added in v0.9.0
func (p *PageContextInfo) Empty() bool
Empty reports whether nothing on the page was verified.
type PageContextMCPService ¶ added in v0.9.0
PageContextMCPService is the MCP service open in the MCP settings. It never carries the URL, headers or credentials.
type PageContextMessage ¶ added in v0.9.0
type PageContextMessage struct {
SessionID string
MessageID string
Role string
AgentID string
Question string
Answer string
References []*PageContextReference
}
PageContextMessage is the chat message the user pointed the assistant at, with excerpts of the exchange it belongs to.
type PageContextModel ¶ added in v0.9.0
PageContextModel is the model open in the model settings. It never carries the endpoint or credentials.
type PageContextReference ¶ added in v0.9.0
PageContextReference is one source a chat answer cited.
type PageContextWikiIssue ¶ added in v0.9.0
PageContextWikiIssue is a Wiki issue shown on the page the user has open.
type PageContextWikiPage ¶ added in v0.9.0
PageContextWikiPage is the Wiki page open in a page context.
type PendingCall ¶ added in v0.9.0
type PendingCall struct {
ID string `json:"id"`
Name string `json:"name"`
// Arguments is the decoded JSON the call executes with.
Arguments string `json:"arguments"`
UnresolvedHandles []string `json:"unresolved_handles,omitempty"`
ProviderMetadata types.ToolCallMetadata `json:"provider_metadata,omitempty"`
}
PendingCall is one tool call of the interrupted round.
type PendingRound ¶ added in v0.9.0
type PendingRound struct {
// Step carries the round's thought and reasoning; its ToolCalls are the
// calls that finished before the blocked one.
Step types.AgentStep `json:"step"`
Calls []PendingCall `json:"calls"`
// BlockedIndex is the call waiting on the prompt. Calls after it have
// not run.
BlockedIndex int `json:"blocked_index"`
}
PendingRound is the round interrupted by the prompt.
type PinnedMCPServiceInfo ¶
type PinnedMCPServiceInfo struct {
Discoverable bool // Available through the scoped MCP directory.
ID string
Name string
Description string
ToolNames []string // Registered tool.function names for this service (mcp_{service}_{tool})
}
PinnedMCPServiceInfo describes an MCP service explicitly @mentioned for this turn.
type PinnedSkillInfo ¶
PinnedSkillInfo describes a skill explicitly @mentioned for this turn.
type PlaceholderDefinition ¶
type PlaceholderDefinition struct {
Name string `json:"name"`
Label string `json:"label"`
Description string `json:"description"`
}
PlaceholderDefinition defines a placeholder exposed to UI/configuration Deprecated: Use types.PromptPlaceholder instead
func AvailablePlaceholders ¶
func AvailablePlaceholders() []PlaceholderDefinition
AvailablePlaceholders lists all supported prompt placeholders for UI hints This returns agent mode specific placeholders
type QuestionOriginInfo ¶
type QuestionOriginInfo struct {
KnowledgeBaseID string
KnowledgeBaseName string
Document *SelectedDocumentInfo // nil when only the base is known
}
QuestionOriginInfo is the knowledge source a suggested question was generated from, when the user picked that question. Rendered into runtime_context so the model searches the source before answering.
type RecentDocInfo ¶
type RecentDocInfo struct {
ChunkID string
KnowledgeBaseID string
KnowledgeID string
Title string
Description string
FileName string
FileSize int64
Type string
CreatedAt string // Formatted time string
FAQStandardQuestion string
FAQSimilarQuestions []string
FAQAnswers []string
}
RecentDocInfo contains brief information about a recently added document
type RunSnapshot ¶ added in v0.9.0
type RunSnapshot struct {
CollaborationDeliveries []CollaborationDelivery `json:"collaboration_deliveries,omitempty"`
CollaborationCursor *int64 `json:"collaboration_cursor,omitempty"`
MCPToolRefs []string `json:"mcp_tool_refs,omitempty"`
Version int `json:"version"`
CollaborationWait bool `json:"collaboration_wait,omitempty"`
BetweenRounds bool `json:"between_rounds,omitempty"`
// Request is the caller's types.ResumableAgentRequest.
Request json.RawMessage `json:"request,omitempty"`
Query string `json:"query"`
ImageURLs []string `json:"image_urls,omitempty"`
// UserMessages holds the raw text referenced by UserMessagesBefore.
UserMessages map[string]string `json:"user_messages,omitempty"`
CompletedSteps []types.AgentStep `json:"completed_steps"`
KnowledgeRefs []*types.SearchResult `json:"knowledge_refs,omitempty"`
CurrentRound int `json:"current_round"`
TurnUsage types.TokenUsage `json:"turn_usage"`
PendingRound PendingRound `json:"pending_round"`
}
RunSnapshot is everything needed to resume a run that ended waiting on a user prompt. It holds durable values only: request-local model handles (chunk://N, doc://N, res://, msN, mtN) do not survive the run, so the user turn is kept as the raw query and re-rendered on resume, and tool arguments are kept in their decoded form.
func DecodeRunSnapshot ¶ added in v0.9.0
func DecodeRunSnapshot(data []byte) (*RunSnapshot, error)
DecodeRunSnapshot parses a saved snapshot, rejecting unknown versions.
func (*RunSnapshot) ClosedSteps ¶ added in v0.9.0
func (s *RunSnapshot) ClosedSteps(reason string) []types.AgentStep
ClosedSteps returns the steps of a run that will never resume: the interrupted round's unfinished calls are recorded as failed with reason, so the transcript keeps one result per tool call the model issued.
func (*RunSnapshot) DisplaySteps ¶ added in v0.9.0
func (s *RunSnapshot) DisplaySteps() []types.AgentStep
DisplaySteps returns the steps a suspended message shows: the completed rounds plus whatever the interrupted round produced so far.
type SelectedDocumentInfo ¶
type SelectedDocumentInfo struct {
KnowledgeID string // Knowledge ID
KnowledgeBaseID string // Knowledge base ID
Title string // Document title
FileName string // Original file name
FileType string // File type (pdf, docx, etc.)
}
SelectedDocumentInfo contains summary information about a user-selected document (via @ mention). Injected into the user message runtime_context (pinned_documents); content is fetched via tools.
type SystemPromptSection ¶
SystemPromptSection identifies the source of each effective prompt fragment. Keep runtime policy here, template content in YAML, and retrieved data in messages.
func BuildSystemPromptSections ¶
func BuildSystemPromptSections( knowledgeBases []*KnowledgeBaseInfo, webSearchEnabled bool, options *BuildSystemPromptOptions, systemPromptTemplate ...string, ) []SystemPromptSection
BuildSystemPromptSections is the single assembly path, also usable by diagnostics. Custom templates replace only the base section; tool scope and runtime contracts always come from the active engine, never from editable template text.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package approval implements human-in-the-loop gating for dangerous MCP tool calls (issue #1173).
|
Package approval implements human-in-the-loop gating for dangerous MCP tool calls (issue #1173). |
|
Package collaboration owns durable agent work.
|
Package collaboration owns durable agent work. |
|
Package compaction keeps an agent turn inside the model's context window by replacing older conversation with a structured summary.
|
Package compaction keeps an agent turn inside the model's context window by replacing older conversation with a structured summary. |
|
Package hitl coordinates human-in-the-loop prompts raised by agent runs: tool approvals, in-conversation authorizations, questions for the user.
|
Package hitl coordinates human-in-the-loop prompts raised by agent runs: tool approvals, in-conversation authorizations, questions for the user. |
|
Package operations is the catalog of WeKnora HTTP API operations an agent may run on behalf of the signed-in user.
|
Package operations is the catalog of WeKnora HTTP API operations an agent may run on behalf of the signed-in user. |
|
Package policy decides whether an agent may run an action without asking the user.
|
Package policy decides whether an agent may run an action without asking the user. |
|
Package skills provides Agent Skills functionality following Claude's Progressive Disclosure pattern.
|
Package skills provides Agent Skills functionality following Claude's Progressive Disclosure pattern. |
|
Package token provides token estimation for LLM context window management.
|
Package token provides token estimation for LLM context window management. |
|
Package tools — capability requirements for built-in agent tools.
|
Package tools — capability requirements for built-in agent tools. |