← Back to PRs

#11788: feat: inter-agent communication via CLI scripts

by jingkang0822 open 2026-02-08 09:37 View on GitHub →
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