Documentation
¶
Index ¶
- func MCPToolErrorResult(c *llm.Context, err error) string
- type Builder
- func (b *Builder) AddSkillTools(c *llm.Context, cfg llm.BotConfig) error
- func (b *Builder) BuildLLMContextUserRequest(bot *bots.Bot, requestingUser *model.User, channel *model.Channel, ...) *llm.Context
- func (b *Builder) SetMCPDynamicToolTelemetry(telemetry llm.MCPDynamicToolTelemetry)
- func (b *Builder) SetSkillProvider(provider SkillProvider)
- func (b *Builder) UsesServiceAccountCatalog(bot *bots.Bot) bool
- func (b *Builder) WithLLMContextBot(bot *bots.Bot) llm.ContextOption
- func (b *Builder) WithLLMContextChannel(channel *model.Channel) llm.ContextOption
- func (b *Builder) WithLLMContextConcreteTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption
- func (b *Builder) WithLLMContextDirectMessage() llm.ContextOption
- func (b *Builder) WithLLMContextDisabledMCPServers(origins []string) llm.ContextOption
- func (b *Builder) WithLLMContextInteractive() llm.ContextOption
- func (b *Builder) WithLLMContextMCPToolFilter(keep func(llm.Tool) bool) llm.ContextOption
- func (b *Builder) WithLLMContextNoTools() llm.ContextOption
- func (b *Builder) WithLLMContextParameters(params map[string]any) llm.ContextOption
- func (b *Builder) WithLLMContextPreloadedMCPTools(tools []llm.EnabledMCPTool) llm.ContextOption
- func (b *Builder) WithLLMContextRequestingUser(user *model.User) llm.ContextOption
- func (b *Builder) WithLLMContextResponseFiles() llm.ContextOption
- func (b *Builder) WithLLMContextServerInfo() llm.ContextOption
- func (b *Builder) WithLLMContextSkills(enabled bool) llm.ContextOption
- func (b *Builder) WithLLMContextTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption
- type ConfigProvider
- type DMOnlyMCPServerDescriber
- type MCPServerDescriber
- type MCPToolProvider
- type MCPToolRetrievalOverrideProvider
- type SkillProvider
- type ToolProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MCPToolErrorResult ¶ added in v2.10.0
MCPToolErrorResult returns the tool result text for a failed tool call. When the call failed because the user's authorization for its MCP server lapsed, the server's remaining tools are removed for the rest of the turn, and where connection requests can be offered, RequestMCPConnection is offered for it.
It changes c's tool store, so it must run on the goroutine that owns the tool loop, between tool calls, never from inside a resolver.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder builds contexts for LLM requests
func NewLLMContextBuilder ¶
func NewLLMContextBuilder( pluginAPI *pluginapi.Client, toolProvider ToolProvider, mcpToolProvider MCPToolProvider, configProvider ConfigProvider, ) *Builder
NewLLMContextBuilder creates a new LLM context builder
func (*Builder) AddSkillTools ¶ added in v2.13.0
AddSkillTools catalogs the skill tools for cfg when the context enables skills. Call it after the tool store is built: built-in skills depend on the tools beside them.
func (*Builder) BuildLLMContextUserRequest ¶
func (b *Builder) BuildLLMContextUserRequest(bot *bots.Bot, requestingUser *model.User, channel *model.Channel, opts ...llm.ContextOption) *llm.Context
BuildLLMContextUserRequest is a helper function to collect the required context for a user request.
func (*Builder) SetMCPDynamicToolTelemetry ¶
func (b *Builder) SetMCPDynamicToolTelemetry(telemetry llm.MCPDynamicToolTelemetry)
func (*Builder) SetSkillProvider ¶ added in v2.13.0
func (b *Builder) SetSkillProvider(provider SkillProvider)
func (*Builder) UsesServiceAccountCatalog ¶ added in v2.7.0
UsesServiceAccountCatalog reports whether tool catalogs for this bot are built in service-account mode. Service-account catalogs are available at Enterprise and above; below that, agents use per-user credentials.
func (*Builder) WithLLMContextBot ¶
func (b *Builder) WithLLMContextBot(bot *bots.Bot) llm.ContextOption
func (*Builder) WithLLMContextChannel ¶
func (b *Builder) WithLLMContextChannel(channel *model.Channel) llm.ContextOption
func (*Builder) WithLLMContextConcreteTools ¶
func (b *Builder) WithLLMContextConcreteTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption
WithLLMContextConcreteTools adds the requester's tools but forces concrete MCP tools instead of dynamic-loading meta-tools. Bridge catalog APIs need the full concrete MCP tool list regardless of the bot's dynamic-loading setting.
func (*Builder) WithLLMContextDirectMessage ¶ added in v2.12.0
func (b *Builder) WithLLMContextDirectMessage() llm.ContextOption
WithLLMContextDirectMessage marks the request as the requester's direct message with the agent, so DM-only MCP servers are cataloged. It has no effect unless the context's channel is exactly that DM, and must be configured before default tools are built.
func (*Builder) WithLLMContextDisabledMCPServers ¶
func (b *Builder) WithLLMContextDisabledMCPServers(origins []string) llm.ContextOption
func (*Builder) WithLLMContextInteractive ¶
func (b *Builder) WithLLMContextInteractive() llm.ContextOption
WithLLMContextInteractive marks the requesting user as interactively present and able to answer pending tool approvals. User-interaction tools (llm.Tool.UserInteraction) are only cataloged when this is applied, so it must be configured before default tools are built. Automated invokers (bots, webhooks, bridge API, evals) must never set this.
func (*Builder) WithLLMContextMCPToolFilter ¶
func (*Builder) WithLLMContextNoTools ¶
func (b *Builder) WithLLMContextNoTools() llm.ContextOption
WithLLMContextNoTools explicitly disables tools for this context session only, overriding the bot's DisableTools configuration. This allows inter-plugin requests to work with tool-enabled bots by bypassing tools for non-streaming calls.
func (*Builder) WithLLMContextParameters ¶
func (b *Builder) WithLLMContextParameters(params map[string]any) llm.ContextOption
func (*Builder) WithLLMContextPreloadedMCPTools ¶
func (b *Builder) WithLLMContextPreloadedMCPTools(tools []llm.EnabledMCPTool) llm.ContextOption
WithLLMContextPreloadedMCPTools requests exact-or-bare MCP tools for internal predefined flows. The selected tools are still constrained by the normal authorized MCP catalog and must be configured before default tools are built.
func (*Builder) WithLLMContextRequestingUser ¶
func (b *Builder) WithLLMContextRequestingUser(user *model.User) llm.ContextOption
func (*Builder) WithLLMContextResponseFiles ¶ added in v2.6.0
func (b *Builder) WithLLMContextResponseFiles() llm.ContextOption
WithLLMContextResponseFiles marks the context as supporting response-post file attachments (ToolRuntime.CreatedFiles are attached to the streamed response post at end of turn). Must be configured before default tools are built so CreateFile is cataloged.
func (*Builder) WithLLMContextServerInfo ¶
func (b *Builder) WithLLMContextServerInfo() llm.ContextOption
func (*Builder) WithLLMContextSkills ¶ added in v2.13.0
func (b *Builder) WithLLMContextSkills(enabled bool) llm.ContextOption
WithLLMContextSkills sets whether AddSkillTools catalogs the skill tools.
func (*Builder) WithLLMContextTools ¶
func (b *Builder) WithLLMContextTools(ctx stdcontext.Context, bot *bots.Bot) llm.ContextOption
WithLLMContextTools adds tools to the LLM context the requester can access. Tools are always added for LLM awareness; execution is controlled via WithToolsDisabled() based on the context (e.g., DM vs channel).
type ConfigProvider ¶
type ConfigProvider interface {
GetServiceByID(id string) (llm.ServiceConfig, bool)
}
ConfigProvider provides configuration access
type DMOnlyMCPServerDescriber ¶ added in v2.12.0
type DMOnlyMCPServerDescriber interface {
DescribeDMOnlyMCPServers(ctx stdcontext.Context, req mcp.CatalogRequest, selection mcp.ToolSelection) []llm.DMOnlyMCPServer
}
DMOnlyMCPServerDescriber names the servers a catalog selection left out only because they are limited to direct messages.
type MCPServerDescriber ¶ added in v2.10.0
type MCPServerDescriber interface {
DescribeUnconnectedMCPServers(authErrors []llm.ToolAuthError) []llm.UnconnectedMCPServer
MCPServerOriginsByName() map[string]string
}
MCPServerDescriber describes configured MCP servers beyond the tools a catalog request returned, so the model can ask the requester to connect one.
type MCPToolProvider ¶
type MCPToolProvider interface {
GetToolsWithSelection(ctx stdcontext.Context, req mcp.CatalogRequest, selection mcp.ToolSelection) ([]llm.Tool, *mcp.Errors)
}
MCPToolProvider provides MCP tools for a user or service-account agent. selection identifies which servers the request may reach, so ineligible servers are never connected rather than connected and then filtered out.
type MCPToolRetrievalOverrideProvider ¶
type MCPToolRetrievalOverrideProvider interface {
GetToolRetrievalOverrides() map[string]mcp.ToolRetrievalOverride
}