Skip to content

feat(listen): presets default to own — runs act as the agent itself - #13

Merged
sanctrl merged 4 commits into
mainfrom
feat/run-as-itself
Nov 19, 2026
Merged

sanctrl merged 4 commits into
mainfrom
feat/run-as-itself

Conversation

@sanctrl

@sanctrl sanctrl commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What changes

agentchat listen --preset claude-code|codex runs act as the agent itself by default. The profile own comes from the engine (agentchatme/agentchat-agent-core#22): reply runs use your own Claude Code (or Codex) permission settings, with anything that would ask refused. Runs started by peers' messages act with those permissions.

  • Claude Code, own:
    • The listener's own --mcp-config is passed without --strict-mcp-config. Its agentchat is used, and the user's other servers load.
    • Flags: --permission-prompts none --allowedTools mcp__agentchat__*, the key-store deny rules, and the served identity line.
  • Codex, own:
    • No sandbox, approval, feature or permission-profile flag, and no MCP listing.
    • The key comes from a headers helper in the home (<home>/presets/codex.mcp-headers.mjs, owner-only, no key in it), so the run's environment carries none.
    • It does not start while $CODEX_HOME/.env sets AGENTCHAT_API_KEY, or while the agentchat entry Codex reports names bearer_token_env_var. A Codex integration from 0.5.2 or earlier left both, and Codex would send that agent's key in place of the helper's. doctor names the fix.
  • Texts:
    • --profile takes own|answer|work|full. The usage and the refusal for an unknown --profile say what each one does.
    • status, listen and doctor's listener line say what the profile does: runs the claude-code preset (profile own — reply runs use your own Claude Code permission settings, …). The answer line now says what it does too.
    • doctor's preset-mcp lines describe what an own run is given, and workdir says when own runs use the fallback folder.
    • The README covers own, and the changelog leads with the upgrade note.
    • The README notes that the Codex url and http_headers_helper overrides take over an existing [mcp_servers.agentchat] table, verified this time.
  • Upgrade:
    • An installed preset listener switches to own. Earlier releases wrote answer into listener.json (version 1) at every install, --profile or not, so this release reads a version-1 answer as own. A version-1 work or full is kept. The file is not rewritten.
    • New installs write version 2, taken exactly as written.
    • The service switches once it runs this release's listener copy: doctor --fix or listen --install re-installs it. status says when it still runs an earlier one.
    • To keep the lock, install with --profile answer (or AGENTCHAT_RUN_PROFILE=answer). A value that names no profile is answer.
  • Known limits (README):
    • A Codex own run's shell can read the home's credentials.
    • A Claude Code own run can read it with a program the user's rules let it start.

Needs the new engine release before this is released. This PR builds and passes against the pinned @agentchatme/agent-core 0.5.2. On 0.5.2 the listener still resolves the old profiles (default answer), and the tests that need own are skipped (ENGINE_HAS_OWN). A tagged release's tests fail until the pin moves (tests/version-consistency.test.ts, run for the tag by the publish workflow's gate job), so a release cannot ship these texts on the old engine. They run, and pass, once the pin moves. Merge the engine PR first. Move the pin at the release step. No version number is set here.

Verification

  • Tests: pnpm type-check, pnpm build, pnpm test and the release smoke on Node 22 (macOS), both ways.
    • Pinned 0.5.2: 8 files, 91 passed, 10 skipped (101); smoke ok.
    • With the new engine linked in: 100 passed, 1 skipped (the tag-only release gate).
    • New tests:
      • The listener description and words, and that they equal the engine's.
      • presetPointer for own: the address for Claude Code, the file for Codex.
      • --preset defaulting to own, --profile own accepted, an unknown environment value giving answer.
      • listener.json versions: v1 answer reads as own (file untouched), v1 work/full kept, v2 taken as written (answer included), a newer version refused, every write v2, a new install without --profile writes v2 own, --profile answer and AGENTCHAT_RUN_PROFILE=answer write v2 answer, status and listen --install say own for a v1 file, and status names a service still on an earlier release's copy.
      • The home-folder fallback for own.
      • End to end with the real listener and fake runtimes. Claude Code own: the listener's file not strict, the identity line, no context switches, the deny list without the projects folder, the manual's address in the prompt. Codex own: one listing with the run's own flags (nothing switched off), the exact argv with the helper, the helper file in the home, no key in the run's environment.
    • A tag-only release gate (tests/version-consistency.test.ts): on a tag build it fails unless the engine has own; it fails on the pinned 0.5.2 with GITHUB_REF_TYPE=tag.
    • The two end-to-end answer tests now pass --profile answer explicitly.
  • Review: independent review by a separate agent with fresh context, given the code and the requirements; it ran every suite on both engines. Verdict: one blocker, now fixed.
    • Blocker, fixed here: a Codex listener's own run did not override bearer_token_env_var. Over a config a 0.5.2 Codex integration left (that variable, the key in $CODEX_HOME/.env), it would have authenticated as that integration's agent and carried its key. Such runs now refuse, verified live (engine PR).
    • Should-fix, fixed:
      • A tag-only release gate in each integration, because the help texts describe own.
      • The Codex helper command is now tested exactly as the argv carries it, through sh -c.
      • The Codex integration's own test asserts on the environment of the spawned run.
    • Raised, not a defect: the Windows cmd /C quoting of the helper. Codex wraps the command in one more pair of quotes (raw_arg(""<command>""), rmcp-client/src/http_headers.rs:446).
    • Nits, fixed:
      • The runtime label on the runner factories, so status names the runtime while idle.
      • The describeMcp and work wording.
      • The Windows deny-rule limit, now documented.
    • Left open, a design question: doctor shows PASS for own even when the user's own settings amount to full.
  • Live check: before release, the engine's listener runners, built, against the real Claude Code 2.1.327 and Codex 0.154.0, with scripted fake model APIs, local fake MCP servers and a throwaway HOME.
    • Claude Code listener own: the AgentChat tool reached the listener's server with the listener's key. The user-scope agentchat of another agent got no request, and the user's other server connected.
    • Codex listener own: the helper in <home>/presets/ authenticated as the listener's agent, over a helper-based [mcp_servers.agentchat] of another agent in the user's config. The run's environment held no AGENTCHAT* variable.
    • Codex listener own, home laid out as a 0.5.2 integration leaves it: the run did not start, for the .env key and then for the entry's bearer_token_env_var, with the fix named and no model call made.
    • After release: listen --preset claude-code --install with no --profile; status shows profile own — …; a peer's DM gets a reply.

Risk and rollback

  • Preset listeners default to own, installed ones included once their service runs this release. One installed with --profile answer by this release keeps the lock.
  • Rollback: revert, or install the listener with --profile answer.

`listen --preset claude-code|codex` takes --profile own|answer|work|full,
`own` by default (the engine's): the coding agent's own permission settings,
with anything that would ask refused. status and doctor say what the profile
does; an installed listener keeps the profile its listener.json recorded.
Builds and passes on the pinned engine; the own tests run once the pin moves.
…for idle status; texts

A tagged release's tests fail unless the bundled engine has the own profile
(the publish workflow's gate job runs them for the tag), so these texts
cannot ship on the old engine; pull requests stay green on the pin. The
runner factory names its runtime, so status says it while idle. The known
limits (Windows, plan mode, a key a 0.5.2 placement left in .env) are said.
Releases before own wrote listener.json version 1 and recorded answer at
every preset install, --profile or not, so it cannot be told apart from a
choice. listener.json is now version 2. Reading a version-1 file maps its
answer to the default (own); work and full are kept; version 2 is taken as
written. The mapping is in the schema, so the service, listen, status and
doctor agree, and the file is not rewritten. Installing with --profile
answer (or AGENTCHAT_RUN_PROFILE=answer) writes version 2 with answer.

status says when the service still runs an earlier release's listener copy
(which reads listener.json as that release did) and that doctor --fix
re-installs it.
@sanctrl
sanctrl enabled auto-merge (squash) November 19, 2026 11:33
@sanctrl
sanctrl merged commit 6411264 into main Nov 19, 2026
5 checks passed
@sanctrl
sanctrl deleted the feat/run-as-itself branch November 19, 2026 11:33
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