Skip to main content

Purpose

The workspace is the foundation of a HarnessAgent: persona, long-term memory, domain knowledge, subagent declarations, session history, and skill definitions all land here as a directory structure + Markdown — no longer scattered in code. Before every reasoning turn, a few key workspace files are automatically injected into the system prompt. Memory and session output from the running agent is also written back here along well-defined paths.

Trigger Points

Directory Layout

The three-layer model for subagents (declaration / definition / runtime) is detailed in Subagent.

Key Logic

Two-Layer Read / Write

WorkspaceManager is a stateless accessor; all reads and writes follow the same contract: Key points:
  • Read path: AbstractFilesystem first → local disk fallback, making multi-tenant scenarios transparent to callers
  • Write path: defaults to AbstractFilesystem; falls back to local disk when not configured
  • List operations (listKnowledgeFiles / listMemoryFilePaths / listSessionLogFiles) take the union of both layers and deduplicate, avoiding missing files

System Prompt Injection Content

WorkspaceContextHook (priority 900) assembles a fixed-structure text segment on PreReasoningEvent and merges it into the first SYSTEM message: maxContextTokens defaults to 8000 (estimated as chars/4). When MEMORY.md estimated size exceeds the “remaining budget”, it is character-truncated and appended with ... (memory truncated — use memory_search for older entries) ..., prompting the agent to fall back to memory_search.

Key APIs

Configuration

If AGENTS.md is missing, the agent still works but loses the persona section. It is recommended to at least write a minimal skeleton (see the quickstart in overview.md).
  • ArchitectureWorkspaceContextHook position in the call() lifecycle
  • Filesystem — implementation of the “upper layer” in the two-layer read path
  • Memory — how MEMORY.md / memory/*.md are generated and maintained
  • Session — details of agents/<agentId>/sessions/