Skip to content

fix(agents): agents must post as themselves — never via an operator profile - #702

Merged
lilyshen0722 merged 2 commits into
mainfrom
fix/agent-post-attribution
Jul 22, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
fix/agent-post-attribution

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Incident

codex-impl (BYO wrapper agent with full shell access) posted pod messages through the operator's Commonly CLI profile (commonly pod send → ~/.commonly/config.json token), so its words landed in the public milestone pod attributed to the human operator (name + avatar). Worse, the wrapper's id-only self-post detection saw the new (human-authored) message appear mid-spawn, concluded "agent posted itself", and suppressed the correctly-attributed reply — the misattributed copy was the only one that landed.

Provenance is the product thesis; agent words showing under a human's name is the exact failure we can't have.

Fix (three layers)

  1. Wrapper (cli/src/commands/agent.js): echo suppression now counts only NEW bot-authored messages (isBot). A human-authored message appearing during the spawn — someone typing mid-turn, or an agent misusing an operator profile — no longer suppresses the wrapper's correctly-attributed reply. +2 regression tests.
  2. Kernel (agentMentionService.formatPodContextFrame): inline identity rule appended to the pod-context frame every runtime receives — post as yourself only; never via operator CLI profiles or human tokens. Same inline-cue pattern as the ADR-012 §9 DM frame.
  3. Skill (cli/skills/commonly/SKILL.md): the rule, documented for every wrapper agent that mounts the bundled skill.

Also deletes a stray empty HEAD file tracked at repo root since an old bulk commit.

Tests

  • cli: 158 passed (15 suites) including 2 new regression tests
  • backend: agentMentionService suite 27 passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES

lilyshen0722 and others added 2 commits July 21, 2026 22:13
…rofile

Incident: codex-impl (BYO wrapper, full shell) posted pod messages through
the operator's Commonly CLI profile (~/.commonly/config.json), so its words
landed in the milestone pod attributed to the human operator. The wrapper's
id-only self-post detection then treated that human-authored message as
'agent posted itself' and swallowed the correctly-attributed reply, leaving
the misattributed copy as the only one in the room.

Three layers:
- wrapper: echo suppression now counts only NEW bot-authored messages
  (isBot) — a human-authored message appearing mid-spawn no longer
  suppresses the correctly-attributed wrapper reply (+2 regression tests)
- kernel: pod-context frame gains an inline identity rule (post as
  yourself; never via operator CLI profiles or human tokens) — reaches
  every runtime, same inline-cue pattern as ADR-012 §9
- skill: bundled commonly SKILL.md documents the rule for wrapper agents

Also removes a stray empty HEAD file tracked at repo root since an old
bulk commit.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES
…s.* overrides)

The codex adapter silently ignored environment.mcp, so a local codex
wrapper agent had NO commonly_* tools — no sanctioned way to post mid-turn.
That vacuum is what produced the as-operator incident: the agent found the
operator's CLI profile with bash and posted through it, as the human.

- adapters/codex.js: environment.mcp (stdio/command servers) becomes
  `-c mcp_servers.<name>.{command,args,env}` TOML overrides, with the same
  ${COMMONLY_AGENT_TOKEN}/${COMMONLY_API_URL} substitution contract as
  claude.js. Declared env rides inside the mcp_servers env table because
  codex does not pass parent env to MCP children (the PR #398 lesson).
- agent.js: codex joins ADAPTERS_WITH_DEFAULT_MCP — fresh codex attaches
  get @commonlyai/mcp wired by default, same as claude.
- +3 adapter/attach tests (override shape, url-server skip, MCP-less argv)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES
@lilyshen0722
lilyshen0722 merged commit fed61c7 into main Jul 22, 2026
10 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/agent-post-attribution branch July 22, 2026 05:27
lilyshen0722 added a commit that referenced this pull request Jul 25, 2026
…-only (#755)

* fix(cli): ship the #702 attribution guardrail — sync skill copies + guard drift

`cli/package.json`'s `prepublishOnly` copies `docs/agents/skills/commonly/SKILL.md`
OVER `cli/skills/commonly/SKILL.md` at publish time, which quietly makes the docs
copy the real source of truth for what ends up in the tarball.

PR #702 added the "post as yourself, never as your operator" guardrail to the cli
copy only. The publish hook then erased it, so @commonlyai/[email protected] shipped
without the rule — every agent attached with 0.1.4 was instructed without the
guardrail that #702 existed to add. (Verified against the published tarball, not
just the working tree.)

- sync the guardrail into the docs copy, so it actually ships
- add a test asserting the two copies stay byte-identical, so this class of
  drift fails in CI instead of silently at publish

The new guard fails against the pre-fix tree and passes after.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES

* fix(cli): mount agent skills as read-only copies, not write-through symlinks

`linkSkills` symlinked each declared skill source into the agent's workspace at
`.claude/skills/<name>`. A symlink is writable *through*: an agent holding
Write/Edit can rewrite the file that governs its own behaviour, and because the
common source is `cli/skills/commonly` inside the operator's checkout, that edit
lands in a tracked file. `npm publish` ships the working tree rather than git
HEAD, so a write-through edit can ride out in the next release unnoticed.

Empirically confirmed the old shape is write-through: writing to the workspace
path mutates the source.

Replace with `mountSkills`, which materializes a read-only snapshot copy:
- data flows one way, source → workspace, never back
- refreshed every spawn, so source edits still reach the agent next turn
- only directories carrying `.commonly-skill-mount` are refreshed; user-authored
  content in the slot is reported as `not-a-mount` and left untouched
- legacy symlinks from CLI <=0.1.4 are replaced (that shape is what we retire)

Bumps to 0.1.5 for release alongside the guardrail fix.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DMeWzgFxsfBcjoLVLewEES

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
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]>
lilyshen0722 added a commit that referenced this pull request Aug 1, 2026
Four agents ran a sprint pod for three days and produced genuinely good review
reasoning — one caught a real ReDoS. All of it landed as pod prose, so four PRs
were merged with zero GitHub reviews on them. The agents were not unable to
review; sprint-review has gh access. They defaulted to chat because chat was
where the conversation was.

That is a default-surface problem, not a capability gap, so the fix belongs in
the bundled skill rather than in the product: output goes where it will be
acted on by someone who was not in the conversation. Reviews to `gh pr review`,
decisions to an ADR, ideas to the register, work to an issue.

Stated most sharply for reviews, because that is where the cost showed up:
review reasoning in a pod message gates nothing — the merge button does not
know the conversation happened.

Both copies updated together; the #755 sync guard covers the drift that would
otherwise erase this at publish time, as it erased the #702 guardrail.

Co-authored-by: Claude Opus 4.8 <[email protected]>
samxu01 pushed a commit that referenced this pull request Oct 20, 2026
C14 call rehearsal, 2026-10-20: Claude handed Codex a change and promised to
review it; Codex posted the result without @mentioning Claude, so Claude
never woke and the review never came. The kernel now cues the first handoff
(#2367); the skill states the rule for every runtime that loads it.

Edited in docs/agents/skills/commonly/SKILL.md (prepublishOnly copies it over
the packaged one) and mirrored; skill-sync pins it beside the #702 guardrail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
samxu01 pushed a commit that referenced this pull request Oct 21, 2026
C14 call rehearsal, 2026-10-20: Claude handed Codex a change and promised to
review it; Codex posted the result without @mentioning Claude, so Claude
never woke and the review never came. The kernel now cues the first handoff
(#2367); the skill states the rule for every runtime that loads it.

Edited in docs/agents/skills/commonly/SKILL.md (prepublishOnly copies it over
the packaged one) and mirrored; skill-sync pins it beside the #702 guardrail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wkz5axAzCvoLEFkZ5KtkKG
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