[BUG] `--agent` is silently ignored when launching cloud sessions with `--cloud` (while `--model` propagates)

Status Open
Reported on v2.1.220
Maintainer reply None cached
Activity 0 comments · opened Jul 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When creating a cloud session with claude --cloud, the --agent flag is accepted without error but not applied: the created session runs as the default top-level agent with the unrestricted toolset instead of the named agent definition — no persona, and the definition's tools: restriction is not in effect. --model passed in the same invocation is applied, so propagation into the cloud-session payload appears to be flag-specific. Because the flag is accepted silently, the degradation is invisible until the session's behavior is inspected.

Notably, the repo's .claude/agents/ definitions are fully visible to the created session as invocable subagents — only the top-level --agent binding is dropped.

What Should Happen?

The cloud session's main agent runs as the named agent — persona applied, tools restricted per the frontmatter — matching the local behavior of claude --agent <name>. Alternatively, if --agent is unsupported in combination with --cloud, the CLI should exit with an error rather than accept the flag and silently ignore it.

Error Messages/Logs

$ claude --agent scoped --model opus --cloud "State which agent definition you are running as, which model you are on, and which tools you have available."
Created cloud session: <session title>
View: https://claude.ai/code/session_<id>?from=cli&m=0
Resume with: claude --teleport session_<id>
# No error or warning — the launch succeeds; --agent is silently dropped.

Steps to Reproduce

  1. In a git repo, create .claude/agents/scoped.md:

``markdown
---
name: scoped
description: Minimal test agent
tools: Read, Grep, Glob, Bash
model: opus
---
You are the "scoped" test agent. When asked to identify yourself, say so.
``

  1. From an interactive terminal (or a pseudo-TTY — --cloud refuses non-TTY invocation, which is separate and clearly messaged), run:

``bash
claude --agent scoped --model opus --cloud "State which agent definition you are running as, which model you are on, and which tools you have available."
``

  1. Open the created cloud session and read its self-report.
  2. Observed: the session identifies as the default top-level agent with the full unrestricted toolset; the requested model is applied; the scoped persona and its tool restriction are not.

Claude Model

Opus (requested via --model opus; the model flag propagates correctly)

Is this a regression?

Not sure — I have not observed a version where --agent propagated to --cloud sessions.

Last Working Version

Unknown / n-a

Claude Code Version

2.1.220 (flag present since at least 2.1.216; behavior reproduced on 2.1.220)

Platform

CLI

Operating System

Linux

Terminal/Shell

bash (reproduced both from a real TTY and under script(1) pseudo-TTY)

Additional Information

Impact: scheduled or automated cloud launches that use --agent to set an orchestrator persona — with a restricted toolset as a guardrail — silently run unrestricted instead. A hard error on the unsupported flag combination would be strictly better than the silent fallback.

(Filed initially without this template; body rewritten to match it. The bug label from the form could not be self-applied.)

View original on GitHub ↗