Skip to content

Commit 956c248

Browse files
authored
fix: align name constraints with API docs (#701)
- CredentialNameSchema: max 255→128, min 3→1, remove dots (matches CreateApiKeyCredentialProvider API) - Fix agent name max 64→48 in docs/commands.md, AgentPrimitive.tsx, LLM context files - Fix credential constraints in docs/configuration.md (3-255→1-128) - Add API doc links as comments on AgentNameSchema, GatewayNameSchema, CredentialNameSchema, MemoryNameSchema - Regenerate JSON schema - Update unit tests for new credential constraints
1 parent ec38020 commit 956c248

8 files changed

Lines changed: 34 additions & 20 deletions

File tree

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ agentcore add agent \
195195

196196
| Flag | Description |
197197
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
198-
| `--name <name>` | Agent name (alphanumeric, starts with letter, max 64 chars) |
198+
| `--name <name>` | Agent name (alphanumeric + underscores, starts with letter, max 48 chars) |
199199
| `--type <type>` | `create` (default), `byo`, or `import` |
200200
| `--build <type>` | `CodeZip` (default) or `Container` (see [Container Builds](container-builds.md)) |
201201
| `--language <lang>` | `Python` (create); `Python`, `TypeScript`, `Other` (BYO) |

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Strategy configuration:
272272
| Field | Required | Description |
273273
| ------ | -------- | ----------------------------------- |
274274
| `type` | Yes | Always `"ApiKeyCredentialProvider"` |
275-
| `name` | Yes | Credential name (3-255 chars) |
275+
| `name` | Yes | Credential name (1-128 chars) |
276276

277277
### OAuth Credential
278278

@@ -288,7 +288,7 @@ Strategy configuration:
288288
| Field | Required | Description |
289289
| -------------- | -------- | ------------------------------------------------------ |
290290
| `type` | Yes | Always `"OAuthCredentialProvider"` |
291-
| `name` | Yes | Credential name (3-255 chars) |
291+
| `name` | Yes | Credential name (1-128 chars) |
292292
| `discoveryUrl` | Yes | OIDC discovery URL (must be a valid URL) |
293293
| `scopes` | No | Array of OAuth scopes |
294294
| `vendor` | No | Credential provider vendor (default: `"CustomOauth2"`) |

src/cli/primitives/AgentPrimitive.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export interface AddAgentOptions extends VpcOptions {
7575
export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableResource> {
7676
readonly kind = 'agent';
7777
readonly label = 'Agent';
78-
protected override readonly article = 'an';
7978
readonly primitiveSchema = AgentEnvSpecSchema;
8079

8180
/** Local instance to avoid circular dependency with registry. */
@@ -198,12 +197,15 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
198197
.description('Add an agent to the project')
199198
.option(
200199
'--name <name>',
201-
'Agent name (start with letter, alphanumeric and underscores only, max 48 chars) [non-interactive]'
200+
'Agent name (start with letter, alphanumeric + underscores, max 48 chars) [non-interactive]'
202201
)
203202
.option('--type <type>', 'Agent type: create, byo, or import [non-interactive]', 'create')
204203
.option('--build <type>', 'Build type: CodeZip or Container (default: CodeZip) [non-interactive]')
205204
.option('--language <lang>', 'Language: Python (create), or Python/TypeScript/Other (BYO) [non-interactive]')
206-
.option('--framework <fw>', 'Framework: Strands, LangChain_LangGraph, GoogleADK, OpenAIAgents [non-interactive]')
205+
.option(
206+
'--framework <fw>',
207+
'Framework: Strands, LangChain_LangGraph, CrewAI, GoogleADK, OpenAIAgents [non-interactive]'
208+
)
207209
.option('--model-provider <provider>', 'Model provider: Bedrock, Anthropic, OpenAI, Gemini [non-interactive]')
208210
.option('--api-key <key>', 'API key for non-Bedrock providers [non-interactive]')
209211
.option('--memory <mem>', 'Memory: none, shortTerm, longAndShortTerm (create path only) [non-interactive]')

src/schema/llm-compacted/AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Incorrect enums or regex will cause agents to generate invalid JSON that fails v
4444
### Constraint Comments
4545

4646
```typescript
47-
name: string; // @regex ^[a-zA-Z][a-zA-Z0-9]{0,63}$ @max 64
47+
name: string; // @regex ^[a-zA-Z][a-zA-Z0-9]{0,63}$ @max 48
4848
eventExpiryDuration: number; // @min 7 @max 365 (days)
4949
targets: Target[]; // @min 1 - at least one required
5050
```

src/schema/llm-compacted/agentcore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ interface MemoryStrategy {
9191

9292
interface Credential {
9393
type: 'ApiKeyCredentialProvider';
94-
name: string; // @regex ^[A-Za-z0-9_.-]+$ @min 3 @max 255
94+
name: string; // @regex ^[a-zA-Z0-9\-_]+$ @min 1 @max 128
9595
}

src/schema/schemas/__tests__/agentcore-project.test.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,25 @@ describe('MemorySchema', () => {
224224
describe('CredentialNameSchema', () => {
225225
it('accepts valid credential names', () => {
226226
expect(CredentialNameSchema.safeParse('MyProjectGemini').success).toBe(true);
227-
expect(CredentialNameSchema.safeParse('api-key.v2').success).toBe(true);
227+
expect(CredentialNameSchema.safeParse('api-key-v2').success).toBe(true);
228228
expect(CredentialNameSchema.safeParse('my_cred_123').success).toBe(true);
229229
});
230230

231-
it('rejects names shorter than 3 characters', () => {
232-
expect(CredentialNameSchema.safeParse('ab').success).toBe(false);
233-
expect(CredentialNameSchema.safeParse('a').success).toBe(false);
231+
it('accepts single character name (min 1)', () => {
232+
expect(CredentialNameSchema.safeParse('a').success).toBe(true);
234233
});
235234

236-
it('accepts name with exactly 3 characters', () => {
237-
expect(CredentialNameSchema.safeParse('abc').success).toBe(true);
235+
it('rejects empty name', () => {
236+
expect(CredentialNameSchema.safeParse('').success).toBe(false);
237+
});
238+
239+
it('rejects names longer than 128 characters', () => {
240+
expect(CredentialNameSchema.safeParse('a'.repeat(128)).success).toBe(true);
241+
expect(CredentialNameSchema.safeParse('a'.repeat(129)).success).toBe(false);
242+
});
243+
244+
it('rejects names with dots', () => {
245+
expect(CredentialNameSchema.safeParse('api-key.v2').success).toBe(false);
238246
});
239247

240248
it('rejects names with spaces', () => {

src/schema/schemas/agent-env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type { PythonRuntime, NodeRuntime, RuntimeVersion, NetworkMode, ProtocolM
2222
// Name Schemas
2323
// ============================================================================
2424

25+
// https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateAgentRuntime.html
2526
export const AgentNameSchema = z
2627
.string()
2728
.min(1, 'Name is required')
@@ -40,6 +41,7 @@ export const EnvVarNameSchema = z
4041
'Must start with a letter or underscore, contain only letters, digits, and underscores'
4142
);
4243

44+
// https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateGateway.html
4345
export const GatewayNameSchema = z
4446
.string()
4547
.min(1)

src/schema/schemas/agentcore-project.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export { AgentCoreGatewaySchema, AgentCoreGatewayTargetSchema, AgentCoreMcpRunti
5656
// Project Name Schema
5757
// ============================================================================
5858

59+
// Project name is a CLI-only concept (combined with agent name to form the runtime name).
60+
// Max 23 so that projectName + "_" + agentName fits within the 48-char runtime name limit.
5961
export const ProjectNameSchema = z
6062
.string()
6163
.min(1, 'Project name is required')
@@ -75,6 +77,8 @@ export const ProjectNameSchema = z
7577
export const MemoryTypeSchema = z.literal('AgentCoreMemory');
7678
export type MemoryType = z.infer<typeof MemoryTypeSchema>;
7779

80+
// Memory names follow the same constraints as agent runtime names.
81+
// https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateMemory.html
7882
export const MemoryNameSchema = z
7983
.string()
8084
.min(1, 'Name is required')
@@ -108,14 +112,12 @@ export type Memory = z.infer<typeof MemorySchema>;
108112
// Credential Schema
109113
// ============================================================================
110114

115+
// https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateApiKeyCredentialProvider.html
111116
export const CredentialNameSchema = z
112117
.string()
113-
.min(3, 'Credential name must be at least 3 characters')
114-
.max(255)
115-
.regex(
116-
/^[A-Za-z0-9_.-]+$/,
117-
'Must contain only alphanumeric characters, underscores, dots, and hyphens (3-255 chars)'
118-
);
118+
.min(1, 'Credential name is required')
119+
.max(128, 'Credential name must be 128 characters or less')
120+
.regex(/^[a-zA-Z0-9\-_]+$/, 'Must contain only alphanumeric characters, hyphens, and underscores (1-128 chars)');
119121

120122
export const CredentialTypeSchema = z.enum(['ApiKeyCredentialProvider', 'OAuthCredentialProvider']);
121123
export type CredentialType = z.infer<typeof CredentialTypeSchema>;

0 commit comments

Comments
 (0)