Skip to content

Commit 63472c3

Browse files
committed
fix: align name constraints with API docs
- 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 6b1cf79 commit 63472c3

8 files changed

Lines changed: 33 additions & 18 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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
195195
addCmd
196196
.command('agent')
197197
.description('Add an agent to the project')
198-
.option('--name <name>', 'Agent name (start with letter, alphanumeric only, max 64 chars) [non-interactive]')
198+
.option(
199+
'--name <name>',
200+
'Agent name (start with letter, alphanumeric + underscores, max 48 chars) [non-interactive]'
201+
)
199202
.option('--type <type>', 'Agent type: create, byo, or import [non-interactive]', 'create')
200203
.option('--build <type>', 'Build type: CodeZip or Container (default: CodeZip) [non-interactive]')
201204
.option('--language <lang>', 'Language: Python (create), or Python/TypeScript/Other (BYO) [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
@@ -90,5 +90,5 @@ interface MemoryStrategy {
9090

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

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
@@ -49,6 +49,8 @@ export { AgentCoreGatewaySchema, AgentCoreGatewayTargetSchema, AgentCoreMcpRunti
4949
// Project Name Schema
5050
// ============================================================================
5151

52+
// Project name is a CLI-only concept (combined with agent name to form the runtime name).
53+
// Max 23 so that projectName + "_" + agentName fits within the 48-char runtime name limit.
5254
export const ProjectNameSchema = z
5355
.string()
5456
.min(1, 'Project name is required')
@@ -68,6 +70,8 @@ export const ProjectNameSchema = z
6870
export const MemoryTypeSchema = z.literal('AgentCoreMemory');
6971
export type MemoryType = z.infer<typeof MemoryTypeSchema>;
7072

73+
// Memory names follow the same constraints as agent runtime names.
74+
// https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateMemory.html
7175
export const MemoryNameSchema = z
7276
.string()
7377
.min(1, 'Name is required')
@@ -101,14 +105,12 @@ export type Memory = z.infer<typeof MemorySchema>;
101105
// Credential Schema
102106
// ============================================================================
103107

108+
// https://docs.aws.amazon.com/bedrock-agentcore-control/latest/APIReference/API_CreateApiKeyCredentialProvider.html
104109
export const CredentialNameSchema = z
105110
.string()
106-
.min(3, 'Credential name must be at least 3 characters')
107-
.max(255)
108-
.regex(
109-
/^[A-Za-z0-9_.-]+$/,
110-
'Must contain only alphanumeric characters, underscores, dots, and hyphens (3-255 chars)'
111-
);
111+
.min(1, 'Credential name is required')
112+
.max(128, 'Credential name must be 128 characters or less')
113+
.regex(/^[a-zA-Z0-9\-_]+$/, 'Must contain only alphanumeric characters, hyphens, and underscores (1-128 chars)');
112114

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

0 commit comments

Comments
 (0)