DocsSub-Contexts & Memory
Dynamic Prompt Engineering

Sub-Contexts & Dynamic Memory

Static system prompts cause cognitive drift during long coding tasks. Smoke Monkey introduces Sub-Contexts: modular, named memory blocks rendered into the prompt under ## <Title> that can be activated, deactivated, or swapped at runtime.

Built-In Sub-Contexts

Active Goalgoal

High-level milestone guidance and user requirements.

Current Tasktask

Decomposed step-by-step checklist of immediate actions.

Research Moderesearch_mode

Puts the model in a read-first exploratory posture.

Project Invariantsconstants

Immutable rules (e.g. do not modify package-lock.json).

Working Memorynotes

Scratchpad for findings during long, multi-turn runs.

Active Skillsskills

Container where activated SKILL.md workflows are loaded.

Registering Custom Sub-Contexts

subcontexts.tstypescript
import { createAgent, registerSubContext } from '@smoke-monkey/harness';
// 1. Register a modular domain guideline
registerSubContext({
id: 'strict_typing',
title: 'Strict TypeScript Standards',
summary: 'Enforces no-any and runtime Zod validation',
content: '## Guidelines: Strict TypeScript typing rules',
lockMode: 'locked', // Prevents the LLM from removing these rules
});
// 2. Pre-activate sub-contexts on startup
const agent = createAgent({
workspacePath: process.cwd(),
defaultSubContexts: ['goal', 'task', 'strict_typing'],
sessionId: 'user-session-987', // Persists memory across runs
});
// The agent autonomously calls context_manage({ action: 'swap', id: 'research_mode' });

Next: Lifecycle Hooks & Observability

Learn how to intercept tool calls and inspect structured error objects.