Documentation
¶
Overview ¶
Package agent defines the expression types used to represent agent and toolset declarations during Goa design evaluation. These types are populated during DSL execution and form the schema used for code generation and validation.
Index ¶
- type AgentExpr
- type CacheExpr
- type CapsExpr
- type FederationExpr
- type HistoryExpr
- type HistoryMode
- type ProviderExpr
- type ProviderKind
- type RegistryExpr
- func (r *RegistryExpr) AddSecurityRequirement(sec *goaexpr.SecurityExpr)
- func (r *RegistryExpr) EvalName() string
- func (r *RegistryExpr) Finalize()
- func (r *RegistryExpr) Prepare()
- func (r *RegistryExpr) SetTimeout(duration string) error
- func (r *RegistryExpr) SetURL(u string)
- func (r *RegistryExpr) Validate() error
- type RetryPolicyExpr
- type RootExpr
- type RunPolicyExpr
- type ServerDataExpr
- type ServerDataSourceExpr
- type ServiceExportsExpr
- type ToolBoundsExpr
- type ToolConfirmationExpr
- type ToolExpr
- func (t *ToolExpr) AddMeta(name string, value ...string)
- func (t *ToolExpr) BoundServiceName() string
- func (t *ToolExpr) DeleteMeta(name string)
- func (t *ToolExpr) EvalName() string
- func (t *ToolExpr) Finalize()
- func (t *ToolExpr) Prepare()
- func (t *ToolExpr) RecordBinding(serviceName, methodName string)
- func (t *ToolExpr) SetTitle(title string)
- func (t *ToolExpr) Validate() error
- type ToolPagingExpr
- type ToolPassthroughExpr
- type ToolsetExpr
- func (t *ToolsetExpr) AddMeta(name string, value ...string)
- func (t *ToolsetExpr) DeleteMeta(name string)
- func (t *ToolsetExpr) EvalName() string
- func (t *ToolsetExpr) SetDescription(d string)
- func (t *ToolsetExpr) SetVersion(v string)
- func (t *ToolsetExpr) Validate() error
- func (t *ToolsetExpr) WalkSets(walk eval.SetWalker)
- type ToolsetGroupExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentExpr ¶
type AgentExpr struct {
eval.DSLFunc
// Name is the unique identifier for this agent.
Name string
// Description provides a human-readable explanation of the
// agent's purpose and capabilities.
Description string
// Service is the Goa service expression this agent is
// associated with.
Service *goaexpr.ServiceExpr
// Used contains the toolsets this agent consumes from other
// agents or services.
Used *ToolsetGroupExpr
// Exported contains the toolsets this agent exposes for other
// agents to consume.
Exported *ToolsetGroupExpr
// RunPolicy defines runtime execution and resource constraints
// for this agent.
RunPolicy *RunPolicyExpr
}
AgentExpr describes a single LLM-powered agent configured via the Goa Agent DSL.
type CacheExpr ¶
type CacheExpr struct {
eval.DSLFunc
// Policy is the run policy expression this cache configuration
// belongs to.
Policy *RunPolicyExpr
// AfterSystem places a cache checkpoint after all system messages.
AfterSystem bool
// AfterTools places a cache checkpoint after tool definitions.
AfterTools bool
}
CacheExpr captures the design-time configuration for prompt caching behavior. Zero-value means no cache policy is configured.
type CapsExpr ¶
type CapsExpr struct {
// Policy is the run policy expression this caps configuration
// belongs to.
Policy *RunPolicyExpr
// MaxToolCalls is the maximum number of tool invocations
// allowed in a single run.
MaxToolCalls int
// MaxConsecutiveFailedToolCall is the maximum number of
// consecutive tool failures before the run is terminated.
MaxConsecutiveFailedToolCall int
}
CapsExpr defines per-run limits on agent tool usage.
type FederationExpr ¶
type FederationExpr struct {
eval.DSLFunc
// Include specifies glob patterns for namespaces to import from
// the federated source. If empty, all namespaces are included.
Include []string
// Exclude specifies glob patterns for namespaces to skip from
// the federated source.
Exclude []string
}
FederationExpr captures federation configuration for importing servers and agents from external registries.
func (*FederationExpr) EvalName ¶
func (f *FederationExpr) EvalName() string
EvalName implements eval.Expression allowing descriptive error messages.
type HistoryExpr ¶
type HistoryExpr struct {
eval.DSLFunc
// Policy is the run policy expression this history configuration
// belongs to.
Policy *RunPolicyExpr
// Mode selects the history strategy.
Mode HistoryMode
// KeepRecent is the number of recent turns to retain when
// ModeKeepRecent is selected.
KeepRecent int
// TriggerAt is the number of turns that must accumulate before
// compression triggers when ModeCompress is selected.
TriggerAt int
// CompressKeepRecent is the number of recent turns to retain in full
// fidelity when ModeCompress is selected.
CompressKeepRecent int
}
HistoryExpr captures the design-time configuration for history management. It encodes either a KeepRecentTurns or Compress policy; at most one mode may be set.
func (*HistoryExpr) EvalName ¶
func (h *HistoryExpr) EvalName() string
EvalName returns a descriptive identifier for error reporting.
type HistoryMode ¶
type HistoryMode string
HistoryMode identifies which history policy is configured on an agent.
const ( // HistoryModeKeepRecent configures a sliding-window policy that // retains only the most recent N turns. HistoryModeKeepRecent HistoryMode = "keep_recent" // HistoryModeCompress configures a summarization policy that // compresses older turns once a trigger threshold is reached. HistoryModeCompress HistoryMode = "compress" )
type ProviderExpr ¶
type ProviderExpr struct {
// Kind identifies the provider type (local, MCP, registry).
Kind ProviderKind
// MCPService is the Goa service name that owns the MCP server
// definition. Used when Kind is ProviderMCP.
MCPService string
// MCPToolset is the MCP server name for this toolset. Used when
// Kind is ProviderMCP.
MCPToolset string
// Registry references the registry source for this toolset.
// Used when Kind is ProviderRegistry.
Registry *RegistryExpr
// ToolsetName is the name of the toolset in the registry.
// Used when Kind is ProviderRegistry.
ToolsetName string
// Version pins the toolset to a specific version.
// Used when Kind is ProviderRegistry.
Version string
}
ProviderExpr captures the provider configuration for a toolset, specifying where tool schemas come from and how tools are executed.
func (*ProviderExpr) EvalName ¶
func (p *ProviderExpr) EvalName() string
EvalName returns a descriptive identifier for error reporting.
type ProviderKind ¶
type ProviderKind int
ProviderKind identifies the source/executor type for a toolset.
const ( // ProviderLocal indicates a toolset with inline schemas defined // directly in the DSL. ProviderLocal ProviderKind = iota // ProviderMCP indicates a toolset backed by an MCP server. ProviderMCP // ProviderRegistry indicates a toolset sourced from a registry. ProviderRegistry )
func (ProviderKind) String ¶
func (k ProviderKind) String() string
String returns a human-readable representation of the provider kind.
type RegistryExpr ¶
type RegistryExpr struct {
eval.DSLFunc
// Name is the unique identifier for this registry within the design.
Name string
// Description provides a human-readable explanation of the
// registry's purpose.
Description string
// URL is the registry endpoint URL.
URL string
// APIVersion is the registry API version (e.g., "v1", "2024-11-05").
// Defaults to "v1" for Anthropic-compatible registries.
APIVersion string
// Requirements contains the security requirements for authenticating
// with this registry. References Goa security schemes.
Requirements []*goaexpr.SecurityExpr
// SyncInterval specifies how often to refresh the registry catalog.
SyncInterval time.Duration
// CacheTTL specifies local cache duration for registry data.
CacheTTL time.Duration
// Timeout specifies HTTP request timeout for registry operations.
Timeout time.Duration
// RetryPolicy configures retry behavior for failed requests.
RetryPolicy *RetryPolicyExpr
// Federation configures external registry import settings.
Federation *FederationExpr
}
RegistryExpr captures a registry source declaration from the agent DSL. It represents a centralized catalog of MCP servers, toolsets, and agents that can be discovered and consumed by loom-mcp agents.
func (*RegistryExpr) AddSecurityRequirement ¶
func (r *RegistryExpr) AddSecurityRequirement(sec *goaexpr.SecurityExpr)
AddSecurityRequirement implements goaexpr.SecurityHolder, allowing the Security() DSL function to be used inside Registry declarations.
func (*RegistryExpr) EvalName ¶
func (r *RegistryExpr) EvalName() string
EvalName implements eval.Expression allowing descriptive error messages.
func (*RegistryExpr) Finalize ¶
func (r *RegistryExpr) Finalize()
Finalize completes the registry expression after validation.
func (*RegistryExpr) Prepare ¶
func (r *RegistryExpr) Prepare()
Prepare sets default values for optional fields.
func (*RegistryExpr) SetTimeout ¶
func (r *RegistryExpr) SetTimeout(duration string) error
SetTimeout implements expr.TimeoutHolder, allowing the Timeout() DSL function to set the registry timeout.
func (*RegistryExpr) SetURL ¶
func (r *RegistryExpr) SetURL(u string)
SetURL implements goaexpr.URLHolder, allowing the URL() DSL function to be used inside Registry declarations.
func (*RegistryExpr) Validate ¶
func (r *RegistryExpr) Validate() error
Validate performs semantic checks on the registry expression.
type RetryPolicyExpr ¶
type RetryPolicyExpr struct {
// MaxRetries is the maximum number of retry attempts.
MaxRetries int
// BackoffBase is the initial backoff duration between retries.
BackoffBase time.Duration
// BackoffMax is the maximum backoff duration between retries.
BackoffMax time.Duration
}
RetryPolicyExpr defines retry configuration for registry operations.
type RootExpr ¶
type RootExpr struct {
// Agents is the collection of all agent expressions defined in the
// design.
Agents []*AgentExpr
// ServiceExports holds toolsets exported directly by services.
ServiceExports []*ServiceExportsExpr
// Toolsets is the collection of all standalone toolset expressions not
// owned by an agent.
Toolsets []*ToolsetExpr
// Registries is the collection of all registry expressions defined
// in the design.
Registries []*RegistryExpr
// DisableAgentDocs controls whether agent-specific documentation
// generation is suppressed.
DisableAgentDocs bool
}
RootExpr represents the top-level root for all agent and toolset declarations.
var Root *RootExpr
Root holds all agent DSL declarations for the current Goa design run.
func (*RootExpr) Validate ¶
Validate enforces repository-wide invariants that require a view of all agent, toolset, and registry declarations. In particular:
- Registry names must be globally unique.
- Defining toolsets (Origin == nil) must use globally unique names so they can serve as stable identifiers.
- Tool names must be unique within a defining toolset (Origin == nil) but may be reused across different toolsets. Qualified tool IDs are derived as "toolset.tool".
type RunPolicyExpr ¶
type RunPolicyExpr struct {
eval.DSLFunc
// Agent is the agent expression this policy applies to.
Agent *AgentExpr
// DefaultCaps specifies default per-run limits on tool usage.
DefaultCaps *CapsExpr
// TimeBudget is the maximum duration a run may execute before
// being terminated.
TimeBudget time.Duration
// PlanTimeout applies to both Plan and Resume activities when set.
PlanTimeout time.Duration
// ToolTimeout is the default ExecuteTool activity timeout when set.
ToolTimeout time.Duration
// InterruptsAllowed indicates whether the agent can be
// interrupted during execution.
InterruptsAllowed bool
// OnMissingFields controls behavior when validation indicates
// missing fields. Allowed values: "finalize" |
// "await_clarification" | "resume". Empty means unspecified.
OnMissingFields string
// History configures how the runtime prunes or compresses
// conversational history before planner invocations.
History *HistoryExpr
// Cache configures prompt caching hints for planner/model calls.
Cache *CacheExpr
}
RunPolicyExpr defines runtime execution and resource constraints for a single agent.
func (*RunPolicyExpr) EvalName ¶
func (r *RunPolicyExpr) EvalName() string
EvalName returns a descriptive identifier for error reporting.
func (*RunPolicyExpr) Validate ¶
func (r *RunPolicyExpr) Validate() error
Validate enforces semantic constraints on the run policy.
type ServerDataExpr ¶
type ServerDataExpr struct {
eval.DSLFunc
// Kind identifies the logical kind of this server data (for example,
// "atlas.time_series" for UI charts).
Kind string
// Audience declares who this server-data payload is intended for.
//
// Contract:
// - "timeline": persisted and eligible for UI rendering and transcript export.
// - "internal": tool-composition attachment; not persisted or rendered.
// - "evidence": provenance references; persisted separately from timeline cards.
//
// Audience is set by the DSL layer. When not explicitly configured, it
// defaults to "timeline".
Audience string
// Description is the observer-facing description of this server-data payload.
// It is typically used by UIs and sinks to explain rendering behavior.
Description string
// Schema describes the typed payload. It must be non-empty.
Schema *goaexpr.AttributeExpr
// Source describes how to populate the server-data payload. When set,
// code generation uses it to derive the server-data payload from the tool's
// bound method result.
Source *ServerDataSourceExpr
// Tool links this server-data declaration to its owning tool. It is set by
// the DSL layer and used for schema naming and validation.
Tool *ToolExpr
}
ServerDataExpr declares one server-only data item emitted alongside a tool result.
func (*ServerDataExpr) EvalName ¶
func (s *ServerDataExpr) EvalName() string
EvalName implements eval.Expression.
func (*ServerDataExpr) SetDescription ¶
func (s *ServerDataExpr) SetDescription(d string)
SetDescription implements github.com/CaliLuke/loom/expr.DescriptionHolder so the Goa Description DSL helper can be used inside ServerData configuration blocks.
type ServerDataSourceExpr ¶
type ServerDataSourceExpr struct {
// MethodResultField names the bound method result field used as the source
// payload (for example, "Evidence").
MethodResultField string
}
ServerDataSourceExpr describes the producer-side source of a server-data payload.
type ServiceExportsExpr ¶
type ServiceExportsExpr struct {
eval.DSLFunc
// Service is the Goa service that owns these exported toolsets.
Service *goaexpr.ServiceExpr
// Toolsets is the collection of toolset expressions exported
// by the service.
Toolsets []*ToolsetExpr
}
ServiceExportsExpr represents toolsets exported directly by a Goa service via a Service-level Exports block.
func (*ServiceExportsExpr) EvalName ¶
func (s *ServiceExportsExpr) EvalName() string
EvalName is part of eval.Expression allowing descriptive error messages.
type ToolBoundsExpr ¶
type ToolBoundsExpr struct {
// Tool is the owning tool declaration.
Tool *ToolExpr
// Paging optionally describes cursor-based pagination for this bounded tool.
Paging *ToolPagingExpr
}
ToolBoundsExpr describes the out-of-band bounded-result contract for a tool.
func (*ToolBoundsExpr) EvalName ¶
func (b *ToolBoundsExpr) EvalName() string
EvalName implements eval.Expression.
type ToolConfirmationExpr ¶
type ToolConfirmationExpr struct {
// Title is an optional title presented in the confirmation UI.
Title string
// PromptTemplate is a Go text/template rendered with the tool payload to
// produce the operator-facing confirmation prompt.
PromptTemplate string
// DeniedResultTemplate is a Go text/template rendered with the tool payload to
// produce canonical JSON for the denied tool result. The rendered JSON must
// decode successfully using the tool result codec.
DeniedResultTemplate string
}
ToolConfirmationExpr captures design-time confirmation requirements for a tool. When present, the runtime must request an external confirmation before executing the tool, unless runtime overrides disable or supersede the confirmation.
func (*ToolConfirmationExpr) EvalName ¶
func (c *ToolConfirmationExpr) EvalName() string
EvalName implements eval.Expression.
func (*ToolConfirmationExpr) SetTitle ¶
func (c *ToolConfirmationExpr) SetTitle(title string)
SetTitle implements expr.TitleHolder, allowing the Goa Title() DSL function to set the confirmation UI title when used inside Confirmation(...).
type ToolExpr ¶
type ToolExpr struct {
eval.DSLFunc
// Name is the unique identifier for this tool within its toolset.
Name string
// Title is an optional human-friendly display title. When empty, codegen
// derives a title from Name (e.g., "analyze_sensor_patterns" -> "Analyze Sensor Patterns").
Title string
// Description provides a human-readable explanation of what the
// tool does.
Description string
// Tags are labels for categorizing and filtering this tool.
Tags []string
// Meta carries arbitrary design-time metadata attached to the tool via DSL.
// Keys map to one or more values, matching Goa's Meta conventions.
Meta goaexpr.MetaExpr
// Args defines the input parameter schema for this tool.
Args *goaexpr.AttributeExpr
// Return defines the output result schema for this tool.
Return *goaexpr.AttributeExpr
// ServerData declares typed server-only data emitted alongside the canonical
// tool result. Server data is never serialized into model provider requests.
//
// Each entry declares a Kind identifier and a schema type. Code generation
// produces a JSON codec per entry so values can be marshaled into canonical
// JSON bytes and decoded reliably by runtimes and downstream consumers.
ServerData []*ServerDataExpr
// Toolset is the toolset expression that owns this tool.
Toolset *ToolsetExpr
// Method is the resolved Goa service method this tool is bound
// to, if any.
Method *goaexpr.MethodExpr
// ExportPassthrough defines deterministic forwarding for this tool
// when it is part of an exported toolset.
ExportPassthrough *ToolPassthroughExpr
// Optional display hint templates declared in the DSL.
CallHintTemplate string
ResultHintTemplate string
// InjectedFields are fields marked as infrastructure-only.
InjectedFields []string
// Bounds declares the out-of-band bounded-result contract for this tool.
// When non-nil, runtimes require planner.ToolResult.Bounds and generated
// method-backed executors project canonical bound fields from service
// method results without polluting the semantic result schema.
Bounds *ToolBoundsExpr
// TerminalRun indicates that once this tool executes, the runtime should
// terminate the run immediately without requesting a follow-up planner
// PlanResume/finalization turn. It is set via the TerminalRun DSL helper.
TerminalRun bool
// ResultReminder is an optional system reminder that is injected into
// the conversation after the tool result is returned. It provides
// backstage guidance to the model about how to interpret or present
// the result (for example, "The user sees a rendered graph of this
// data"). The reminder is wrapped in <system-reminder> tags by the
// runtime.
ResultReminder string
// Confirmation configures design-time confirmation requirements for this tool.
// When non-nil, the runtime requests an external confirmation before executing
// the tool (unless runtime overrides supersede the confirmation).
Confirmation *ToolConfirmationExpr
// contains filtered or unexported fields
}
ToolExpr captures an individual tool declaration within a toolset.
func (*ToolExpr) AddMeta ¶
AddMeta adds metadata to the tool expression.
This method exists so Goa's standard Meta DSL helper can attach metadata to loom-mcp agent tool expressions without loom-mcp introducing a parallel Meta DSL.
func (*ToolExpr) BoundServiceName ¶
BoundServiceName returns the service name specified via BindTo, if any.
func (*ToolExpr) DeleteMeta ¶
DeleteMeta removes the metadata entry identified by name.
This method exists so Goa's standard RemoveMeta DSL helper can remove metadata from loom-mcp agent tool expressions.
func (*ToolExpr) Finalize ¶
func (t *ToolExpr) Finalize()
Finalize materializes tool shapes and resolves method bindings.
Contract:
- Args/Return are finalized before codegen so Extend-composed fields are materialized once at the expression layer.
- Method bindings are resolved after validation and must be deterministic.
func (*ToolExpr) Prepare ¶
func (t *ToolExpr) Prepare()
Prepare ensures Args and Return are always non-nil attributes.
func (*ToolExpr) RecordBinding ¶
RecordBinding records the service and method names specified via the DSL.
type ToolPagingExpr ¶
type ToolPagingExpr struct {
// CursorField is the name of the optional String field in the tool payload
// that carries the paging cursor for retrieving the next page.
CursorField string
// NextCursorField is the canonical field name for the next-page cursor in
// the paging contract.
NextCursorField string
}
ToolPagingExpr identifies the cursor field names used by a cursor-paged tool. CursorField always names a payload field. NextCursorField names the canonical next-page cursor identifier for the paging contract, which is projected into runtime-owned bounds metadata rather than the semantic tool result.
type ToolPassthroughExpr ¶
ToolPassthroughExpr defines deterministic forwarding for an exported tool.
type ToolsetExpr ¶
type ToolsetExpr struct {
eval.DSLFunc
// Name is the unique identifier for this toolset within the design.
// Root-level validation enforces that defining toolsets (Origin == nil)
// use globally unique names so tooling can treat toolset IDs as simple
// names.
Name string
// Description provides a human-readable explanation of the
// toolset's purpose.
Description string
// Tags are labels for categorizing and filtering this toolset.
Tags []string
// Meta carries arbitrary design-time metadata attached to the toolset via DSL.
// Keys map to one or more values, matching Goa's Meta conventions.
Meta goaexpr.MetaExpr
// Agent is the agent expression that owns this toolset, if any.
// When nil, the toolset is either top-level or attached to a
// service export.
Agent *AgentExpr
// Tools is the collection of tool expressions in this toolset.
Tools []*ToolExpr
// Provider configures the source/executor for this toolset.
// When nil, the toolset is local with inline schemas.
Provider *ProviderExpr
// PublishTo specifies registries where this toolset should be
// published when exported.
PublishTo []*RegistryExpr
// Origin references the original defining toolset when this toolset
// is a reference/alias (e.g., consumed under Uses or via AgentToolset).
// When nil, this toolset is the defining origin.
Origin *ToolsetExpr
}
ToolsetExpr captures a toolset declaration from the agent DSL.
func (*ToolsetExpr) AddMeta ¶
func (t *ToolsetExpr) AddMeta(name string, value ...string)
AddMeta adds metadata to the toolset expression.
This method exists so Goa's standard Meta DSL helper can attach metadata to loom-mcp agent toolset expressions without loom-mcp introducing a parallel Meta DSL.
func (*ToolsetExpr) DeleteMeta ¶
func (t *ToolsetExpr) DeleteMeta(name string)
DeleteMeta removes the metadata entry identified by name.
This method exists so Goa's standard RemoveMeta DSL helper can remove metadata from loom-mcp agent toolset expressions.
func (*ToolsetExpr) EvalName ¶
func (t *ToolsetExpr) EvalName() string
EvalName is part of eval.Expression allowing descriptive error messages.
func (*ToolsetExpr) SetDescription ¶
func (t *ToolsetExpr) SetDescription(d string)
SetDescription implements expr.DescriptionHolder, allowing the Description() DSL function to set the toolset description.
func (*ToolsetExpr) SetVersion ¶
func (t *ToolsetExpr) SetVersion(v string)
SetVersion implements expr.VersionHolder, allowing the Version() DSL function to set the toolset version. Version is only valid for registry-backed toolsets.
func (*ToolsetExpr) Validate ¶
func (t *ToolsetExpr) Validate() error
Validate performs semantic checks on the toolset expression.
func (*ToolsetExpr) WalkSets ¶
func (t *ToolsetExpr) WalkSets(walk eval.SetWalker)
WalkSets exposes the nested expressions to the eval engine.
type ToolsetGroupExpr ¶
type ToolsetGroupExpr struct {
eval.DSLFunc
// Agent is the agent expression that owns this toolset group.
Agent *AgentExpr
// Toolsets is the collection of toolset expressions in this
// group.
Toolsets []*ToolsetExpr
}
ToolsetGroupExpr represents a logical group of toolsets, as exposed or consumed by an agent.
func (*ToolsetGroupExpr) EvalName ¶
func (t *ToolsetGroupExpr) EvalName() string
EvalName is part of eval.Expression allowing descriptive error messages.