Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(agent/agentcontainers): support apps for dev container agents#18346

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DanielleMaywood merged 16 commits intomainfromdm-sub-agent-apps-configuration-2
Jun 18, 2025

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywoodDanielleMaywood commentedJun 12, 2025
edited by mafredri
Loading

Add apps to the sub agent based on the dev container customization.

{  "name": "Development Container",  "image": "mcr.microsoft.com/devcontainers/typescript-node:18",  "customizations": {    "coder": {      "apps": [        {          "slug": "web-app",          "displayName": "Web Application",          "url": "http://localhost:8080/${localEnv:CODER_USER_NAME}/${localEnv:CODER_WORKSPACE_NAME}/${localEnv:CODER_AGENT_NAME}",          "openIn": "tab",          "share": "owner",          "icon": "${localEnv:CODER_URL}/icons/web.svg",          "order": 1,          "group": "Web Editors"        }      ]    }  }}

The implementation also provides the following env variables for use in the devcontainer json

  • CODER_WORKSPACE_AGENT_NAME
  • CODER_WORKSPACE_USER_NAME
  • CODER_WORKSPACE_NAME
  • CODER_URL

@DanielleMaywoodDanielleMaywoodforce-pushed thedm-sub-agent-apps-configuration-2 branch fromd06023f to08f0f9cCompareJune 12, 2025 19:47
Base automatically changed fromdm-sub-agent-apps-configuration tomainJune 12, 2025 22:36
@DanielleMaywoodDanielleMaywoodforce-pushed thedm-sub-agent-apps-configuration-2 branch from08f0f9c to6270098CompareJune 12, 2025 22:42
Copilot

This comment was marked as outdated.

@DanielleMaywoodDanielleMaywoodforce-pushed thedm-sub-agent-apps-configuration-2 branch 3 times, most recently fromc3ba85a toc800571CompareJune 17, 2025 16:07
@DanielleMaywoodDanielleMaywoodforce-pushed thedm-sub-agent-apps-configuration-2 branch from75709b9 to8ec61b6CompareJune 18, 2025 10:14
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR adds support for passing app definitions to sub agents based on dev container customizations and updates related tests and API integrations.

  • Extends the API to accept new app-related configuration options.
  • Adds new tests for sub-agent apps functionality and updates environment variable handling in the devcontainer CLI.
  • Updates various components (API, client, tests, and mocks) to support the new apps configuration.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
agent/api.goAppends options for user and workspace names and devcontainer apps; injects environment variables.
agent/agenttest/client.goIntroduces GetSubAgentApps for retrieving app definitions.
agent/agentcontainers/subagent_test.goAdds tests for sub-agent creation with app configurations.
agent/agentcontainers/subagent.goExtends the SubAgent struct and converts app configuration for API calls.
agent/agentcontainers/devcontainercli_test.goUpdates devcontainer CLI test to include an explicit env argument.
agent/agentcontainers/devcontainercli.goAdds environment variables to CLI commands.
agent/agentcontainers/api_test.goUpdates tests to include env validations for sub-agent app settings.
agent/agentcontainers/acmock/acmock.goAdjusts mock method signatures to include the new env arg.
Comments suppressed due to low confidence (1)

@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewJune 18, 2025 10:28
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I still need to take a closer look at the tests, but I identified some things that may require some refactoring.

fmt.Sprintf("CODER_WORKSPACE_AGENT_NAME=%s", dc.Name),
fmt.Sprintf("CODER_WORKSPACE_OWNER_NAME=%s", api.userName),
fmt.Sprintf("CODER_WORKSPACE_NAME=%s", api.workspaceName),
fmt.Sprintf("CODER_DEPLOYMENT_URL=%s", api.subAgentURL),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
fmt.Sprintf("CODER_DEPLOYMENT_URL=%s",api.subAgentURL),
fmt.Sprintf("CODER_AGENT_URL=%s",api.subAgentURL),

The naming is slightly unfortunate but we currently have bothCODER_URL andCODER_AGENT_URL in the product, and a third one seems like too much.

IMOCODER_URL would be more appropriate, however, it would be nice if these environment variables werealso set on the parent workspace/agent (withCODER_AGENT_URL we're at 3/4). The reason is that if a user runsdevcontainer up manually, these values are then serializable into the docker container label.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I've replaced it withCODER_URL. If you'd ratherCODER_AGENT_URL I'm happy to update it again.

I don't think we can rely on anything serialized at the point ofdevcontainer up, as theCODER_WORKSPACE_AGENT_NAME will be the parents agent name, not the child. So I'm not sure there is too much benefit there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, that's a good point about the conflicting env. Let's go withCODER_URL for now 👍🏻

agent/api.go Outdated
if manifest != nil {
containerAPIOpts = append(containerAPIOpts,
agentcontainers.WithUserName(manifest.OwnerName),
agentcontainers.WithWorkspaceName(manifest.WorkspaceName),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It'd be nice to consolidate similar things rather than having too many knobs, perhaps aagentcontainers.WithManifestInfo(url, owner, workspace)? (I'm aware my naming suggestion could've been better 😅.)

@@ -153,6 +156,15 @@ func WithSubAgentEnv(env ...string) Option {
}
}

// WithManifestInfo sets the owner name, and workspace name
// for the sub-agent.
func WithManifestInfo(owner, workspace string) Option {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: the naming suggests you can pass in the entire manifest?

Comment on lines +1146 to +1149
fmt.Sprintf("CODER_WORKSPACE_AGENT_NAME=%s", dc.Name),
fmt.Sprintf("CODER_WORKSPACE_OWNER_NAME=%s", api.ownerName),
fmt.Sprintf("CODER_WORKSPACE_NAME=%s", api.workspaceName),
fmt.Sprintf("CODER_URL=%s", api.subAgentURL),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Note for later: we'll need to document these environment variables somewhere.

DanielleMaywood reacted with thumbs up emoji
@DanielleMaywoodDanielleMaywood merged commit529fb50 intomainJun 18, 2025
34 checks passed
@DanielleMaywoodDanielleMaywood deleted the dm-sub-agent-apps-configuration-2 branchJune 18, 2025 13:55
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 18, 2025
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A few more things but other than that, looks good, nice work!

if config, err := api.dccli.ReadConfig(ctx, dc.WorkspaceFolder, dc.ConfigPath,
[]string{
fmt.Sprintf("CODER_WORKSPACE_AGENT_NAME=%s", dc.Name),
fmt.Sprintf("CODER_WORKSPACE_OWNER_NAME=%s", api.ownerName),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can we modifyagent/agent.go to set this on the parent as well?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just to ensure I know what you're referring to:

In this stanza here?

coder/agent/agent.go

Lines 1293 to 1309 in529fb50

// Define environment variables that should be set for all commands,
// and then merge them with the current environment.
envs:=map[string]string{
// Set env vars indicating we're inside a Coder workspace.
"CODER":"true",
"CODER_WORKSPACE_NAME":manifest.WorkspaceName,
"CODER_WORKSPACE_AGENT_NAME":manifest.AgentName,
// Specific Coder subcommands require the agent token exposed!
"CODER_AGENT_TOKEN":*a.sessionToken.Load(),
// Git on Windows resolves with UNIX-style paths.
// If using backslashes, it's unable to find the executable.
"GIT_SSH_COMMAND":fmt.Sprintf("%s gitssh --",unixExecutablePath),
// Hide Coder message on code-server's "Getting Started" page
"CS_DISABLE_GETTING_STARTED_OVERRIDE":"true",
}

subAgentConfig.DisplayApps = displayApps
subAgentConfig.Apps = apps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We should log app creation errors from the response after agent creation too.

Hidden: &app.Hidden,
Order: &app.Order,
Subdomain: &app.Subdomain,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Did we check to see what the "defaults" when creating apps in terraform?

URL string `json:"url"`
}

func (app SubAgentApp) ToProtoApp() (*agentproto.CreateSubAgentRequest_App, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Comment: Typically these methods exist inagentsdk/convert.go. Personally I think it makes sense to keep here though.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri left review comments

@johnstcnjohnstcnjohnstcn approved these changes

Copilot code reviewCopilotCopilot left review comments

Assignees

@DanielleMaywoodDanielleMaywood

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@DanielleMaywood@mafredri@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp