Skip to main content
System instructions define the behavior and personality of an agent. The SDK provides flexible ways to create system instructions, from simple strings to dynamic templates loaded from remote sources.

Basic Usage

The simplest way to provide a system instruction is using a plain string:

Template Variables

System instructions support template variables using Go template syntax. Variables are resolved at runtime using resolvers.

Simple Template Variables

Use {{variable}} syntax in your instruction string, and provide a resolver to populate the values:
The template syntax {{variable}} is automatically converted to Go template format {{ .variable }} for resolution.

Custom Resolvers

You can create custom resolvers functions for more complex template resolution logic. The resolver function will have access to the raw prompt and the run context.

Skills

You can inject skills into the system prompt using prompts.WithSkills. Each skill adds more specialised context, instructions and scripts that the agent can pull in when a task requires it.
The agents.Skill fields are loaded from a skill’s SKILL.md:

Remote Prompts

You can load system instructions from the HasteKit Gateway server using a hastekitgateway.Config’s NewPrompt.

Parameters

  • name: The name of the prompt stored in the HasteKit Gateway server
  • alias: The prompt alias ("production" or "latest")
For this to work, you should have configured the hastekitgateway.Config with the gateway’s endpoint, organisation name, project name and an API key.

Remote Prompt with Resolvers

You can combine remote prompts with resolvers for dynamic content:

Custom Prompt Loaders

For advanced use cases, you can implement a custom PromptLoader interface to load prompts from any source:

Complete Example

Here’s a complete example demonstrating different ways to use system instructions:

Notes

  • Template variables use the syntax {{variable}} which is automatically converted to Go template format
  • Remote prompts require the SDK client to be initialized with endpoint, organisation name and projectName
  • Custom prompt loaders must implement the PromptLoader interface with a LoadPrompt(ctx context.Context) (string, error) method