Skip to content

feat: wire customInstructions from plugin config#181

Open
jamebobob wants to merge 1 commit intoMartian-Engineering:mainfrom
jamebobob:feat/custom-instructions-config
Open

feat: wire customInstructions from plugin config#181
jamebobob wants to merge 1 commit intoMartian-Engineering:mainfrom
jamebobob:feat/custom-instructions-config

Conversation

@jamebobob
Copy link

Summary

The customInstructions parameter threads through all 4 prompt builders (buildLeafSummaryPrompt, buildD1Prompt, buildD2Prompt, buildD3PlusPrompt) but is never read from config. Operators cannot control summarization tone or style without patching source.

This matters because LCM summaries are injected into the agent's context window via DAG assembly — the summarizer's voice becomes the agent's voice. AugmentedMind's ResonantOS article documents how the memoryFlush gap under LCM leaves operators without control over what persists through compaction. Operator-controlled summarization instructions are a step toward closing that gap.

Changes

  • src/db/config.ts: Add customInstructions: string to LcmConfig type and resolver. Follows the same 3-tier precedence as summaryModel: env (LCM_CUSTOM_INSTRUCTIONS) → plugin config → default ("").
  • src/engine.ts: Read this.config.customInstructions as fallback in resolveSummarize() — the single chokepoint all summarization paths pass through. Explicit caller values still win.
  • openclaw.plugin.json: Add customInstructions to configSchema.properties and uiHints.
  • test/custom-instructions.test.ts: Config test coverage: defaults, plugin config, env override, trimming, type coercion, manifest schema.

Usage

{
  "plugins": {
    "entries": {
      "lossless-claw": {
        "config": {
          "customInstructions": "Write as a neutral documenter, not as the assistant. Use third person. Report what happened, not its significance."
        }
      }
    }
  }
}

This gives operators control over summarization tone. For example, an operator running a long-lived agent might want summaries written in third person to prevent the summarizer's editorial voice from propagating into agent output through DAG assembly.

Design

The change is minimal by design: one config field, one fallback line in the chokepoint. No caller changes needed — afterTurn, /compact, overflow recovery, and any future compaction path all get instructions automatically.

caller → resolveSummarize() → createLcmSummarizeFromLegacyParams() → prompt builders
                ↑
    params.customInstructions || this.config.customInstructions || undefined

The customInstructions parameter threads through all 4 prompt builders
(buildLeafSummaryPrompt, buildD1Prompt, buildD2Prompt, buildD3PlusPrompt)
but is never read from config. This means operators cannot control
summarization tone or style without patching source.

Fix:
- Add customInstructions to LcmConfig type and resolver (config.ts)
- Read in resolveSummarize() chokepoint (engine.ts) with fallback:
  params.customInstructions || this.config.customInstructions || undefined
- Add to plugin schema and uiHints (openclaw.plugin.json)
- Add config test coverage (test/custom-instructions.test.ts)

Every summarization path (afterTurn, /compact, overflow recovery) gets
instructions automatically through the chokepoint without caller changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant