Skip to content

feat: add hidden CODER_AGENT_IS_SUB_AGENT flag to coder agent #17783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Options struct {
ServiceBannerRefreshInterval time.Duration
BlockFileTransfer bool
Execer agentexec.Execer
SubAgent bool

ExperimentalDevcontainersEnabled bool
ContainerAPIOptions []agentcontainers.Option // Enable ExperimentalDevcontainersEnabled for these to be effective.
Expand Down Expand Up @@ -190,6 +191,8 @@ func New(options Options) Agent {
metrics: newAgentMetrics(prometheusRegistry),
execer: options.Execer,

subAgent: options.SubAgent,

experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
containerAPIOptions: options.ContainerAPIOptions,
}
Expand Down Expand Up @@ -272,6 +275,8 @@ type agent struct {
metrics *agentMetrics
execer agentexec.Execer

subAgent bool

experimentalDevcontainersEnabled bool
containerAPIOptions []agentcontainers.Option
containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.
Expand Down
13 changes: 13 additions & 0 deletions cli/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
blockFileTransfer bool
agentHeaderCommand string
agentHeader []string
subAgent bool

experimentalDevcontainersEnabled bool
)
Expand Down Expand Up @@ -350,6 +351,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
PrometheusRegistry: prometheusRegistry,
BlockFileTransfer: blockFileTransfer,
Execer: execer,
SubAgent: subAgent,

ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
})
Expand Down Expand Up @@ -481,6 +483,17 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
Description: "Allow the agent to automatically detect running devcontainers.",
Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
},
{
Flag: "is-sub-agent",
Default: "false",
Env: "CODER_AGENT_IS_SUB_AGENT",
Description: "Specify whether this is a sub agent or not.",
Value: serpent.BoolOf(&subAgent),
// As `coderd` handles the creation of sub-agents, it does not make
// sense for this to be exposed. We do not want people setting an
// agent as a sub-agent if it is not.
Hidden: true,
},
}

return cmd
Expand Down
Loading