Skip to content

Commit 3254b5a

Browse files
committed
merge: resolve main conflicts for agent-capabilities PR
2 parents 84b77b2 + 594616a commit 3254b5a

23 files changed

Lines changed: 2714 additions & 89 deletions

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,20 +525,45 @@ AgentChatBus therefore exposes **underscore-style** tool names (e.g. `thread_cre
525525

526526
| Tool | Required Args | Description |
527527
|---|---|---|
528-
| `thread_create` | `topic` | Create a new conversation thread. Returns `thread_id`. |
528+
| `thread_create` | `topic` | Create a new conversation thread. Optional `template` to apply defaults (system prompt, metadata). Returns `thread_id`. |
529529
| `thread_list` || List threads. Optional `status` filter. |
530530
| `thread_get` | `thread_id` | Get full details of one thread. |
531531
| `thread_delete` | `thread_id`, `confirm=true` | Permanently delete a thread and all messages (irreversible). |
532532

533533
> **Note**: Thread state management (`set_state`, `close`, `archive`) are available via **REST API** (`/api/threads/{id}/state`, `/api/threads/{id}/close`, `/api/threads/{id}/archive`), not MCP tools.
534534
535+
### Thread Templates
536+
537+
Thread templates provide reusable presets for thread creation. Four built-in templates are included:
538+
539+
| Template ID | Name | Purpose |
540+
|---|---|---|
541+
| `code-review` | Code Review | Structured review focused on correctness, security, and style |
542+
| `security-audit` | Security Audit | Security-focused review with severity ratings |
543+
| `architecture` | Architecture Discussion | Design trade-offs and system structure evaluation |
544+
| `brainstorm` | Brainstorm | Free-form ideation, all ideas welcome |
545+
546+
| Tool | Required Args | Description |
547+
|---|---|---|
548+
| `template_list` || List all available templates (built-in + custom). |
549+
| `template_get` | `template_id` | Get details of a specific template. |
550+
| `template_create` | `id`, `name` | Create a custom template. Optional `description`, `system_prompt`, `default_metadata`. |
551+
552+
**Using a template when creating a thread:**
553+
554+
```json
555+
{ "topic": "My Review Session", "template": "code-review" }
556+
```
557+
558+
The template's `system_prompt` and `default_metadata` are applied as defaults. Any caller-provided values override the template defaults.
559+
535560
### Messaging
536561

537562
| Tool | Required Args | Description |
538563
|---|---|---|
539-
| `msg_post` | `thread_id`, `author`, `content` | Post a message. Returns `{msg_id, seq}`. Triggers SSE push. |
564+
| `msg_post` | `thread_id`, `author`, `content` | Post a message. Returns `{msg_id, seq}`. Optional `metadata` with structured keys (`handoff_target`, `stop_reason`, `attachments`). Triggers SSE push. |
540565
| `msg_list` | `thread_id` | Fetch messages. Optional `after_seq`, `limit`, `include_system_prompt`, and `return_format`. |
541-
| `msg_wait` | `thread_id`, `after_seq` | **Block** until a new message arrives. Optional `timeout_ms`, `agent_id`, `token`, and `return_format`. |
566+
| `msg_wait` | `thread_id`, `after_seq` | **Block** until a new message arrives. Optional `timeout_ms`, `agent_id`, `token`, `return_format`, and `for_agent`. |
542567

543568
#### `return_format` (legacy JSON vs native blocks)
544569

@@ -553,6 +578,19 @@ AgentChatBus therefore exposes **underscore-style** tool names (e.g. `thread_cre
553578
- Returns a single `TextContent` block whose `.text` is a JSON-encoded array of messages.
554579
- Use this if you have older scripts that do `json.loads(tool_result[0].text)`.
555580

581+
#### Structured `metadata` keys
582+
583+
`msg_post` accepts an optional `metadata` object with the following recognized keys:
584+
585+
| Key | Type | Description |
586+
|---|---|---|
587+
| `handoff_target` | `string` | Agent ID that should handle this message next. Triggers a `msg.handoff` SSE event. Response includes `handoff_target` for discoverability. |
588+
| `stop_reason` | `string` | Why the posting agent is ending its turn. Values: `convergence`, `timeout`, `error`, `complete`, `impasse`. Triggers a `msg.stop` SSE event. |
589+
| `attachments` | `array` | File or image attachments (see below). |
590+
| `mentions` | `array` | Agent IDs mentioned in the message (web UI format). |
591+
592+
**`for_agent` in `msg_wait`**: pass `for_agent: "<agent_id>"` to receive only messages where `metadata.handoff_target` matches. Useful for directed handoff patterns in multi-agent workflows.
593+
556594
##### Attachment format (images)
557595

558596
To attach images, pass `metadata` to `msg_post`:
@@ -638,7 +676,11 @@ The server also exposes a plain REST API used by the web console and simulation
638676
| Method | Path | Description |
639677
|---|---|---|
640678
| `GET` | `/api/threads` | List threads (optional `?status=` filter and `?include_archived=` boolean) |
641-
| `POST` | `/api/threads` | Create thread `{ "topic": "...", "metadata": {...}, "system_prompt": "..." }` |
679+
| `POST` | `/api/threads` | Create thread `{ "topic": "...", "metadata": {...}, "system_prompt": "...", "template": "code-review" }` |
680+
| `GET` | `/api/templates` | List all thread templates (built-in + custom) |
681+
| `GET` | `/api/templates/{id}` | Get template details (404 if not found) |
682+
| `POST` | `/api/templates` | Create custom template `{ "id": "...", "name": "...", "description": "...", "system_prompt": "..." }` |
683+
| `DELETE` | `/api/templates/{id}` | Delete custom template (403 if built-in, 404 if not found) |
642684
| `GET` | `/api/threads/{id}/messages` | List messages (`?after_seq=0&limit=200&include_system_prompt=false`) |
643685
| `POST` | `/api/threads/{id}/messages` | Post message `{ "author", "role", "content", "metadata": {...}, "mentions": [...] }` |
644686
| `POST` | `/api/threads/{id}/state` | Change state `{ "state": "discuss\|implement\|review\|done" }` |

0 commit comments

Comments
 (0)