From 0f9ad9b370c8e6f9dd417f7f0d66e19ca6b9c817 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 18 Jun 2025 13:23:06 +0000 Subject: [PATCH] fix(agent/agentcontainers): make sure arch is set for sub agents --- agent/agentcontainers/api.go | 6 ++++++ agent/agentcontainers/api_test.go | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/agent/agentcontainers/api.go b/agent/agentcontainers/api.go index 785d87bf3654e..f8798efbdf311 100644 --- a/agent/agentcontainers/api.go +++ b/agent/agentcontainers/api.go @@ -1051,6 +1051,10 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c ) return nil } + if proc.agent.ID == uuid.Nil { + proc.agent.Architecture = arch + } + agentBinaryPath, err := os.Executable() if err != nil { return xerrors.Errorf("get agent binary path: %w", err) @@ -1095,6 +1099,8 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c subAgentConfig := proc.agent.CloneConfig(dc) if proc.agent.ID == uuid.Nil || maybeRecreateSubAgent { + subAgentConfig.Architecture = arch + // Detect workspace folder by executing `pwd` in the container. // NOTE(mafredri): This is a quick and dirty way to detect the // workspace folder inside the container. In the future we will diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index 8dc1f83dc916b..ee756dc0c8751 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -252,6 +252,15 @@ func (m *fakeSubAgentClient) Create(ctx context.Context, agent agentcontainers.S } } } + if agent.Name == "" { + return agentcontainers.SubAgent{}, xerrors.New("name must be set") + } + if agent.Architecture == "" { + return agentcontainers.SubAgent{}, xerrors.New("architecture must be set") + } + if agent.OperatingSystem == "" { + return agentcontainers.SubAgent{}, xerrors.New("operating system must be set") + } agent.ID = uuid.New() agent.AuthToken = uuid.New() if m.agents == nil {