Skip to content

harden(local-agents): fix a2a DM route + pod roster in get_context + sharper skill - #622

Merged
lilyshen0722 merged 1 commit into
mainfrom
harden/local-agent-dm-roster-skill
Jul 4, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
harden/local-agent-dm-roster-skill

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Pre-beta smoke testing of local wrapper agents (BYO codex/claude via commonly agent run) surfaced two real bugs and a skill gap:

1. Agent-to-agent DM was broken. commonly_dm_agent posted to /agents/runtime/room (an agent-room — the operator 1:1 channel, which blocks bot senders). A local agent could open the DM but never post to it. Repointed at /agents/runtime/agent-dm (the a2a route cloud agents already use) + optional originPodId. Verified end-to-end: two local wrapper agents (solo↔duo) held a real multi-turn a2a DM. MCP bumped 0.1.4 → 0.1.5 (needs npm publish).

2. get_context didn't return members. The tool description promises members, but the endpoint never included them — so agents had no way to see who they could ping (a concrete reason "they don't ping"). Added a resolved members roster (name, isAgent, self) to both return paths. Serves MCP + wrapper agents.

3. Skill hardened — a "reach out, don't work alone" section (when to proactively ping: feedback / domain check / handoff / sync), the roster as the who-to-ping list, the fixed a2a-DM flow, and a "don't double-post / don't narrate that you posted" rule.

Human→agent DM verified already working (daemon polls the dm.message event; agent replies with no @mention).

Deploy notes: #2 needs Deploy Dev to take effect; MCP 0.1.5 needs an npm publish.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MnRCAFgjrrGZxo9VRCmCm9

…, sharpen skill

Surfaced by pre-beta smoke testing of local wrapper agents (BYO codex/claude):

1. a2a DM was broken. commonly_dm_agent (MCP) POSTed to /agents/runtime/room
   — an agent-ROOM (the operator 1:1 channel), which BLOCKS bot senders — so
   an autonomous local agent could open the DM but never post to it. Repointed
   it at /agents/runtime/agent-dm (the a2a route cloud agents use), added an
   optional originPodId, and updated the description. Verified end-to-end: two
   local wrapper agents (solo↔duo) held a real multi-turn a2a DM. MCP → 0.1.5.

2. get_context didn't return members. Its tool description promises "members,"
   but PodContextService.getPodContext never included them — so agents had no
   way to see who they could @mention or DM (a real reason "they don't ping").
   Added a resolved `members` roster (name, isAgent, self) to both return
   paths, honoring the documented contract. Serves MCP and wrapper agents alike.

3. Skill hardening (docs/agents/skills/commonly/SKILL.md): a "reach out, don't
   work alone" section — when to proactively ping a teammate (feedback / domain
   check / handoff / sync), the members roster as the who-to-ping list, the
   fixed a2a-DM two-step, and a "don't double-post / don't narrate that you
   posted" rule (the wrapper posts your output; a narration becomes a 2nd msg
   and re-pings mentioned agents).

Human→agent DM was verified working already (daemon polls the dm.message-typed
chat.mention event; a local agent replies with no @mention needed).
@lilyshen0722
lilyshen0722 merged commit 82da5d6 into main Jul 4, 2026
7 of 8 checks passed
@lilyshen0722
lilyshen0722 deleted the harden/local-agent-dm-roster-skill branch July 4, 2026 11:58
lilyshen0722 added a commit that referenced this pull request Jul 4, 2026
…I to 0.1.1

The #622 members roster fed pod.members straight into User.find({_id:{$in}}) —
a stray non-ObjectId value (corrupt data, or the test fixture's 'user-1') threw
a Mongoose CastError and took down the entire get_context response. main was
red on podContextService.test.js. Filter to 24-hex ObjectIds before the query
(works live where ids are real ObjectIds; degrades to [] otherwise). Test green.

Bump @commonlyai/cli 0.1.0 -> 0.1.1 so the skill-mount + double-post detection
in this PR reach users on the next publish.
lilyshen0722 added a commit that referenced this pull request Jul 4, 2026
… fix)

The #622 a2a-DM fix repointed commonly_dm_agent from /room to /agent-dm with a
nested target — but the .mjs test still asserted the old /room route + flat body,
so main was red (my grep missed the .mjs extension in #622). Update the
assertion to the new route/shape.
lilyshen0722 added a commit that referenced this pull request Jul 5, 2026
…+ kill double-post via self-post detection (#624)

* fix(cli): honor NO_REPLY so the wrapper stops duplicating agent posts

The double-post wasn't "too many messages" — intentional updates ("on it" →
"done") are good. It was mechanism duplication: an agent posts via
commonly_post_message (MCP), then the wrapper ALSO posts the CLI's final text
(usually a restatement), re-firing any @mention. The agent had no way to say
"I already posted, stay quiet" — the wrapper ignored NO_REPLY and would post
the literal string.

Now the wrapper skips its post when the agent's output is empty or exactly
NO_REPLY (the established platform sentinel; mixed content still posts verbatim).
So an agent that owns its turn via the tool — one message, or a deliberate
sequence — ends with NO_REPLY and the wrapper stays out. Agents that don't post
via the tool are unaffected: their reply is still posted as before.

Skill updated to match: intentional updates are encouraged; end a
tool-posted turn with NO_REPLY to avoid the echo.

* fix(cli): mount the behavior skill by default + detect self-posts to kill double-post

Round-two smoke testing showed the NO_REPLY sentinel alone doesn't fix the
double-post: a wrapper agent (even with the skill mounted) posts its reply via
commonly_post_message AND then narrates ("Posted to the pod: …"), which the
wrapper echoed as a second message — Claude doesn't reliably end on NO_REPLY.

Two changes make wrapper agents behave consistently:

1. Bundle the commonly behavior skill in the CLI package (cli/skills/commonly)
   and mount it via the default attach environment (skills.claude), so a fresh
   `commonly agent attach claude` gives the agent the house rules — not just the
   MCP tools. Without it, wrapper-spawned CLIs fly blind (some narrate, some
   default to NO_REPLY on a normal question). prepublishOnly keeps the bundled
   copy in sync with docs/agents/skills/commonly/SKILL.md.

2. Detect self-posts: snapshot the pod's message ids before the spawn; if a new
   message appeared during it, the agent posted via the tool, so DON'T echo its
   CLI output. Automatic — no reliance on NO_REPLY or the skill loading. Verified
   live: a fresh agent asked "12 × 12" now posts exactly one message (was two).
   NO_REPLY + empty-output are still honored as explicit/secondary signals.

* fix(context): guard members roster against non-ObjectId ids + bump CLI to 0.1.1

The #622 members roster fed pod.members straight into User.find({_id:{$in}}) —
a stray non-ObjectId value (corrupt data, or the test fixture's 'user-1') threw
a Mongoose CastError and took down the entire get_context response. main was
red on podContextService.test.js. Filter to 24-hex ObjectIds before the query
(works live where ids are real ObjectIds; degrades to [] otherwise). Test green.

Bump @commonlyai/cli 0.1.0 -> 0.1.1 so the skill-mount + double-post detection
in this PR reach users on the next publish.

* test(mcp): update commonly_dm_agent test for the /agent-dm route (a2a fix)

The #622 a2a-DM fix repointed commonly_dm_agent from /room to /agent-dm with a
nested target — but the .mjs test still asserted the old /room route + flat body,
so main was red (my grep missed the .mjs extension in #622). Update the
assertion to the new route/shape.

* test(cli): mock the /messages route in the route-aware run-loop test

The double-post detection snapshots pod messages before/after each spawn. The
route-aware mock's else-branch (which consumes the event queue) was catching
those GETs and advancing the event counter, breaking session-reuse sequencing.
Answer /messages explicitly with an empty list. CLI suite green locally (155).
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