agentcontext

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 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 agentcontext assembles the system-context string handed to any agent. It is the Go counterpart of lib/tasks/agent_context.rb, and it is the single assembler: the CLI `tasks -p` path and (later) the TUI queue both build through here, so they can never disagree about what an agent sees.

In order:

  1. the repository TASK_AGENT.md contract (list-agent instructions),
  2. a short "Current environment" block (datetime, hostname, …) when enabled,
  3. the absolute file locations for this run (CLI, task files, memory),
  4. a short pointer to the task-set memory policy, and
  5. the current contents of agent-memory.md, clearly delimited as user-approved defaults, when that sidecar exists and is nonempty.

Coding-agent instructions live in AGENTS.md and are intentionally not injected here — workspace tools load that file separately.

The memory sidecar is read fresh on every call — never cached — so a default saved by one request is visible to the next, and an external edit or a git pull is picked up without restarting. An absent file simply omits the memory section; the builder never creates the file as a side effect.

Index

Constants

View Source
const (
	MemoryHeader = "User-approved task-set defaults from agent-memory.md. These are " +
		"durable defaults for this task set; the current request still wins."
	MemoryBegin = "----- BEGIN AGENT MEMORY -----"
	MemoryEnd   = "----- END AGENT MEMORY -----"

	// MemoryPointer is a short pointer only. The full policy prose lives in
	// TASK_AGENT.md (item 1), the versioned list-agent contract, so it is never
	// duplicated as a string that would drift out of sync.
	MemoryPointer = "Task-set memory: apply the agent-memory.md defaults per the memory " +
		"policy in TASK_AGENT.md — add, change, or remove them only on an " +
		"explicit request, and report any change alongside task changes."
)
View Source
const Contract = "TASK_AGENT.md"

Contract is the source name of the versioned list-agent contract embedded in every binary. Installed builds must not depend on a source checkout.

View Source
const MemoryMaxBytes = 16 * 1024 // 16 KiB

MemoryMaxBytes is the prompt-injection budget for the memory sidecar. A larger file is a configuration mistake, so it fails loudly with the path instead of silently truncating a default the agent would then only half-apply.

Variables

This section is empty.

Functions

func Build

func Build(paths config.Paths, cliExecutable string, sources promptfacts.Sources) (string, error)

Build assembles the whole context. cliExecutable is the installed tasks command — distinct from the task-data directory the harness runs in.

func FileLocations

func FileLocations(paths config.Paths, cliExecutable string) string

FileLocations is Config::Paths#agent_context: the block that lets a headless harness find the CLI and the task files even when they live outside the repo. Provider-agnostic — every backend uses it unchanged.

The memory sidecar path is always listed, even when the file does not exist yet, so an agent can create or edit it without guessing.

The CLI it names is the resolved executable path. That keeps agent prompts correct for Homebrew, make install, symlinks, and development builds.

func MemorySection

func MemorySection(path string) (string, error)

MemorySection is the delimited memory block, or "" when the sidecar is absent or empty. An unreadable, invalid-UTF-8, oversize, or delimiter-carrying file is a hard error carrying the path — never a silent skip that would run the agent without the user's saved defaults.

Types

type Error

type Error struct{ Message string }

Error is raised when the memory sidecar exists but cannot be safely injected (unreadable, invalid UTF-8, oversize, or carrying a reserved delimiter). Callers surface the message and abort the run rather than proceed without the user's defaults — a half-applied default is worse than a refused request.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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