Skip to content

Commit 56ff0fb

Browse files
authored
fix(agent/agentcontainers): make sure arch is set for sub agents (#18428)
1 parent 2f59cd0 commit 56ff0fb

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

agent/agentcontainers/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,10 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
10631063
)
10641064
return nil
10651065
}
1066+
if proc.agent.ID == uuid.Nil {
1067+
proc.agent.Architecture = arch
1068+
}
1069+
10661070
agentBinaryPath, err := os.Executable()
10671071
if err != nil {
10681072
return xerrors.Errorf("get agent binary path: %w", err)
@@ -1107,6 +1111,8 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
11071111

11081112
subAgentConfig := proc.agent.CloneConfig(dc)
11091113
if proc.agent.ID == uuid.Nil || maybeRecreateSubAgent {
1114+
subAgentConfig.Architecture = arch
1115+
11101116
// Detect workspace folder by executing `pwd` in the container.
11111117
// NOTE(mafredri): This is a quick and dirty way to detect the
11121118
// workspace folder inside the container. In the future we will

agent/agentcontainers/api_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,15 @@ func (m *fakeSubAgentClient) Create(ctx context.Context, agent agentcontainers.S
252252
}
253253
}
254254
}
255+
if agent.Name == "" {
256+
return agentcontainers.SubAgent{}, xerrors.New("name must be set")
257+
}
258+
if agent.Architecture == "" {
259+
return agentcontainers.SubAgent{}, xerrors.New("architecture must be set")
260+
}
261+
if agent.OperatingSystem == "" {
262+
return agentcontainers.SubAgent{}, xerrors.New("operating system must be set")
263+
}
255264
agent.ID = uuid.New()
256265
agent.AuthToken = uuid.New()
257266
if m.agents == nil {

0 commit comments

Comments
 (0)