Skip to content

Commit 212b3f5

Browse files
qlitreclaude
andauthored
Fix/configurable agent foundation model (#1527)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 0674699 commit 212b3f5

8 files changed

Lines changed: 102 additions & 7 deletions

File tree

docs/en/DEPLOY_OPTION.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,34 @@ const envs: Record<string, Partial<StackInput>> = {
402402
}
403403
```
404404

405+
#### Customizing Agent Foundation Model
406+
407+
You can customize the foundation model used by Code Interpreter and Search Agent. By default, `global.anthropic.claude-sonnet-4-6` is used.
408+
409+
- `agentFoundationModel` : Specify the model to use for agents. Only models supported by Bedrock Agent are available.
410+
411+
**Edit [parameter.ts](/packages/cdk/parameter.ts)**
412+
413+
```typescript
414+
// parameter.ts
415+
const envs: Record<string, Partial<StackInput>> = {
416+
dev: {
417+
agentFoundationModel: 'global.anthropic.claude-sonnet-4-6',
418+
},
419+
};
420+
```
421+
422+
**Edit [packages/cdk/cdk.json](/packages/cdk/cdk.json)**
423+
424+
```json
425+
// cdk.json
426+
{
427+
"context": {
428+
"agentFoundationModel": "global.anthropic.claude-sonnet-4-6"
429+
}
430+
}
431+
```
432+
405433
#### Deploying Search Agent
406434

407435
Creates an Agent that connects to APIs to reference the latest information for responses. You can customize the Agent to add other actions and create multiple Agents to switch between.

docs/ja/DEPLOY_OPTION.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,34 @@ const envs: Record<string, Partial<StackInput>> = {
417417
}
418418
```
419419

420+
#### エージェントの基盤モデルのカスタマイズ
421+
422+
Code Interpreter および検索エージェントで使用する基盤モデルをカスタマイズできます。デフォルトでは `global.anthropic.claude-sonnet-4-6` が使用されます。
423+
424+
- `agentFoundationModel` : エージェントで利用するモデルを指定してください。Bedrock Agent がサポートするモデルのみ利用可能です。
425+
426+
**[parameter.ts](/packages/cdk/parameter.ts) を編集**
427+
428+
```typescript
429+
// parameter.ts
430+
const envs: Record<string, Partial<StackInput>> = {
431+
dev: {
432+
agentFoundationModel: 'global.anthropic.claude-sonnet-4-6',
433+
},
434+
};
435+
```
436+
437+
**[packages/cdk/cdk.json](/packages/cdk/cdk.json) を編集**
438+
439+
```json
440+
// cdk.json
441+
{
442+
"context": {
443+
"agentFoundationModel": "global.anthropic.claude-sonnet-4-6"
444+
}
445+
}
446+
```
447+
420448
#### 検索エージェントのデプロイ
421449

422450
API と連携し最新情報を参照して回答する Agent を作成します。Agent のカスタマイズを行い他のアクションを追加できるほか、複数の Agent を作成し切り替えることが可能です。

docs/ko/DEPLOY_OPTION.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,34 @@ const envs: Record<string, Partial<StackInput>> = {
403403
}
404404
```
405405

406+
#### 에이전트 기반 모델 사용자 정의
407+
408+
Code Interpreter 및 Search Agent에서 사용하는 기반 모델을 사용자 정의할 수 있습니다. 기본적으로 `global.anthropic.claude-sonnet-4-6`이 사용됩니다.
409+
410+
- `agentFoundationModel` : 에이전트에 사용할 모델을 지정합니다. Bedrock Agent가 지원하는 모델만 사용할 수 있습니다.
411+
412+
**[parameter.ts](/packages/cdk/parameter.ts) 편집**
413+
414+
```typescript
415+
// parameter.ts
416+
const envs: Record<string, Partial<StackInput>> = {
417+
dev: {
418+
agentFoundationModel: 'global.anthropic.claude-sonnet-4-6',
419+
},
420+
};
421+
```
422+
423+
**[packages/cdk/cdk.json](/packages/cdk/cdk.json) 편집**
424+
425+
```json
426+
// cdk.json
427+
{
428+
"context": {
429+
"agentFoundationModel": "global.anthropic.claude-sonnet-4-6"
430+
}
431+
}
432+
```
433+
406434
#### Search Agent 배포
407435

408436
API에 연결하여 최신 정보를 참조하여 응답하는 Agent를 생성합니다. Agent를 사용자 정의하여 다른 작업을 추가하고 여러 Agent를 생성하여 전환할 수 있습니다.

packages/cdk/cdk.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"speechToSpeechModelIds": ["amazon.nova-sonic-v1:0"],
6060
"endpointNames": [],
6161
"agentEnabled": false,
62+
"agentFoundationModel": "global.anthropic.claude-sonnet-4-6",
6263
"searchAgentEnabled": false,
6364
"searchEngine": "Brave",
6465
"searchApiKey": "",

packages/cdk/lib/agent-stack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ export class AgentStack extends Stack {
1717
constructor(scope: Construct, id: string, props: AgentStackProps) {
1818
super(scope, id, props);
1919

20-
const { searchAgentEnabled, searchApiKey, searchEngine } = props.params;
20+
const {
21+
searchAgentEnabled,
22+
searchApiKey,
23+
searchEngine,
24+
agentFoundationModel,
25+
} = props.params;
2126

2227
const agent = new Agent(this, 'Agent', {
2328
searchAgentEnabled,
2429
searchApiKey,
2530
searchEngine,
2631
vpc: props.vpc,
32+
foundationModel: agentFoundationModel,
2733
});
2834

2935
this.agents = agent.agents;

packages/cdk/lib/construct/agent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface AgentProps {
2626
readonly searchApiKey?: string | null;
2727
readonly searchEngine?: StackInput['searchEngine'];
2828
readonly vpc?: IVpc;
29+
readonly foundationModel: string;
2930
}
3031

3132
export class Agent extends Construct {
@@ -126,7 +127,7 @@ export class Agent extends Construct {
126127
idleSessionTtlInSeconds: 3600,
127128
autoPrepare: true,
128129
description: searchAgentDescription,
129-
foundationModel: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
130+
foundationModel: props.foundationModel,
130131
instruction: `You are an advanced assistant with the ability to search and retrieve information from the web to perform complex research tasks.
131132
Your main function is to solve problems and meet user requests by utilizing these capabilities.
132133
Your main characteristics and instructions are as follows.
@@ -171,7 +172,7 @@ Automatically detect the language of the user's request and think and answer in
171172
idleSessionTtlInSeconds: 3600,
172173
autoPrepare: true,
173174
description: 'Code Interpreter',
174-
foundationModel: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
175+
foundationModel: props.foundationModel,
175176
instruction: `You are an advanced AI agent with the ability to execute code, generate charts, and perform complex data analysis.
176177
Your main function is to solve problems and meet user requests by utilizing these capabilities.
177178
Your main characteristics and instructions are as follows.

packages/cdk/lib/stack-input.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ const baseStackInputSchema = z.object({
133133
rerankingModelId: z.string().nullish(),
134134
// Agent
135135
agentEnabled: z.boolean().default(false),
136+
agentFoundationModel: z
137+
.string()
138+
.default('global.anthropic.claude-sonnet-4-6'),
136139
searchAgentEnabled: z.boolean().default(false),
137140
searchApiKey: z.string().nullish(),
138141
searchEngine: z.enum(['Brave', 'Tavily']).default('Brave'),

packages/cdk/test/__snapshots__/generative-ai-use-cases.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,7 +3402,7 @@ exports[`GenerativeAiUseCases matches the snapshot (closed network mode) 3`] = `
34023402
},
34033403
"AutoPrepare": true,
34043404
"Description": "Code Interpreter",
3405-
"FoundationModel": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
3405+
"FoundationModel": "global.anthropic.claude-sonnet-4-6",
34063406
"IdleSessionTTLInSeconds": 3600,
34073407
"Instruction": "You are an advanced AI agent with the ability to execute code, generate charts, and perform complex data analysis.
34083408
Your main function is to solve problems and meet user requests by utilizing these capabilities.
@@ -3515,7 +3515,7 @@ Automatically detect the language of the user's request and think and answer in
35153515
},
35163516
"AutoPrepare": true,
35173517
"Description": "Agent with Web Search Functionality",
3518-
"FoundationModel": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
3518+
"FoundationModel": "global.anthropic.claude-sonnet-4-6",
35193519
"IdleSessionTTLInSeconds": 3600,
35203520
"Instruction": "You are an advanced assistant with the ability to search and retrieve information from the web to perform complex research tasks.
35213521
Your main function is to solve problems and meet user requests by utilizing these capabilities.
@@ -26375,7 +26375,7 @@ exports[`GenerativeAiUseCases matches the snapshot 3`] = `
2637526375
},
2637626376
"AutoPrepare": true,
2637726377
"Description": "Code Interpreter",
26378-
"FoundationModel": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
26378+
"FoundationModel": "global.anthropic.claude-sonnet-4-6",
2637926379
"IdleSessionTTLInSeconds": 3600,
2638026380
"Instruction": "You are an advanced AI agent with the ability to execute code, generate charts, and perform complex data analysis.
2638126381
Your main function is to solve problems and meet user requests by utilizing these capabilities.
@@ -26488,7 +26488,7 @@ Automatically detect the language of the user's request and think and answer in
2648826488
},
2648926489
"AutoPrepare": true,
2649026490
"Description": "Agent with Web Search Functionality",
26491-
"FoundationModel": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
26491+
"FoundationModel": "global.anthropic.claude-sonnet-4-6",
2649226492
"IdleSessionTTLInSeconds": 3600,
2649326493
"Instruction": "You are an advanced assistant with the ability to search and retrieve information from the web to perform complex research tasks.
2649426494
Your main function is to solve problems and meet user requests by utilizing these capabilities.

0 commit comments

Comments
 (0)