Skip to content

feat(middleware): implement system prompt builder (#28)#29

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/system-prompt-builder
Feb 26, 2026
Merged

feat(middleware): implement system prompt builder (#28)#29
alexey-pelykh merged 1 commit intomainfrom
feat/system-prompt-builder

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Implement buildSystemPrompt() in src/middleware/system-prompt.ts that assembles ~10 sections for CLI subprocess agents
  • Replace OpenClaw's 26-section, 665-line builder with a clean ~170 LoC module tailored to RemoteClaw's middleware architecture
  • Add comprehensive test suite (25 tests) covering section inclusion, dynamic content, conditional omission, size budget, and content correctness

Details

Sections (10 total):

  • Static: Safety, Messaging, Reply Tags, Silent Replies (constant text)
  • Dynamic: Identity, Runtime, Workspace (parameterized)
  • Conditional: Message Tool Hints, Authorized Senders, Reactions (only when params provided)

Design: No promptMode switch (always full), no bootstrap context (CLI agent handles), no tool list (MCP handles), no skills/memory/sandbox sections.

Budget: Base prompt <4,000 chars, worst-case with LINE hints <6,000 chars (~770-1,270 tokens).

Closes #28

Test plan

  • All 25 new tests pass: npx vitest run src/middleware/system-prompt.test.ts
  • Full suite passes: 1,558 test files, 13,136 tests
  • Typecheck clean: pnpm tsgo
  • Lint clean: pnpm lint
  • Format clean: pnpm format

🤖 Generated with Claude Code

Add buildSystemPrompt() that assembles ~10 sections for injection into
CLI subprocess agents. Replaces OpenClaw's 26-section, 665-line builder
with a clean ~170 LoC module tailored to RemoteClaw's middleware needs.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh merged commit 382fe50 into main Feb 26, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/system-prompt-builder branch February 26, 2026 07:24
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.

Implement system prompt builder

1 participant