From 2e71d5924bf00195ab198da5f4f385d742f2df08 Mon Sep 17 00:00:00 2001 From: Nanook Date: Mon, 24 Aug 2026 15:13:36 +0000 Subject: [PATCH] fix: honor language defaults for BYO agents --- .../commands/add/__tests__/add-agent.test.ts | 68 +++++++++++++++++++ src/cli/primitives/AgentPrimitive.tsx | 8 ++- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/src/cli/commands/add/__tests__/add-agent.test.ts b/src/cli/commands/add/__tests__/add-agent.test.ts index cee0dfbeb..a5d5ed8bf 100644 --- a/src/cli/commands/add/__tests__/add-agent.test.ts +++ b/src/cli/commands/add/__tests__/add-agent.test.ts @@ -272,6 +272,74 @@ describe('add agent command', () => { const agent = projectSpec.runtimes.find((a: { name: string }) => a.name === agentName); expect(agent, 'Agent should be in agentcore.json').toBeTruthy(); expect(agent.codeLocation.includes(codeDir), `codeLocation should reference ${codeDir}`).toBeTruthy(); + expect(agent.entrypoint).toBe('main.py'); + expect(agent.runtimeVersion).toBe('PYTHON_3_14'); + }); + + it('uses TypeScript defaults for BYO agents', async () => { + const agentName = `ByoTypeScriptAgent${Date.now()}`; + const codeDir = 'existing-typescript-agent'; + + const result = await runCLI( + [ + 'add', + 'agent', + '--name', + agentName, + '--type', + 'byo', + '--code-location', + codeDir, + '--language', + 'TypeScript', + '--framework', + 'Strands', + '--model-provider', + 'Bedrock', + '--json', + ], + projectDir + ); + + expect(result.exitCode, `stdout: ${result.stdout}`).toBe(0); + + const projectSpec = JSON.parse(await readFile(join(projectDir, 'agentcore/agentcore.json'), 'utf-8')); + const agent = projectSpec.runtimes.find((a: { name: string }) => a.name === agentName); + expect(agent.entrypoint).toBe('main.js'); + expect(agent.runtimeVersion).toBe('NODE_22'); + }); + + it('preserves Python defaults for BYO agents with Other language', async () => { + const agentName = `ByoOtherAgent${Date.now()}`; + const codeDir = 'existing-other-agent'; + + const result = await runCLI( + [ + 'add', + 'agent', + '--name', + agentName, + '--type', + 'byo', + '--code-location', + codeDir, + '--language', + 'Other', + '--framework', + 'Strands', + '--model-provider', + 'Bedrock', + '--json', + ], + projectDir + ); + + expect(result.exitCode, `stdout: ${result.stdout}`).toBe(0); + + const projectSpec = JSON.parse(await readFile(join(projectDir, 'agentcore/agentcore.json'), 'utf-8')); + const agent = projectSpec.runtimes.find((a: { name: string }) => a.name === agentName); + expect(agent.entrypoint).toBe('main.py'); + expect(agent.runtimeVersion).toBe('PYTHON_3_14'); }); it('requires code-location for BYO path', async () => { diff --git a/src/cli/primitives/AgentPrimitive.tsx b/src/cli/primitives/AgentPrimitive.tsx index 1f3cbbfcd..53f54658e 100644 --- a/src/cli/primitives/AgentPrimitive.tsx +++ b/src/cli/primitives/AgentPrimitive.tsx @@ -27,7 +27,8 @@ import type { import { AgentEnvSpecSchema, CREDENTIAL_PROVIDERS, - DEFAULT_PYTHON_VERSION, + DEFAULT_ENTRYPOINT_BY_LANGUAGE, + DEFAULT_RUNTIME_BY_LANGUAGE, LIFECYCLE_TIMEOUT_MAX, LIFECYCLE_TIMEOUT_MIN, } from '../../schema'; @@ -720,13 +721,14 @@ export class AgentPrimitive extends BasePrimitive