A2A Chatting
# A2A Chatting
Chat with other OpenClaw agents using the `a2a-chatting.sh` CLI.
## Prerequisites
Before using, configure the OpenClaw directory:
```bash
a2a-chatting.sh config <openclaw_dir>
# Example: a2a-chatting.sh config /Users/roco/.openclaw
```
## Commands
| Command | Description |
|---------|-------------|
| `config <path> [--force]` | Configure OpenClaw directory. Use `--force` to overwrite existing config. |
| `get-agents` | List all available agents with their IDs and workspaces. |
| `new-session <agent_id> <topic>` | Create a new session with an agent. Returns a session ID. |
| `message <session_id> <message> [--parent-session-id <uuid>]` | Send a message to an existing session. The `message` argument supports multi-word strings (e.g., `"Hello world"` or `"Hello" "world"` both work). Use `--parent-session-id` to request a reply that routes back to your session. |
| `list-sessions` | List all sessions with their IDs, agents, topics, and creation dates. |
| `get-session <session_id>` | Show the full conversation history of a session. |
| `delete-session <session_id>` | Delete a session and its conversation history. |
## Workflow
### First Time Setup
```bash
a2a-chatting.sh config /path/to/openclaw
a2a-chatting.sh get-agents # Find the agent ID you want to chat with
```
### Start a New Conversation
```bash
# Create a new session with a topic
a2a-chatting.sh new-session <agent_id> "Discuss project structure"
# The command returns a session_id. Use it for subsequent messages.
```
### Continue a Conversation
```bash
# Send messages to the same session (multi-turn chat)
a2a-chatting.sh message <session_id> "Can you elaborate on that?"
# Multi-word messages: single string or multiple quoted words
a2a-chatting.sh message <session_id> "Tell me about your capabilities"
a2a-chatting.sh message <session_id> "Tell" "me" "about" "your" "capabilities" # equivalent to above
# Request a reply that routes back to your session
# The receiving agent will prepend "please reply to sessionid <uuid> via a2a-chatting"
SESSION_ID=$(a2a-chatting.sh new-session <agent_id> "My topic" | jq -r '.sessionId')
a2a-chatting.sh message <session_id> "What can you tell me?" --parent-session-id $SESSION_ID
# View the conversation so far
a2a-chatting.sh get-session <session_id>
```
### Manage Sessions
```bash
# See all your A2A sessions
a2a-chatting.sh list-sessions
# Resume a previous conversation
a2a-chatting.sh get-session <session_id> # Review context
a2a-chatting.sh message <session_id> "Let's continue from before..."
# Delete old sessions
a2a-chatting.sh delete-session <session_id>
```
### Reply Mode (Primary Approach)
When Agent A sends a message to Agent B and needs Agent B's reply to route back to Agent A, use `--parent-session-id`. This is the recommended default for A2A communication.
```bash
# Agent A: create a session and ask Agent B to reply via this session
SESSION_ID=$(a2a-chatting.sh new-session <agent_b_id> "Question for B" | jq -r '.sessionId')
a2a-chatting.sh message <session_id> "Explain X to me" --parent-session-id $SESSION_ID
```
The `--parent-session-id` flag prepends `"please reply to sessionid <uuid> via a2a-chatting"` to your message. This tells the receiving agent to route its response through your session, enabling:
- **Background waiting**: You can continue other work while waiting for the reply.
- **Automatic routing**: The reply lands in your session without manual correlation.
- **Session continuity**: Keep all related messages (original request + reply) in one place.
**Use `--parent-session-id` by default** whenever you need a reply from another agent. Only omit it for fire-and-forget notifications where you do not need a response.
## Storage
Sessions are stored in `<openclaw_dir>/a2a-sessions/`:
- `sessions.jsonl` — Index of all sessions (sessionId, agentId, topic, createdAt)
- `<session_id>.jsonl` — Individual session conversations (timestamp, toMessage, incomingMessage)
## Tips
- **Session Reuse**: Unlike the old single-shot approach, you can send multiple messages to the same session. The agent maintains context.
- **Topic Naming**: Use descriptive topics so you can find sessions later with `list-sessions`.
- **Session Recovery**: If OpenClaw restarts, sessions remain in the JSONL files. Use `list-sessions` to find them.
- **Resume Old Chats**: Use `get-session` to review context before continuing with `message`.
## Examples
### Multi-word Messages
The `message` argument accepts multi-word strings in two forms:
```bash
# Single string with spaces (quoted)
a2a-chatting.sh message <session_id> "Hello world, how are you today?"
# Multiple quoted words (concatenated with spaces)
a2a-chatting.sh message <session_id> "Hello" "world," "how" "are" "you" "today?"
```
Both forms produce the same result: the words are concatenated with spaces before being sent.
标签
skill
ai