#11788: feat: inter-agent communication via CLI scripts
docs
app: web-ui
gateway
agents
stale
## Summary
- Add inter-agent communication system: CLI scripts (`session-send.sh`, `session-list.sh`, `session-history.sh`) + gateway RPC client (`gateway-rpc.mjs`) enabling agents to message each other through the gateway
- Messages sent via `chat.send` RPC so conversations appear in webchat (not just agent RPC)
- Auto-inject sender identity `[from:<agentId>]` via `OPENCLAW_AGENT_ID` env var
- Sync `cli-scripts/` to `~/.openclaw/scripts/` at gateway startup for runtime availability
- Change webchat forward prefix from `[Control UI]` to `[💬]`
- Make `command` field optional in CLI backend schema
## Test plan
- [ ] Start gateway, verify `~/.openclaw/scripts/` contains synced scripts
- [ ] From webchat, send a message that triggers inter-agent communication (e.g., CTO asks developer a question)
- [ ] Verify the conversation appears in both agents' webchat sessions
- [ ] Verify `[from:<agentId>]` prefix appears in received messages
- [ ] Verify webchat-to-external forwarded messages show `[💬]` prefix
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR introduces a small set of bundled `cli-scripts/` (Node WebSocket JSON-RPC client + shell helpers) to allow CLI agents to message other agent sessions via the gateway using `chat.send`, and syncs those scripts into `~/.openclaw/scripts/` at gateway startup. It also adjusts webchat cross-delivery behavior by preserving external session origin metadata for webchat messages and forwarding webchat-originated messages/replies to the session’s external origin when routable, plus a small prefix change (`[💬]`).
Key code paths touched are the gateway `chat.send` handler (cross-delivery + transcript append for non-agent responses), CLI agent runner system prompt/env injection for `OPENCLAW_AGENT_ID`, and a new raw transcript appender reused by both gateway and CLI runner execution.
<h3>Confidence Score: 3/5</h3>
- This PR is close, but has a few runtime-failure risks that should be addressed before merging.
- Score reduced due to (1) CLI backend schema allowing missing `command` while the runner still requires it, (2) new runtime CLI script depending on `python3` for JSON escaping, and (3) synchronous fs operations during gateway startup that can crash the gateway on permissions/filesystem errors. The rest of the changes are straightforward and localized.
- src/config/zod-schema.core.ts, src/agents/cli-runner.ts, cli-scripts/session-send.sh, src/infra/cli-scripts-sync.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#16685: Fix cli agents/approvals/discord routing edge cases
by craftowen · 2026-02-15
79.7%
#12635: Gateway: add inbound webhook dispatch framework
by jhs129 · 2026-02-09
79.0%
#10748: feat: Add sessions.spawn gateway method for direct subagent spawning
by fox-openclaw · 2026-02-06
78.7%
#8713: feat: gateway memory monitor, install linger, docs and failover
by quratus · 2026-02-04
78.0%
#12234: gateway: incident tracking, recover command, and ciao ERR_SERVER_CL...
by levineam · 2026-02-09
77.9%
#6611: fix(webchat): persist assistant messages for CLI backends
by JorgeAlan · 2026-02-01
77.7%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
77.6%
#9051: fix(sessions): respect dmScope config in CLI agent commands
by benleavett · 2026-02-04
77.6%
#15792: fix: pass agentId to resolveSessionFilePath in additional call sites
by MisterGuy420 · 2026-02-13
77.3%
#6512: Claude/setup open claw agent f v sqk
by franelcisco · 2026-02-01
76.9%