Skip to content

feat(channel): add response sanitizer + fix setup.sh dep install - #37

Merged
madtank merged 1 commit into
mainfrom
feat/response-sanitizer
Feb 25, 2026
Merged

madtank merged 1 commit into
mainfrom
feat/response-sanitizer

Conversation

@madtank

@madtank madtank commented Feb 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Response sanitizer — new sanitizeAgentResponse() function strips reasoning blocks, system metadata, identity blocks, italic self-talk preamble, and excessive newlines from agent output before it reaches users. Applied to all 3 message paths (ASYNC dispatch, outbound sendText, SYNC dispatch).
  • setup.sh dep install — setup.sh sync now runs npm install --omit=dev after rsync, preventing broken plugin loads caused by rsync --delete wiping node_modules/.
  • org_id fallback — error callbacks now use payload.org_id || payload.space_id || session.spaceId to avoid null org_id.
  • Error callback fields — added agent_name and message_id to SYNC error callback for better traceability.

Sanitizer rules

  1. Strip Reasoning: _..._ blocks (leading and mid-text)
  2. Strip plain Reasoning: blocks up to double newline
  3. Strip 🧭 Identity metadata blocks
  4. Strip 🦞 OpenClaw status blocks
  5. Strip standalone system metadata lines (Runtime, Channel, Session, etc.)
  6. Strip reasoning toggle lines (Thinking: on/off)
  7. Strip italic self-talk preamble (_internal thoughts_ before the real answer)
  8. Collapse excessive newlines

Test plan

  • Tested all agents (clawdbot, logic_runner, react_ranger, nova_sage, project_lead_ai, sec_auditor) — all produce clean output
  • project_lead_ai italic self-talk correctly stripped
  • setup.sh sync installs deps automatically after rsync
  • Gateway loads plugin without Cannot find module errors after sync

🤖 Generated with Claude Code

Adds sanitizeAgentResponse() to strip internal noise from agent
messages before they reach users:
- Reasoning: _italic block_ prefixes (leading and mid-text)
- Italic self-talk preamble (_thinking out loud_ before the answer)
- System identity blocks (🧭 Identity, 🦞 OpenClaw status)
- Metadata lines (Runtime, Channel, Session, etc.)
- [self-reference] tags
- Reasoning toggle lines (Reasoning: on/off)

Applied at all three message paths: async dispatch, sync dispatch,
and outbound sendText. Also ports org_id fallback and agent_name
fields to error callbacks.

Fixes setup.sh sync to run npm install after copying extension files.
Without this, rsync wipes node_modules and the plugin fails to load
(@sinclair/typebox missing).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@madtank
madtank merged commit fc1a003 into main Feb 25, 2026
1 check passed
@madtank
madtank deleted the feat/response-sanitizer branch February 25, 2026 04:31
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