config

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 25 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads the service configuration from environment variables.

Index

Constants

View Source
const (
	BackendOpenSandbox = "opensandbox"
	BackendLocal       = "local"
	BackendNone        = "none"
)

Names of the built-in sandbox backends (SANDBOX_BACKEND).

View Source
const (
	ConfigFile       = "config.yml"
	PermissionsFile  = "permissions.yml"
	InstructionsFile = "instructions.md"
	MCPFile          = "mcp.json"
	SkillsFolder     = layout.SkillsFolder
	MemoryFolder     = layout.MemoryFolder
	AuthFile         = "auth.json"
	AgentsFile       = "AGENTS.md"
	SessionsFolder   = "sessions"
)

Files and folders inside a configuration directory.

View Source
const (
	// HomeEnv overrides the location of the user directory (default ~/.har):
	// for tests, containers and servers.
	HomeEnv = "HAR_HOME"
	// NoUserDirEnv disables reading anything from the user directory (any
	// non-empty value but 0/false/no/off): for servers, containers and CI that must be hermetic.
	NoUserDirEnv = "HARNESS_NO_USER_DIR"
)

Environment variables that place or disable the user directory.

View Source
const (
	DefaultMaxOutputTokens = 16000
	ReserveMarginTokens    = 20000
	DeepSeekContextWindow  = 1_000_000
)

Defaults of the output reserve and DeepSeek models.

View Source
const (
	// ModelPricesEnv replaces the default source of the model price table
	// (LiteLLM's public JSON): a file path or an http(s) URL; "off" disables it.
	ModelPricesEnv = "HARNESS_MODEL_PRICES"
	// ModelPricesFile is the user's override, in the same schema: its models win
	// over the table's, so private or self-hosted models can be priced.
	ModelPricesFile = "model-prices.json"
	// CacheFolder holds downloaded data under the user directory.
	CacheFolder = "cache"
)

Names of the files in the user directory that belong to the model price table.

View Source
const DefaultContextWindow = modelinfo.DefaultContextWindow

DefaultContextWindow is the context window of models missing from LLM_CONTEXT_WINDOWS.

View Source
const DefaultPresets = "fast=gpt-5.6-terra:low,balanced=gpt-5.6-terra:medium,thinking=gpt-5.6-sol:medium,deep=gpt-5.6-sol:high"

DefaultPresets is the envDefault of LLM_PRESETS.

View Source
const DirName = layout.DirName

DirName is the name of the configuration directory of a project (<repo>/.har/) and of the user (~/.har/). It is the only place the name is defined (in core/layout, for packages that must not import config): every path below it derives from it.

View Source
const NoPresets = "none"

NoPresets is the LLM_PRESETS value that disables the thinking slider.

View Source
const ShutdownInterruptBudget = 12

ShutdownInterruptBudget is what a runtime needs after RUNTIME_SHUTDOWN_GRACE_SECONDS to interrupt its runs (8 s), let background archives end and flush Sentry.

View Source
const TrustEnv = "HARNESS_TRUST_PROJECT"

TrustEnv trusts the current project for one process (CI, scripts) when it has a true value ("1", "true", ...).

View Source
const TrustFile = "trust.json"

TrustFile is the name of the trust file in the user directory.

View Source
const UserConfigHint = "~/.har/config.yml"

UserConfigHint is where a setting a project may not make belongs.

Variables

View Source
var DefaultReasoningEfforts = []string{"minimal", "low", "medium", "high"}

DefaultReasoningEfforts are accepted by reasoning models missing from LLM_REASONING_EFFORTS.

View Source
var ReasoningEfforts = []string{"none", "minimal", "low", "medium", "high", "xhigh"}

ReasoningEfforts are the reasoningEffort values accepted by POST /threads/{id}/runs (each model accepts a subset: Config.ReasoningEffortsOf, LLM_REASONING_EFFORTS).

Functions

func AddTrust

func AddTrust(dir, root string) (bool, error)

AddTrust lists root in the trust file of dir; it reports whether it was added (false: already listed).

func ApproveMCP

func ApproveMCP(dir, root string, s MCPServer) (bool, error)

ApproveMCP records the approval of a project's stdio server, replacing an earlier approval of the same name (whose command may have been different); it reports whether the file changed.

func AuthPath

func AuthPath(dir string) string

AuthPath is the credentials file of the user directory dir.

func AuthProviders

func AuthProviders(keys map[string]string) []string

AuthProviders lists the provider names that have a key, sorted, with the keys.

func CanonicalProject

func CanonicalProject(p string) (string, error)

CanonicalProject makes a project root comparable: absolute, symbolic links resolved when it exists.

func FindProjectDir

func FindProjectDir(start string) (dir, root string, found bool)

FindProjectDir walks up from start to the git root (the first directory holding a .git entry) or the filesystem root and returns the nearest <dir>/.har directory and the project root (its parent, or the git root when there is no .har). found is false when there is no .har directory. The user directory itself is never a project directory.

func HomeDir

func HomeDir() string

HomeDir is the user directory whether or not it is disabled: $HAR_HOME, else ~/.har ("" when the home directory is unknown). Commands that write to it (harness auth, harness config init) use it; everything that reads uses UserDir.

func IsDeepSeek

func IsDeepSeek(model string) bool

IsDeepSeek reports a DeepSeek model id ("deepseek/DeepSeek-V4-Flash", or a bare "DeepSeek-…").

func IsTrusted

func IsTrusted(dir, root string) (bool, error)

IsTrusted reports whether root is listed in the trust file of dir.

func MCPApproved

func MCPApproved(dir, root string, s MCPServer) (bool, error)

MCPApproved reports whether the user approved this exact stdio server of the project root (name, command, arguments and environment unchanged since the approval).

func MCPFingerprint

func MCPFingerprint(s MCPServer) string

MCPFingerprint identifies what a stdio MCP server runs: the SHA-256 of its command, arguments and environment (the environment can redirect a program, e.g. NODE_OPTIONS). The name and the project are recorded beside it.

func MCPToolName added in v0.3.0

func MCPToolName(server, tool string) string

MCPToolName is the name the model sees for the tool of an MCP server: {server}__{tool}, characters outside [a-zA-Z0-9_-] replaced by "_", at most 64 characters.

func MaskKey

func MaskKey(key string) string

MaskKey shows the last 4 characters of key ("****" when it is too short to show any).

func ModelPriceOptions

func ModelPriceOptions() (o modelinfo.Options, ok bool)

ModelPriceOptions are the options to load the model price table, from HARNESS_MODEL_PRICES and the user directory. ok is false when the table is disabled ("off").

func NoUserDir

func NoUserDir() bool

NoUserDir reports HARNESS_NO_USER_DIR: nothing is read from the user directory.

func PermissionStrictness

func PermissionStrictness(mode string) (int, bool)

PermissionStrictness ranks the permission modes: the higher, the stricter. "" is ask.

func ReadAuth

func ReadAuth(dir string) (map[string]string, error)

ReadAuth returns the API keys of the credentials file in dir by provider name. A missing file is no error (an empty map); a file with a loose mode, or one that is not valid, is, and the error names the file and never holds a key.

func ReadTrust

func ReadTrust(dir string) ([]string, error)

ReadTrust returns the trusted project roots of dir. A missing file is no error; a file with a loose mode or invalid content is.

func RemoveAuthKey

func RemoveAuthKey(dir, provider string) (bool, error)

RemoveAuthKey deletes the key of a provider; it reports whether there was one.

func RemoveTrust

func RemoveTrust(dir, root string) (bool, error)

RemoveTrust removes root from the trust file of dir; it reports whether it was listed.

func RevokeMCP

func RevokeMCP(dir, root, server string) (bool, error)

RevokeMCP removes the approval of the project's stdio server of that name; it reports whether one was listed.

func SetAuthKey

func SetAuthKey(dir, provider, key string) error

SetAuthKey stores the key of a provider in the credentials file of dir, creating the directory (0700) and the file (0600) when needed.

func TrustPath

func TrustPath(dir string) string

TrustPath is the trust file of the user directory dir.

func UserDir

func UserDir() string

UserDir is the directory every user-level file is read from: $HAR_HOME, else ~/.har. It is "" when the home directory is unknown or HARNESS_NO_USER_DIR is set. All readers of the user directory go through it.

func ValidProviderName

func ValidProviderName(name string) bool

ValidProviderName reports whether name can name a provider.

Types

type Config

type Config struct {
	Port int `env:"PORT" envDefault:"8000"`
	// Production is on when HARNESS_PRODUCTION has any non-empty value
	// ("1", "true", "yes" alike).
	Production    bool   `env:"-"`
	ProductionRaw string `env:"HARNESS_PRODUCTION"`

	PostgresHost     string `env:"POSTGRES_HOST" envDefault:"postgres"`
	PostgresPort     string `env:"POSTGRES_PORT" envDefault:"5432"`
	PostgresDB       string `env:"POSTGRES_DB" envDefault:"db"`
	PostgresUser     string `env:"POSTGRES_USER" envDefault:"postgres"`
	PostgresPassword string `env:"POSTGRES_PASSWORD" envDefault:""`
	PostgresSchema   string `env:"POSTGRES_SCHEMA" envDefault:"work"`
	PostgresSSLMode  string `env:"POSTGRES_SSLMODE" envDefault:"require"`
	DBPoolMaxConns   int    `env:"DB_POOL_MAX_CONNS" envDefault:"20"`
	// PingDBAtStartup=false starts without touching Postgres/Redis (lazy connections), like authn.
	PingDBAtStartup bool `env:"PING_DB_AT_STARTUP" envDefault:"true"`

	UseSentinel        bool   `env:"USE_SENTINEL" envDefault:"false"`
	RedisSentinelHosts string `env:"REDIS_SENTINEL_HOSTS"`
	RedisMasterName    string `env:"REDIS_MASTER_NAME" envDefault:"mymaster"`
	RedisPassword      string `env:"REDIS_PASSWORD"`
	RedisHost          string `env:"REDIS_HOST" envDefault:"redis"`
	RedisPort          string `env:"REDIS_PORT" envDefault:"6379"`
	RedisDB            int    `env:"REDIS_DB" envDefault:"0"`
	// RedisPoolSize must exceed concurrent SSE tailers (each holds a connection during XREAD BLOCK).
	RedisPoolSize int `env:"REDIS_POOL_SIZE" envDefault:"256"`

	// LLMProvider is "openai" (any OpenAI-compatible endpoint at LLM_BASE_URL) or "anthropic".
	LLMProvider string `env:"LLM_PROVIDER" envDefault:"openai"`
	LLMBaseURL  string `env:"LLM_BASE_URL"`
	LLMAPIKey   string `env:"LLM_API_KEY"`
	// LLMProviderName is the selected provider (a name of Providers, or openai/anthropic);
	// LLMProvider is its type. LLMKeySource says where LLMAPIKey came from ("env LLM_API_KEY",
	// "auth.json", ...; never the key). Providers are the named providers of the config files.
	LLMProviderName string              `env:"-"`
	LLMKeySource    string              `env:"-"`
	Providers       map[string]Provider `env:"-"`

	// ExploreModel is EXPLORE_MODEL: the model of the read-only explore sub-agent of the coding profile
	// (default LLM_DEFAULT_MODEL; a cheaper model saves the most).
	ExploreModel string `env:"EXPLORE_MODEL"`
	// CodeChecks is CODE_CHECKS: ".ext=command;…" syntax checks run after write_file/edit_file ({path} is the
	// file; see codecheck.Defaults). They are on with AGENT_PROFILE=coding, or whenever this is set.
	CodeChecks string `env:"CODE_CHECKS"`
	// LLMSessionHeader is LLM_SESSION_HEADER: the name of a request header that carries the thread id, for
	// providers that route a conversation to one backend by session (OpenCode Go: x-opencode-session).
	LLMSessionHeader string `env:"LLM_SESSION_HEADER"`
	// LLMCacheTTL is the prompt-cache lifetime of the anthropic provider: "5m" (default) or "1h".
	LLMCacheTTL     string   `env:"LLM_CACHE_TTL"`
	LLMDefaultModel string   `env:"LLM_DEFAULT_MODEL" envDefault:"gpt-5.6-terra"`
	LLMModels       []string `env:"LLM_MODELS" envDefault:"gpt-5.6-sol,gpt-5.6-terra" envSeparator:","`
	// LLMDiscoverModels is LLM_DISCOVER_MODELS: at startup the harness asks the provider which models it serves
	// (GET {base}/models) and adds them to LLMModels, so the UI offers them and runs may use them. Off by default:
	// LLM_MODELS is an allow-list and discovery widens it to everything the key can reach.
	LLMDiscoverModels bool `env:"LLM_DISCOVER_MODELS"`
	LLMTimeout        int  `env:"LLM_TIMEOUT_SECONDS" envDefault:"300"`

	AgentMaxSteps           int `env:"AGENT_MAX_STEPS" envDefault:"60"`
	AgentMaxToolOutputChars int `env:"AGENT_MAX_TOOL_OUTPUT_CHARS" envDefault:"30000"`

	RuntimeConcurrency   int `env:"RUNTIME_CONCURRENCY" envDefault:"16"`
	RuntimeShutdownGrace int `env:"RUNTIME_SHUTDOWN_GRACE_SECONDS" envDefault:"15"`

	// SandboxBackend is "opensandbox" (default; needs OPENSANDBOX_URL) or "local": commands run
	// on this machine in LOCAL_WORKSPACE (default: the current directory), seen as /workspace.
	// The local backend has no isolation; use it on your own machine or inside a container.
	SandboxBackend string `env:"SANDBOX_BACKEND"`
	LocalWorkspace string `env:"LOCAL_WORKSPACE"`
	LocalStateDir  string `env:"LOCAL_STATE_DIR"`
	// AgentPermissions is AGENT_PERMISSIONS: ask (default on the local backend), auto-edit, yolo, yolo-unsafe or
	// readonly (see package permissions). It only applies to the local backend and the coding profile.
	AgentPermissions string `env:"AGENT_PERMISSIONS"`
	// AgentPermissionsAllow|Ask|Deny are AGENT_PERMISSIONS_ALLOW|ASK|DENY: extra rules, separated by newlines or ";;".
	AgentPermissionsAllow string `env:"AGENT_PERMISSIONS_ALLOW"`
	AgentPermissionsAsk   string `env:"AGENT_PERMISSIONS_ASK"`
	AgentPermissionsDeny  string `env:"AGENT_PERMISSIONS_DENY"`
	// UserInstructions is HARNESS_USER_INSTRUCTIONS: read the host user's ~/.har/AGENTS.md even with a remote
	// sandbox backend (the local backend always reads it). Off for servers: the host's home is not the tenants'.
	UserInstructions bool `env:"HARNESS_USER_INSTRUCTIONS"`

	OpenSandboxURL            string `env:"OPENSANDBOX_URL"`
	OpenSandboxAPIKey         string `env:"OPENSANDBOX_API_KEY"`
	OpenSandboxImage          string `env:"OPENSANDBOX_IMAGE" envDefault:"python:3.11-slim"`
	OpenSandboxUseServerProxy bool   `env:"OPENSANDBOX_USE_SERVER_PROXY" envDefault:"false"`
	// OpenSandboxCredentialProxy creates sandboxes with the egress sidecar's Credential Vault, so GitHub
	// authentication is added to outbound requests outside the sandbox and no token enters it. Needs
	// opensandbox-server >= 0.2.0 and egress >= 1.1.1 in dns+nft mode.
	OpenSandboxCredentialProxy bool     `env:"OPENSANDBOX_CREDENTIAL_PROXY" envDefault:"false"`
	SandboxTimeoutSeconds      int      `env:"SANDBOX_TIMEOUT_SECONDS" envDefault:"1800"`
	SandboxCommandTimeout      int      `env:"SANDBOX_COMMAND_TIMEOUT_SECONDS" envDefault:"120"`
	SandboxCPU                 string   `env:"SANDBOX_CPU" envDefault:"1"`
	SandboxMemory              string   `env:"SANDBOX_MEMORY" envDefault:"2Gi"`
	SandboxEgressAllowlist     []string `env:"SANDBOX_EGRESS_ALLOWLIST" envSeparator:","`
	// SandboxEgressUnrestricted explicitly accepts unrestricted sandbox egress in production.
	SandboxEgressUnrestricted bool `env:"SANDBOX_EGRESS_UNRESTRICTED" envDefault:"false"`
	// SandboxEgressDenyCIDRs are blocked in unrestricted mode (other sandboxes, host, proxy, metadata;
	// CGNAT pod ranges, "this network", IPv6 ULA and link-local, IPv4-mapped IPv6). Validated at load (C-19).
	SandboxEgressDenyCIDRs []string `` /* 173-byte string literal not displayed */
	// SandboxUnhealthyRecreate: a sandbox unhealthy for longer (and checked ≥ 3 times) is recreated.
	SandboxUnhealthyRecreate int `env:"SANDBOX_UNHEALTHY_RECREATE_SECONDS" envDefault:"300"`
	MaxSandboxesPerUser      int `env:"MAX_SANDBOXES_PER_USER" envDefault:"5"`

	MCPServersJSON string `env:"MCP_SERVERS"`
	MCPServers     []MCPServer
	// MCPAllowStdio is HARNESS_MCP_STDIO (or mcp.allow_stdio in the user's config.yml): MCP servers that are
	// local programs (stdio) may be started. Only with the local sandbox backend; a project file cannot set it.
	MCPAllowStdio bool `env:"HARNESS_MCP_STDIO"`

	GlitchtipDSN string `env:"GLITCHTIP_API_DSN"`

	// Harness v2 §1–§3: artifacts, attachments.
	ArtifactsS3Bucket    string `env:"ARTIFACTS_S3_BUCKET"`
	ArtifactsS3Endpoint  string `env:"ARTIFACTS_S3_ENDPOINT"`
	ArtifactsS3Region    string `env:"ARTIFACTS_S3_REGION" envDefault:"us-east-1"`
	ArtifactsS3PathStyle bool   `env:"ARTIFACTS_S3_PATH_STYLE" envDefault:"true"`
	ArtifactsS3Prefix    string `env:"ARTIFACTS_S3_PREFIX" envDefault:"harness/"`
	// ArtifactsS3CreateBucket creates the bucket at startup when missing (local RustFS; production buckets are provisioned).
	ArtifactsS3CreateBucket bool   `env:"ARTIFACTS_S3_CREATE_BUCKET"`
	AWSAccessKeyID          string `env:"AWS_ACCESS_KEY_ID"`
	AWSSecretAccessKey      string `env:"AWS_SECRET_ACCESS_KEY"`
	// MaxUploadBytes bounds one attachment (413 file_too_large beyond).
	MaxUploadBytes int64 `env:"HARNESS_MAX_UPLOAD_BYTES" envDefault:"104857600"`
	// MaxConcurrentUploads bounds uploads per api process (429 too_many_uploads beyond).
	MaxConcurrentUploads int `env:"HARNESS_MAX_CONCURRENT_UPLOADS" envDefault:"4"`
	// MaxConcurrentUploadsPerUser bounds one user's uploads per api process (429 too_many_uploads beyond).
	// Default 4: the composer uploads 4 files in parallel.
	MaxConcurrentUploadsPerUser int `env:"HARNESS_MAX_CONCURRENT_UPLOADS_PER_USER" envDefault:"4"`
	// PreviewMaxConcurrency bounds the Office → PDF conversions per api process.
	PreviewMaxConcurrency int `env:"PREVIEW_MAX_CONCURRENCY" envDefault:"2"`
	// PurgeAfterDays: deleted threads are hard-deleted (with their artifacts and
	// unreferenced blobs) this many days after deletion (≤ 0 disables the purge).
	PurgeAfterDays int `env:"HARNESS_PURGE_AFTER_DAYS" envDefault:"30"`
	// BlobGCGraceHours: a content blob is only deleted once it has had no
	// artifact version referencing it for this many hours (≤ 0: 24), so content
	// reused by a concurrent upload or snapshot is never collected.
	BlobGCGraceHours int `env:"HARNESS_BLOB_GC_GRACE_HOURS" envDefault:"24"`
	// Workspace checkpoints (README "Workspace checkpoints"): a local Git checkpoint of
	// /workspace before every AI turn, per-file history / diff / restore, and the
	// .git history archived (tar.gz, at most HARNESS_GIT_ARCHIVE_MAX_BYTES; a larger
	// one is not archived) into the blob store after each run, restored into
	// every new sandbox of the thread. Files larger than
	// HARNESS_WORKSPACE_CHECKPOINT_MAX_FILE_BYTES (default 20 MiB, ≤ 0: no limit)
	// are kept out of the checkpoints (large uploads would exceed the archive cap).
	WorkspaceCheckpoints bool  `env:"HARNESS_WORKSPACE_CHECKPOINTS" envDefault:"true"`
	GitArchiveMaxBytes   int64 `env:"HARNESS_GIT_ARCHIVE_MAX_BYTES" envDefault:"52428800"`
	CheckpointMaxFile    int64 `env:"HARNESS_WORKSPACE_CHECKPOINT_MAX_FILE_BYTES" envDefault:"20971520"`

	// SkillsDir is the user skills directory (SKILLS_DIR; "" = ~/.har/skills,
	// see SkillsPath): one <name>/SKILL.md folder per skill.
	SkillsDir string `env:"SKILLS_DIR"`

	// Memory (README "Configuration"): write policy (warn records missing
	// triggers, strict blocks them), delete mode (soft keeps the entry as
	// deleted until the retention, hard removes it), default scope, embedding
	// backend (simple = bag-of-words cosine; disabled|none|keyword only
	// change the reported capabilities), the recalled memories in the
	// system prompt, the limits (≤ 0 entries: no limit)
	// and the consolidation job (dedup + purge of deleted entries; ≤ 0 hours disables it).
	MemoryWriteMode            string `env:"HARNESS_MEMORY_WRITE_MODE" envDefault:"warn"`
	MemoryDeleteMode           string `env:"HARNESS_MEMORY_DELETE_MODE" envDefault:"soft"`
	MemoryDefaultScope         string `env:"HARNESS_MEMORY_DEFAULT_SCOPE" envDefault:"personal"`
	MemoryEmbeddingBackend     string `env:"HARNESS_MEMORY_EMBEDDING_BACKEND" envDefault:"simple"`
	MemoryRecallInjection      bool   `env:"HARNESS_MEMORY_RECALL_INJECTION" envDefault:"true"`
	MemoryMaxEntries           int    `env:"HARNESS_MEMORY_MAX_ENTRIES" envDefault:"1000"`
	MemoryMaxContentBytes      int    `env:"HARNESS_MEMORY_MAX_CONTENT_BYTES" envDefault:"200000"`
	MemoryConsolidationHours   int    `env:"HARNESS_MEMORY_CONSOLIDATION_HOURS" envDefault:"168"`
	MemoryDeletedRetentionDays int    `env:"HARNESS_MEMORY_DELETED_RETENTION_DAYS" envDefault:"30"`
	// MemoryExtract proposes memories from each completed run (pending until confirmed), with
	// MemoryExtractModel (default: the run's model). With HARNESS_MEMORY_EMBEDDING_BACKEND=openai,
	// entries and queries get vectors from the OpenAI-compatible endpoint MemoryEmbeddingURL
	// (default: LLM_BASE_URL, else api.openai.com) with MemoryEmbeddingKey (default LLM_API_KEY).
	MemoryExtract        bool   `env:"HARNESS_MEMORY_EXTRACT"`
	MemoryExtractModel   string `env:"HARNESS_MEMORY_EXTRACT_MODEL"`
	MemoryEmbeddingURL   string `env:"HARNESS_MEMORY_EMBEDDING_URL"`
	MemoryEmbeddingKey   string `env:"HARNESS_MEMORY_EMBEDDING_KEY"`
	MemoryEmbeddingModel string `env:"HARNESS_MEMORY_EMBEDDING_MODEL"`
	// Harness v2 §4–§9 (context windows, reasoning/vision models — LLM_VISION_MODELS
	// also decides which models receive attached images —, compaction).
	Harness
	// Harness v3 loop & context (loop.go): stream idle timeout, step retries, tool
	// output spill, in-run masking, output reserve, reasoning passback, MCP call
	// timeout, DeepSeek defaults.
	Loop
	// Harness v3 (stream C2): LLM_PROMPT_VARIANTS, LLM_REASONING_EFFORTS (prompts.go).
	PromptAndEfforts
	// Tool and prompt selection per profile: AGENT_TOOLS, SKILLS_IN_CODING, MEMORY_IN_CODING (toolprofile.go).
	ToolProfile
	// Stream R: models called through the Responses API (LLM_RESPONSES_MODELS, responses.go).
	Responses
	// Harness v3 runtime & API (stream B): RUNTIME_TERMINATION_GRACE_SECONDS,
	// MAX_STREAMS_PER_USER, APPROVAL_TTL_HOURS, APPROVAL_RISKY_TOOL_PATTERNS (runtime_api.go).
	RuntimeAPI

	// Layers says how the configuration was assembled (files, sources of the values); see LoadWith.
	Layers *Layers `env:"-"`
	// contains filtered or unexported fields
}

Config is the whole service configuration. See README "Configuration".

func Load

func Load() (*Config, error)

Load reads the configuration: built-in defaults, then ~/.har/config.yml, then the nearest <repo>/.har/config.yml, then the process environment (the command line flags of a host are applied by the host on top).

func LoadWith

func LoadWith(o LoadOptions) (*Config, error)

LoadWith is Load with options.

func (*Config) AddModels

func (c *Config) AddModels(ids ...string)

AddModels appends the ids missing from the LLM_MODELS allow-list, keeping the configured ones first. Call it before the configuration is shared (the harness does so in New); it is not safe against concurrent readers.

func (*Config) CallCeiling

func (c *Config) CallCeiling() time.Duration

CallCeiling is LLM_CALL_MAX_SECONDS: no model call lasts longer, whatever its stream sends.

func (*Config) CommandTimeout

func (c *Config) CommandTimeout() time.Duration

CommandTimeout is the default execute_command timeout.

func (*Config) ContextWindow

func (c *Config) ContextWindow(model string) int

ContextWindow is the context window of a model in tokens.

func (*Config) Dump

func (c *Config) Dump(w io.Writer, flags map[string]string)

Dump writes the effective configuration to w: every setting that does not have its built-in default value, with where it comes from. flags are the settings given on the command line (name -> value), which win over the rest. Secrets are masked.

func (*Config) EffortAllowed

func (c *Config) EffortAllowed(model, effort string) bool

EffortAllowed reports whether a run may ask model for effort ("" always may).

func (*Config) EffortFor

func (c *Config) EffortFor(model, effort string) string

EffortFor is the effort actually sent for a run's effort: itself when the model accepts it, else the nearest accepted one (a tie goes to the higher effort; e.g. "minimal" becomes "low" on GPT-5.6), "" for other models.

func (*Config) EgressMode

func (c *Config) EgressMode() (string, error)

EgressMode is the effective sandbox egress: "disabled" (no sandbox), "allowlist" or "unrestricted". In production unrestricted egress must be explicitly accepted with SANDBOX_EGRESS_UNRESTRICTED=true; otherwise an error is returned.

func (*Config) IsDebug

func (c *Config) IsDebug() bool

IsDebug reports debug mode: on unless HARNESS_PRODUCTION is set.

func (*Config) LocalSandbox

func (c *Config) LocalSandbox() bool

LocalSandbox reports whether tools run on this machine (SANDBOX_BACKEND=local).

func (*Config) MCPCallTimeout

func (c *Config) MCPCallTimeout() time.Duration

MCPCallTimeout is MCP_CALL_TIMEOUT_SECONDS (≤ 0: 120 s).

func (*Config) ModelAllowed

func (c *Config) ModelAllowed(model string) bool

ModelAllowed reports whether a model id is in the LLM_MODELS allow-list.

func (*Config) ModelLabel

func (c *Config) ModelLabel(model string) string

ModelLabel is the display name of a model (LLM_MODEL_LABELS, else its id).

func (*Config) OutputReserve

func (c *Config) OutputReserve(model string) int

OutputReserve is the part of a model's window kept free below the compaction trigger: its max output tokens (LLM_MAX_OUTPUT_TOKENS, default 16000) + 20k.

func (*Config) PostgresDSN

func (c *Config) PostgresDSN() string

PostgresDSN builds the pgx DSN.

func (*Config) PromptCacheKey

func (c *Config) PromptCacheKey(model string) bool

PromptCacheKey reports whether calls of a model send prompt_cache_key (DeepSeek rejects unknown fields).

func (*Config) PromptVariant

func (c *Config) PromptVariant(model string) string

PromptVariant is the system prompt variant of a model.

func (*Config) ReasoningEffortsOf

func (c *Config) ReasoningEffortsOf(model string) []string

ReasoningEffortsOf lists the reasoningEffort values a model accepts (nil: none, not a reasoning model).

func (*Config) ReasoningPassback

func (c *Config) ReasoningPassback(model string) bool

ReasoningPassback reports whether a model's assistant messages carry their reasoning back.

func (*Config) RequireLLMKey

func (c *Config) RequireLLMKey() error

RequireLLMKey returns a helpful error when the selected provider has no API key. Endpoints on the local machine (Ollama, llama.cpp ...) need none.

func (*Config) SandboxBackendName

func (c *Config) SandboxBackendName() string

SandboxBackendName is the name of the selected sandbox backend (lower case): SANDBOX_BACKEND when set (a built-in or one a host registered with backends.Register), else "opensandbox" when OPENSANDBOX_URL is set, else "none".

func (*Config) SandboxEnabled

func (c *Config) SandboxEnabled() bool

SandboxEnabled reports whether sandbox tools are configured.

func (*Config) SandboxTimeout

func (c *Config) SandboxTimeout() time.Duration

SandboxTimeout is the idle lifetime of a sandbox.

func (*Config) SkillsPath

func (c *Config) SkillsPath() string

SkillsPath is the user skills directory: SKILLS_DIR, else ~/.har/skills ("" when the home directory is unknown).

func (*Config) StreamIdle

func (c *Config) StreamIdle() time.Duration

StreamIdle is LLM_STREAM_IDLE_SECONDS.

func (*Config) SupportsReasoning

func (c *Config) SupportsReasoning(model string) bool

SupportsReasoning reports whether a model accepts reasoningEffort (LLM_REASONING_MODELS).

func (*Config) SupportsVision

func (c *Config) SupportsVision(model string) bool

SupportsVision reports whether a model accepts image parts (LLM_VISION_MODELS).

func (*Config) Threshold

func (c *Config) Threshold() float64

Threshold is CompactionThreshold with its default when unset (tests build Config literals).

func (*Config) UnsupportedEffort

func (c *Config) UnsupportedEffort(model, effort string) bool

UnsupportedEffort reports a run effort a reasoning model does not accept (non-reasoning models ignore efforts: never unsupported).

func (*Config) UsesResponses

func (c *Config) UsesResponses(model string) bool

UsesResponses reports whether a model is called through the Responses API.

type Harness

type Harness struct {
	// The defaults describe Work's GPT-5.6 Sol / Terra (reasoning, vision; the
	// 272k input window Codex ships for these slugs — harness v3 §5, A-02).
	// LLMContextWindowsRaw is LLM_CONTEXT_WINDOWS: "model=tokens,…".
	LLMContextWindowsRaw string `env:"LLM_CONTEXT_WINDOWS" envDefault:"gpt-5.6-sol=272000,gpt-5.6-terra=272000"`
	LLMContextWindows    map[string]int
	// LLMReasoningModels accept reasoningEffort.
	LLMReasoningModels []string `env:"LLM_REASONING_MODELS" envDefault:"gpt-5.6-sol,gpt-5.6-terra" envSeparator:","`
	// LLMVisionModels accept image parts.
	LLMVisionModels []string `env:"LLM_VISION_MODELS" envDefault:"gpt-5.6-sol,gpt-5.6-terra" envSeparator:","`
	// LLMModelLabelsRaw is LLM_MODEL_LABELS: "model=Label,…" shown by /models (default: the id).
	LLMModelLabelsRaw string `env:"LLM_MODEL_LABELS" envDefault:"gpt-5.6-sol=GPT-5.6 Sol,gpt-5.6-terra=GPT-5.6 Terra"`
	LLMModelLabels    map[string]string
	// LLMPresetsRaw is LLM_PRESETS: the ordered stops of the composer's "thinking"
	// slider, "id=model:effort,…" (effort optional: "id=model" or "id=model:" keeps
	// the model's default effort). GPT-5.6 Sol costs about twice Terra (list
	// prices), so Terra covers the fast/balanced stops and Sol thinking/deep.
	// caarlos0/env applies envDefault to an empty value (like every list here), so
	// "none" is the explicit way to configure no presets (the UI then shows the
	// separate model and reasoning menus).
	// The built-in default is dropped (no slider, PresetsSkipped says why) when
	// LLM_MODELS / LLM_REASONING_MODELS lack its models, so deployments with other
	// models keep starting; an explicit LLM_PRESETS is always validated strictly.
	LLMPresetsRaw string `` // = DefaultPresets
	/* 133-byte string literal not displayed */
	LLMPresets []LLMPreset
	// PresetsSkipped explains why the default LLM_PRESETS was dropped (logged at startup).
	PresetsSkipped string
	// LLMDefaultPreset is LLM_DEFAULT_PRESET: the stop of new threads (must be in LLM_PRESETS; ignored with "none").
	LLMDefaultPreset string `env:"LLM_DEFAULT_PRESET" envDefault:"balanced"`
	// CompactionThreshold is the share of the context window that triggers
	// compaction; unset (0): window − OutputReserve (harness v3 §5).
	CompactionThreshold float64 `env:"COMPACTION_THRESHOLD"`
	// CompactionModel summarizes old context (default: the run's model).
	CompactionModel string `env:"COMPACTION_MODEL"`
}

Harness is the harness v2 configuration (context management, model metadata).

type LLMPreset

type LLMPreset struct {
	ID              string `json:"id"`
	Model           string `json:"model"`
	ReasoningEffort string `json:"reasoningEffort"`
}

LLMPreset is one stop of the thinking slider: a (model, reasoning effort) pair.

type Layers

type Layers struct {
	// ProjectRoot is the project directory (the parent of the .har directory,
	// else the git root, else the starting directory); ProjectDir is its .har
	// directory ("" when there is none).
	ProjectRoot, ProjectDir string
	UserDir                 string
	// AuthFile is the credentials file when the API key came from it.
	AuthFile string
	// ProjectFile and UserFile are the config.yml files that were read ("" if absent).
	ProjectFile, UserFile string
	// Values and Sources are keyed by the environment variable name.
	Values  map[string]string
	Sources map[string]Source
	// MCPSources lists, in priority order (lowest first), the files MCP servers were read from.
	MCPSources []string
	// MCPSkipped are the MCP servers that were not started and why.
	MCPSkipped []string
	// MCPPending are the stdio servers of the (trusted) project that wait for the user's approval of their command.
	MCPPending []MCPServer
	// Trusted says the project is trusted (see TrustFile); TrustedBy says how ("trust.json" or the environment).
	Trusted   bool
	TrustedBy string
	// Ignored lists the settings of the project that were not honoured, and why (an untrusted project
	// cannot loosen the permissions).
	Ignored []string
	// contains filtered or unexported fields
}

Layers records how a Config was assembled: the files read and, for every setting taken from the environment or a file, its source.

type LoadOptions

type LoadOptions struct {
	// Dir is where the project directory is searched from (walking up to the
	// git root). Default: LOCAL_WORKSPACE of the environment, else the working directory.
	Dir string
	// UserDir is the user configuration directory (default ~/.har).
	UserDir string
	// Environ is the process environment ("K=V" entries; default os.Environ()).
	Environ []string
	// Provider selects a named provider (the -provider flag); it wins over
	// LLM_PROVIDER and the files.
	Provider string
	// NoFiles ignores the configuration files (environment only).
	NoFiles bool
}

LoadOptions tune LoadWith. The zero value reads the process environment and the files of the working directory and of the home directory (what Load does).

type Loop

type Loop struct {
	// LLMStreamIdleSeconds bounds the gap between two chunks of a model stream.
	LLMStreamIdleSeconds int `env:"LLM_STREAM_IDLE_SECONDS" envDefault:"90"`
	// LLMStepRetries is how often a failed model call is re-issued as a whole step.
	LLMStepRetries int `env:"LLM_STEP_RETRIES" envDefault:"3"`
	// ToolOutputSpillChars: longer tool outputs are written to /workspace/.work/tool-output/.
	ToolOutputSpillChars int `env:"AGENT_TOOL_OUTPUT_SPILL_CHARS" envDefault:"20000"`
	// KeepRecentToolResults: older tool results are masked in the model input (in-run masking).
	KeepRecentToolResults int `env:"COMPACTION_KEEP_RECENT_TOOL_RESULTS" envDefault:"6"`
	// MaskFromFraction: masking starts once the prompt passes this share of the
	// window (round 3, A1; 0: from the first step, as in v3).
	MaskFromFraction float64 `env:"COMPACTION_MASK_FROM_FRACTION" envDefault:"0.5"`
	// LLMCallMaxSeconds bounds one model call whatever the stream sends (round 3, N3).
	LLMCallMaxSeconds int `env:"LLM_CALL_MAX_SECONDS" envDefault:"1200"`
	// LLMMaxOutputTokensRaw is LLM_MAX_OUTPUT_TOKENS: "model=tokens,…", the output
	// reserved below the window (compaction at window − (max output + 20k)); not sent to the provider.
	LLMMaxOutputTokensRaw string `env:"LLM_MAX_OUTPUT_TOKENS"`
	LLMMaxOutputTokens    map[string]int
	// LLMReasoningPassbackModels get their reasoning_content back on assistant
	// messages (default: the DeepSeek models of LLM_MODELS).
	LLMReasoningPassbackModels []string `env:"LLM_REASONING_PASSBACK_MODELS" envSeparator:","`
	// LLMPromptCacheKey sends prompt_cache_key (the thread id) to the openai provider (disable for endpoints that reject unknown fields).
	LLMPromptCacheKey bool `env:"LLM_PROMPT_CACHE_KEY" envDefault:"true"`
	// MCPCallTimeoutSeconds bounds one MCP tool call.
	MCPCallTimeoutSeconds int `env:"MCP_CALL_TIMEOUT_SECONDS" envDefault:"120"`
}

Loop is the harness v3 loop & context configuration (docs/harness-v3.md §1, §2 spill, §5, §10). DeepSeek models ("deepseek/…" ids of LLM_MODELS) get their defaults (1M window, reasoning effort, reasoning passback, no prompt_cache_key) unless the lists name them; their prompt variant is stream C2's (LLM_PROMPT_VARIANTS).

type MCPServer

type MCPServer struct {
	Name    string            `json:"name"`
	URL     string            `json:"url,omitempty"`
	Tools   []string          `json:"tools,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	// Type is "http" (streamable HTTP, the default for a URL), "sse" or "stdio".
	Type    string            `json:"type,omitempty"`
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	// Origin says where the definition was read from (for messages and -config-dump).
	Origin string `json:"-"`
	// ProjectRoot is set on a server a project file defines (.mcp.json, .har/mcp.json, the project config.yml):
	// a stdio one needs the user's approval for this exact command before it is started (MCPApproved).
	ProjectRoot string `json:"-"`
	// Untrusted marks a server that came from the database (a catalog entry or a custom server a user added):
	// it is dialled through the SSRF-guarded transport, never started as a process, and, with no Tools list,
	// offers only the tools its own annotations declare readOnlyHint. It is never read from a file or JSON.
	Untrusted bool `json:"-"`
}

MCPServer is one MCP server: an entry of MCP_SERVERS, of a .mcp.json file or of the mcp.servers section of config.yml. A remote server has a URL (and maybe headers), a local one a Command that is started as a child process (stdio; see Config.MCPAllowStdio).

func (MCPServer) Describe

func (s MCPServer) Describe() string

Describe is a one-line summary without header or environment values.

func (MCPServer) IsStdio

func (s MCPServer) IsStdio() bool

IsStdio reports a server started as a local child process.

type MCPTrust

type MCPTrust struct {
	Project string `json:"project"`
	Server  string `json:"server"`
	Hash    string `json:"command_sha256"`
}

MCPTrust records that the user approved running one stdio MCP server that a project defines: the project root, the server name and the SHA-256 of its command and arguments (MCPFingerprint). Changing the command or an argument no longer matches, so the server must be approved again.

type PromptAndEfforts

type PromptAndEfforts struct {
	// LLMPromptVariantsRaw is LLM_PROMPT_VARIANTS: "model=variant,…" with the
	// variants of internal/agent/prompts (default, gpt-5.6, deepseek, coding).
	// Models not listed use deepseek when their name contains "deepseek",
	// else default.
	// AgentProfile is AGENT_PROFILE: "work" (default, documents and data), "minimal" (sandbox and plan tools only) or "coding": models not
	// listed in an explicit LLM_PROMPT_VARIANTS then use the coding prompt, which also loads AGENTS.md.
	AgentProfile         string `env:"AGENT_PROFILE"`
	LLMPromptVariantsRaw string `env:"LLM_PROMPT_VARIANTS" envDefault:"gpt-5.6-sol=gpt-5.6,gpt-5.6-terra=gpt-5.6"`
	LLMPromptVariants    map[string]string
	// LLMReasoningEffortsRaw is LLM_REASONING_EFFORTS: "model=effort|effort…,…",
	// the reasoningEffort values a model accepts (GPT-5.x from 5.1: no
	// "minimal"; "none" and "xhigh" exist). Reasoning models not listed accept
	// DefaultReasoningEfforts.
	LLMReasoningEffortsRaw string `env:"LLM_REASONING_EFFORTS" envDefault:"gpt-5.6-sol=none|low|medium|high|xhigh,gpt-5.6-terra=none|low|medium|high|xhigh"`
	LLMReasoningEfforts    map[string][]string
}

PromptAndEfforts is the prompt variant and reasoning effort configuration (harness v3 §6, A-29).

type Provider

type Provider struct {
	Name string
	// Type is "openai" (any OpenAI-compatible endpoint) or "anthropic".
	Type          string
	BaseURL       string
	SessionHeader string
	CacheTTL      string
	// APIKeyEnv is the NAME of the environment variable that holds the key.
	APIKeyEnv    string
	Models       []string
	DefaultModel string
	// Origin is the layer that defined the provider (always the user file: a project cannot define one).
	Origin Source
}

Provider is a named model provider: an entry of the providers section of a config.yml. The built-in providers are the bare types "openai" and "anthropic" (LLM_BASE_URL defaults); a name defined here is selected with provider: <name> or -provider <name>.

type Responses

type Responses struct {
	// LLMResponsesModels are the LLM_MODELS ids called through the Responses API
	// ("none": every model uses Chat Completions). Only the openai provider
	// (LLM_BASE_URL/responses) has a Responses API.
	LLMResponsesModels []string `env:"LLM_RESPONSES_MODELS" envDefault:"gpt-5.6-sol,gpt-5.6-terra" envSeparator:","`
}

Responses selects the models called through the OpenAI Responses API (stream R, docs/harness-v3.md "R" block): their reasoning items are carried across tool steps and runs. Other models stay on Chat Completions.

type RuntimeAPI

type RuntimeAPI struct {
	// RuntimeTerminationGrace is the pod's terminationGracePeriodSeconds: the
	// whole shutdown (HTTP drain, runs, archives, Sentry) must fit it.
	RuntimeTerminationGrace int `env:"RUNTIME_TERMINATION_GRACE_SECONDS" envDefault:"30"`
	// MaxStreamsPerUser caps concurrent SSE streams of one user per api process
	// (429 too_many_streams beyond).
	MaxStreamsPerUser int `env:"MAX_STREAMS_PER_USER" envDefault:"8"`
	// ApprovalTTLHours: a pending approval older than this expires.
	ApprovalTTLHours int `env:"APPROVAL_TTL_HOURS" envDefault:"72"`
	// ApprovalRiskyToolPatterns: MCP tools with a name word starting with one of
	// these (case-insensitive regexp alternatives) need approval in interactive mode.
	ApprovalRiskyToolPatterns string `env:"APPROVAL_RISKY_TOOL_PATTERNS" envDefault:"create|send|update|delete|post|publish|write"`
	// RiskyToolPattern is ApprovalRiskyToolPatterns compiled (nil when empty).
	RiskyToolPattern *regexp.Regexp `env:"-"`
}

RuntimeAPI holds the harness v3 settings of the runtime & API stream (docs/harness-v3.md §7–§9, README "Harness v3: runtime & API").

type Source

type Source string

Source says where a setting's value comes from.

const (
	SourceFlag    Source = "flag"
	SourceEnv     Source = "env"
	SourceProject Source = "project file"
	SourceUser    Source = "user file"
)

The layers, from the highest priority to the lowest.

type ToolProfile

type ToolProfile struct {
	// AgentTools is AGENT_TOOLS: a comma list over the profile's default tools.
	// "+name" adds a tool, "-name" removes one, a bare "name" list replaces the
	// default set. "memory" stands for the memory_* tools and their prompt
	// section, "skills" for load_skill and the skills index. Tools that are not
	// built in (MCP, web search, host tools) stay unless removed.
	AgentTools string `env:"AGENT_TOOLS"`
	// SkillsInCoding keeps load_skill and the skills index in the coding
	// profile even when no skill was installed or attached.
	SkillsInCoding bool `env:"SKILLS_IN_CODING"`
	// MemoryInCoding keeps the memory tools and prompt in the coding profile
	// (off by default there; the work profile is unaffected).
	MemoryInCoding bool `env:"MEMORY_IN_CODING"`
}

ToolProfile selects the built-in tools and prompt sections of a profile (profile.go of the harness package). The work profile offers everything; the coding profile leaves out what a coding agent rarely needs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL