Skip to content

feat(commonly): commonly_open_dm — autonomous agent-to-agent DM initiation#1

Closed
samxu01 wants to merge 1 commit intorebase-2026.3.29from
feat/commonly-open-dm
Closed

feat(commonly): commonly_open_dm — autonomous agent-to-agent DM initiation#1
samxu01 wants to merge 1 commit intorebase-2026.3.29from
feat/commonly-open-dm

Conversation

@samxu01
Copy link
Copy Markdown

@samxu01 samxu01 commented May 3, 2026

Summary

Currently, agents on Commonly can post to pods they're in, @mention peers in shared pods, and create new public pods — but they have no way to open a private 1:1 DM with another agent. The platform-side `POST /api/agents/runtime/agent-dm` endpoint exists; this PR adds the client method and the agent-facing tool that wraps it.

This unblocks ADR-012 memory propagation in the parent repo — the `agent-dm-conclusion` system_exchanges trigger has no live origin without an agent-facing way to start a DM.

What's added

  • `CommonlyClient.openAgentDm({ agentName, instanceId? }, originPodId?)` — POSTs to the existing endpoint. Idempotent on (caller, target). Surfaces 403 when the §3.7 co-pod-member rule rejects.
  • `commonly_open_dm` tool — agent-facing. Returns `{ ok, podId, podName, autoJoined }`. Description explicitly handles the OpenClaw-driven case (`agentName: 'openclaw'` + `instanceId: ''`).
  • 3 vitest cases.

Two-step over one-step

This tool returns `podId` only. The agent then calls `commonly_post_message(podId, content)` to actually send. Keeps each tool atomic, and lets the agent read DM history first if it wants. A one-step "open + post" can be added later if friction shows up.

Future

When ADR-010 unpauses, the entire extension translates to MCP so claude-code, codex, gemini, and BYO runtimes consume the same surface. Tool definitions here are intentionally runtime-portable.

Test plan

  • `pnpm vitest run extensions/commonly/src/client.test.ts` — 12/12 passing
  • After merge + submodule SHA bump in commonly repo: dispatch deploy-dev
  • Have an agent run `commonly_open_dm({ agentName: 'openclaw', instanceId: 'pixel' })` from a session that shares a pod with pixel — confirm a new agent-dm pod is returned (or the existing one if a DM already exists)
  • Confirm 403 path: same call from a session that does NOT share a pod with pixel

🤖 Generated with Claude Code

…ation

Sam (xcjsam@): "if an agent decides to talk with another existing agent
it knows, will the agent autonomously do the DM, or are we enforcing it
via system?" — currently neither. The platform-side `/agent-dm` endpoint
exists, but no client tool wraps it, so agents can only @mention in
shared pods and cannot open private 1:1 channels.

This unblocks ADR-012 — the `agent-dm-conclusion` system_exchanges
trigger has no live origin without an agent-facing way to start a DM.

Adds:
- `client.openAgentDm({ agentName, instanceId? }, originPodId?)` — POSTs
  to /api/agents/runtime/agent-dm. Idempotent on the (caller, target)
  pair. Surfaces 403 when the §3.7 co-pod-member rule rejects.
- `commonly_open_dm` tool — the agent-facing surface. Returns
  { ok, podId, podName, autoJoined }. Description explicitly calls out
  the OpenClaw-driven case (`agentName: 'openclaw' + instanceId: '<id>'`).
- Three vitest cases: target shape with explicit instanceId, default-
  instanceId omission, 403 surfacing.

Two-step model: this tool returns `podId` only — the agent then uses
`commonly_post_message(podId, content)` to send. Keeps each tool atomic
and lets the agent read DM history first if it wants. One-step
"open + post" can be added later if friction shows up in production.

Future work (separate PR, after ADR-010 unpauses): translate the
extension into MCP so claude-code, codex, gemini, and BYO runtimes can
consume the same surface. The tool definitions here are intentionally
runtime-portable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
samxu01 added a commit that referenced this pull request May 3, 2026
…ation (#1)

Currently, agents on Commonly can post to pods they're in, @mention
peers in shared pods, and create new public pods — but they have no way
to open a private 1:1 DM with another agent. The platform-side
POST /api/agents/runtime/agent-dm endpoint exists; this PR adds the
client method and the agent-facing tool that wraps it.

Unblocks ADR-012 memory propagation in the parent repo — the
agent-dm-conclusion system_exchanges trigger has no live origin without
an agent-facing way to start a DM.

Adds:
- CommonlyClient.openAgentDm({ agentName, instanceId? }, originPodId?)
  — POSTs to the existing endpoint. Idempotent on (caller, target).
  Surfaces 403 when the §3.7 co-pod-member rule rejects.
- commonly_open_dm tool — agent-facing. Returns { ok, podId, podName,
  autoJoined }. Description explicitly handles the OpenClaw-driven case
  (agentName: 'openclaw' + instanceId: '<peer-id>').
- 3 vitest cases: target shape with explicit instanceId, default-
  instanceId omission, 403 surfacing.

Two-step over one-step: this tool returns podId only. The agent then
calls commonly_post_message(podId, content) to actually send. Keeps each
tool atomic, and lets the agent read DM history first if it wants.

Future: when ADR-010 unpauses, the entire extension translates to MCP
so claude-code, codex, gemini, and BYO runtimes consume the same
surface. Tool definitions here are intentionally runtime-portable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
samxu01 added a commit to Team-Commonly/commonly that referenced this pull request May 3, 2026
…ool)

Pulls in Team-Commonly/openclaw#1 — the commonly_open_dm tool for
autonomous agent-to-agent DM initiation. Required for ADR-012 Phase 1
to have a live origin for the agent-dm-conclusion trigger.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@samxu01
Copy link
Copy Markdown
Author

samxu01 commented May 3, 2026

Squash-merged locally as 11878b4 on rebase-2026.3.29. Picked up by commonly via submodule bump in ec8eb4f020.

@samxu01 samxu01 closed this May 3, 2026
@samxu01 samxu01 deleted the feat/commonly-open-dm branch May 3, 2026 19:56
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