Repository navigation
fix(cli): consistent wrapper-agent behavior — mount skill by default + kill double-post via self-post detection - #624
Merged
Conversation
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.
…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.
…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.
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).
lilyshen0722
added a commit
that referenced
this pull request
Jul 26, 2026
…first (#757) (#759) In a pod with two BYO-wrapper agents mentioned in one message, whichever agent finished second had its ENTIRE reply silently discarded. The event was still acked, so nothing surfaced the loss — this was being worked around by hand, mentioning one agent at a time. The wrapper's self-post detection asked "did any bot post during my turn?" (`m.isBot`) as a proxy for "did I post?". Equivalent in a single-agent pod; wrong in the multi-agent rooms that are the core use case. The client cannot answer this itself: deriving its own bot username needs `resolveAgentType`'s server-only LEGACY_AGENT_MAP and an owner-scoped `instanceId` assigned at install, and a wrong guess double-posts. So the server answers it — `getRecentMessages(podId, limit, selfUserId)` stamps an explicit `self` boolean on each message, wired through both agent-facing message routes. Omitting the argument emits no `self` key at all, which is how the wrapper detects an older server and degrades to the legacy any-bot test. Three sibling defects found while verifying, each fixed with a test: - The Mongo fallback populated `userId` WITHOUT `isBot`, so every message on that path reported `isBot: false` and detection was dead outright — guaranteed double-posting whenever PG was unavailable. Untested until now because every backend test mocks getRecentMessages. - The PG path fabricated `isBot` from a username substring ('-bot', endsWith 'bot', 'openclaw-'), so a human named "talbot" or "abbot" read as a bot and suppressed an agent's reply. The mirrored `is_bot` column is authoritative. - `hasRecentDuplicateUrls` had no author filter, so a HUMAN posting a link suppressed an agent's next heartbeat post. Suppression is now observable: the log names the message id, its author, and whether the decision came from `self` or the legacy fallback. #757 went unnoticed because that line said only "posted via tool". Verified load-bearing: the new tests fail against the pre-fix code and pass after, and the #624 double-post guard and #702 human-author carve-out stay green in both states. Closes #757 Claude-Session: https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-beta smoke testing (rounds one & two) surfaced that local wrapper agents behave inconsistently — some double-post (narrate after tool-posting), some go silent — because the wrapper spawns the CLI with no behavior guidance and blindly echoes its stdout on top of whatever the agent posted itself.
1. Mount the behavior skill by default. The commonly
SKILL.mdnow ships inside@commonlyai/cli(cli/skills/commonly) and the default attach environment mounts it (skills.claude), socommonly agent attach claudegives the agent the house rules, not just the MCP tools.prepublishOnlykeeps it in sync withdocs/agents/skills/commonly/SKILL.md. Verified: it symlinks into the agent cwd on spawn.2. Kill the double-post via self-post detection. Snapshot the pod's message ids before the spawn; if a new one appears during it, the agent posted via
commonly_post_message, so the wrapper does not echo the CLI's final text. Automatic — no reliance on the agent emittingNO_REPLYor the skill loading (Claude doesn't reliably do either).NO_REPLY/empty output are still honored as explicit signals. Verified live: a fresh agent asked "12 × 12" now posts exactly one message (144) — was two.This correctly supports intentional multi-post ("on it…" then "…done" = two tool calls, both land) while eliminating the mechanism-level duplicate.
Skill also hardened separately for proactive pinging + the roster (which
get_contextnow returns — shipped in #622, deployed).🤖 Generated with Claude Code
https://claude.ai/code/session_01MnRCAFgjrrGZxo9VRCmCm9