Skip to content

Commit 212a542

Browse files
committed
Merge branch 'main' into feat/agent-builder
2 parents 1c3ed17 + 53bda27 commit 212a542

File tree

11 files changed

+179
-43
lines changed

11 files changed

+179
-43
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ To send us a pull request, please:
3535
5. Send us a pull request, answering any default questions in the pull request interface.
3636
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
3737

38+
For detailed development guidelines including linting and code style requirements, please refer to:
39+
40+
- [DEVELOPMENT.md (English)](docs/en/DEVELOPMENT.md)
41+
- [DEVELOPMENT.md (日本語)](docs/ja/DEVELOPMENT.md)
42+
3843
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
3944
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4045

docs/en/DEVELOPMENT.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,45 @@ npm run web:dev
5252

5353
If executed successfully, it will start at http://localhost:5173, so please try accessing it from your browser.
5454

55+
## Linting and Code Style
56+
57+
This project uses **ESLint** and **Prettier** to enforce code quality and consistent style.
58+
59+
### ESLint Configuration
60+
61+
- **Config files**: ESLint configurations are located in each package directory:
62+
- `packages/web/.eslintrc.cjs` (Frontend)
63+
- `packages/cdk/.eslintrc.cjs` (CDK/Infrastructure)
64+
- `browser-extension/.eslintrc.json` (Browser Extension)
65+
- **Base rules**: We extend commonly used configs:
66+
- `eslint:recommended`
67+
- `plugin:@typescript-eslint/recommended`
68+
- `plugin:react-hooks/recommended` (for React code)
69+
- `plugin:tailwindcss/recommended` (for frontend)
70+
- **Key rules enforced**:
71+
- Unused imports/variables
72+
- React Hooks rules (e.g., `exhaustive-deps`)
73+
- Japanese string detection (i18n compliance)
74+
- YAML formatting and key sorting
75+
76+
### Running ESLint
77+
78+
Before committing, run:
79+
80+
```bash
81+
npm run lint
82+
```
83+
84+
To automatically fix issues:
85+
86+
```bash
87+
npm run web:lint:fix # For frontend code
88+
```
89+
90+
### Pre-commit Hook
91+
92+
This repository uses [Husky](https://typicode.github.io/husky) for git hooks. Linting runs automatically on `git commit` via `lint-staged`.
93+
5594
## When Submitting a Pull Request
5695

5796
We welcome Pull Requests for bug fixes and feature improvements :tada:
@@ -72,6 +111,12 @@ If you want to ignore this error and create a Draft PR, add the `--no-verify` op
72111
git commit -m "xxx" --no-verify
73112
```
74113

114+
### Review Standards
115+
116+
- Lint rules are used as **review criteria**.
117+
- Please ensure your code passes linting before opening a PR to avoid unnecessary review cycles.
118+
- Consistent style improves readability and reduces back-and-forth in code review.
119+
75120
Also, if there are changes to the CDK, check the snapshots with the following command and update them:
76121

77122
```bash

docs/ja/DEVELOPMENT.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,45 @@ npm run web:dev
5353

5454
正常に実行されれば http://localhost:5173 で起動しますので、ブラウザからアクセスしてみてください。
5555

56+
## Lint とコードスタイル
57+
58+
このプロジェクトでは、コード品質と一貫したスタイルを保つために **ESLint****Prettier** を使用しています。
59+
60+
### ESLint の設定
61+
62+
- **設定ファイルの場所**: ESLint の設定は各パッケージディレクトリに配置されています:
63+
- `packages/web/.eslintrc.cjs` (フロントエンド)
64+
- `packages/cdk/.eslintrc.cjs` (CDK/インフラ)
65+
- `browser-extension/.eslintrc.json` (ブラウザ拡張)
66+
- **ベースルール**: 以下の一般的な設定を拡張しています:
67+
- `eslint:recommended`
68+
- `plugin:@typescript-eslint/recommended`
69+
- `plugin:react-hooks/recommended` (React コード用)
70+
- `plugin:tailwindcss/recommended` (フロントエンド用)
71+
- **主要なルール**:
72+
- 未使用のインポート/変数の検出
73+
- React Hooks のルール (例: `exhaustive-deps`)
74+
- 日本語文字列の検出 (i18n 対応)
75+
- YAML のフォーマットとキーのソート
76+
77+
### ESLint の実行
78+
79+
コミット前に以下を実行してください:
80+
81+
```bash
82+
npm run lint
83+
```
84+
85+
自動修正を行う場合:
86+
87+
```bash
88+
npm run web:lint:fix # フロントエンドコード用
89+
```
90+
91+
### Pre-commit フック
92+
93+
このリポジトリでは [Husky](https://typicode.github.io/husky) を使用して Git フックを管理しています。`git commit` 時に `lint-staged` 経由で自動的に lint が実行されます。
94+
5695
## Pull Request を出す場合
5796

5897
バグ修正や機能改善などの Pull Request は歓迎しております :tada:
@@ -73,6 +112,12 @@ npm run web:dev
73112
git commit -m "xxx" --no-verify
74113
```
75114

115+
### レビュー基準
116+
117+
- Lint ルールは**レビュー基準**として使用されます。
118+
- 不要なレビューサイクルを避けるため、PR を開く前にコードが lint を通過することを確認してください。
119+
- 一貫したスタイルは可読性を向上させ、コードレビューでのやり取りを減らします。
120+
76121
もしCDK に変更があれば以下のコマンドでスナップショットの確認を行いスナップショットを更新してください。
77122

78123
```bash

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cdk/cdk.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@
7777
"crossAccountBedrockRoleArn": "",
7878
"useCaseBuilderEnabled": true,
7979
"closedNetworkMode": false,
80-
"closedNetworkAppIpv4Cidr": "10.0.0.0/16",
81-
"closedNetworkUserIpv4Cidr": "10.1.0.0/16",
80+
"closedNetworkVpcIpv4Cidr": "10.0.0.0/16",
81+
"closedNetworkVpcId": null,
82+
"closedNetworkSubnetIds": null,
8283
"closedNetworkCertificateArn": null,
8384
"closedNetworkDomainName": null,
8485
"closedNetworkCreateTestEnvironment": true,

packages/cdk/lambda-python/generic-agent-core-runtime/src/agent.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from strands import Agent as StrandsAgent
1010
from strands.models import BedrockModel
1111

12-
from .config import extract_model_info, get_system_prompt
12+
from .config import extract_model_info, get_max_iterations, get_system_prompt
1313
from .tools import ToolManager
1414
from .types import Message, ModelInfo
1515
from .utils import (
@@ -21,16 +21,32 @@
2121
logger.setLevel(logging.INFO)
2222

2323

24+
class IterationLimitExceededError(Exception):
25+
"""Exception raised when iteration limit is exceeded"""
26+
27+
pass
28+
29+
2430
class AgentManager:
2531
"""Manages Strands agent creation and execution."""
2632

2733
def __init__(self):
2834
self.tool_manager = ToolManager()
35+
self.max_iterations = get_max_iterations()
36+
self.iteration_count = 0
2937

3038
def set_session_info(self, session_id: str, trace_id: str):
3139
"""Set session and trace IDs"""
3240
self.tool_manager.set_session_info(session_id, trace_id)
3341

42+
def iteration_limit_handler(self, **ev):
43+
if ev.get("init_event_loop"):
44+
self.iteration_count = 0
45+
if ev.get("start_event_loop"):
46+
self.iteration_count += 1
47+
if self.iteration_count > self.max_iterations:
48+
raise IterationLimitExceededError(f"Event loop reached maximum iteration count ({self.max_iterations}). Please contact the administrator.")
49+
3450
async def process_request_streaming(
3551
self,
3652
messages: list[Message] | list[dict[str, Any]],
@@ -82,6 +98,7 @@ async def process_request_streaming(
8298
messages=processed_messages,
8399
model=bedrock_model,
84100
tools=tools,
101+
callback_handler=self.iteration_limit_handler,
85102
)
86103

87104
async for event in agent.stream_async(processed_prompt):

packages/cdk/lambda-python/generic-agent-core-runtime/src/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
WORKSPACE_DIR = "/tmp/ws"
1515

16+
DEFAULT_MAX_ITERATIONS = 20
17+
1618
FIXED_SYSTEM_PROMPT = f"""## About File Output
1719
- You are running on AWS Bedrock AgentCore. Therefore, when writing files, always write them under `{WORKSPACE_DIR}`.
1820
- Similarly, if you need a workspace, please use the `{WORKSPACE_DIR}` directory. Do not ask the user about their current workspace. It's always `{WORKSPACE_DIR}`.
@@ -71,3 +73,12 @@ def extract_model_info(model_info: Any) -> tuple[str, str]:
7173
region = model_info.get("region", aws_creds.get("AWS_REGION", "us-east-1"))
7274

7375
return model_id, region
76+
77+
78+
def get_max_iterations() -> int:
79+
"""Get maximum iterations from environment or default to {DEFAULT_MAX_ITERATIONS}"""
80+
try:
81+
return int(os.environ.get("MAX_ITERATIONS", DEFAULT_MAX_ITERATIONS))
82+
except ValueError:
83+
logger.warning(f"Invalid MAX_ITERATIONS value. Defaulting to {DEFAULT_MAX_ITERATIONS}.")
84+
return DEFAULT_MAX_ITERATIONS

packages/cdk/lambda/utils/models.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,21 @@ export const defaultVideoGenerationModel: Model = {
108108
};
109109

110110
// Model Params
111-
const CLAUDE_4_5_DEFAULT_PARAMS: ConverseInferenceParams = {
111+
const CLAUDE_SONNET_4_DEFAULT_PARAMS: ConverseInferenceParams = {
112112
inferenceConfig: {
113113
maxTokens: 64000,
114114
temperature: 1,
115115
},
116116
};
117117

118+
const CLAUDE_OPUS_4_DEFAULT_PARAMS: ConverseInferenceParams = {
119+
inferenceConfig: {
120+
maxTokens: 32000,
121+
temperature: 1,
122+
topP: 0.999,
123+
},
124+
};
125+
118126
const CLAUDE_3_5_DEFAULT_PARAMS: ConverseInferenceParams = {
119127
inferenceConfig: {
120128
maxTokens: 8192,
@@ -472,9 +480,7 @@ const createConverseCommandInput = (
472480
...params.inferenceConfig,
473481
temperature: 1, // reasoning requires temperature to be 1
474482
topP: undefined, // reasoning does not require topP
475-
maxTokens:
476-
(model.modelParameters?.reasoningConfig?.budgetTokens || 0) +
477-
(params.inferenceConfig?.maxTokens || 0),
483+
maxTokens: params.inferenceConfig?.maxTokens,
478484
};
479485
converseCommandInput.additionalModelRequestFields = {
480486
reasoning_config: {
@@ -929,79 +935,79 @@ export const BEDROCK_TEXT_GEN_MODELS: {
929935
};
930936
} = {
931937
'us.anthropic.claude-opus-4-1-20250805-v1:0': {
932-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
938+
defaultParams: CLAUDE_OPUS_4_DEFAULT_PARAMS,
933939
usecaseParams: USECASE_DEFAULT_PARAMS,
934940
createConverseCommandInput: createConverseCommandInput,
935941
createConverseStreamCommandInput: createConverseStreamCommandInput,
936942
extractConverseOutput: extractConverseOutput,
937943
extractConverseStreamOutput: extractConverseStreamOutput,
938944
},
939945
'us.anthropic.claude-opus-4-20250514-v1:0': {
940-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
946+
defaultParams: CLAUDE_OPUS_4_DEFAULT_PARAMS,
941947
usecaseParams: USECASE_DEFAULT_PARAMS,
942948
createConverseCommandInput: createConverseCommandInput,
943949
createConverseStreamCommandInput: createConverseStreamCommandInput,
944950
extractConverseOutput: extractConverseOutput,
945951
extractConverseStreamOutput: extractConverseStreamOutput,
946952
},
947953
'global.anthropic.claude-sonnet-4-5-20250929-v1:0': {
948-
defaultParams: CLAUDE_4_5_DEFAULT_PARAMS,
954+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
949955
usecaseParams: USECASE_DEFAULT_PARAMS,
950956
createConverseCommandInput: createConverseCommandInput,
951957
createConverseStreamCommandInput: createConverseStreamCommandInput,
952958
extractConverseOutput: extractConverseOutput,
953959
extractConverseStreamOutput: extractConverseStreamOutput,
954960
},
955961
'us.anthropic.claude-sonnet-4-5-20250929-v1:0': {
956-
defaultParams: CLAUDE_4_5_DEFAULT_PARAMS,
962+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
957963
usecaseParams: USECASE_DEFAULT_PARAMS,
958964
createConverseCommandInput: createConverseCommandInput,
959965
createConverseStreamCommandInput: createConverseStreamCommandInput,
960966
extractConverseOutput: extractConverseOutput,
961967
extractConverseStreamOutput: extractConverseStreamOutput,
962968
},
963969
'eu.anthropic.claude-sonnet-4-5-20250929-v1:0': {
964-
defaultParams: CLAUDE_4_5_DEFAULT_PARAMS,
970+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
965971
usecaseParams: USECASE_DEFAULT_PARAMS,
966972
createConverseCommandInput: createConverseCommandInput,
967973
createConverseStreamCommandInput: createConverseStreamCommandInput,
968974
extractConverseOutput: extractConverseOutput,
969975
extractConverseStreamOutput: extractConverseStreamOutput,
970976
},
971977
'jp.anthropic.claude-sonnet-4-5-20250929-v1:0': {
972-
defaultParams: CLAUDE_4_5_DEFAULT_PARAMS,
978+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
973979
usecaseParams: USECASE_DEFAULT_PARAMS,
974980
createConverseCommandInput: createConverseCommandInput,
975981
createConverseStreamCommandInput: createConverseStreamCommandInput,
976982
extractConverseOutput: extractConverseOutput,
977983
extractConverseStreamOutput: extractConverseStreamOutput,
978984
},
979985
'global.anthropic.claude-sonnet-4-20250514-v1:0': {
980-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
986+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
981987
usecaseParams: USECASE_DEFAULT_PARAMS,
982988
createConverseCommandInput: createConverseCommandInput,
983989
createConverseStreamCommandInput: createConverseStreamCommandInput,
984990
extractConverseOutput: extractConverseOutput,
985991
extractConverseStreamOutput: extractConverseStreamOutput,
986992
},
987993
'us.anthropic.claude-sonnet-4-20250514-v1:0': {
988-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
994+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
989995
usecaseParams: USECASE_DEFAULT_PARAMS,
990996
createConverseCommandInput: createConverseCommandInput,
991997
createConverseStreamCommandInput: createConverseStreamCommandInput,
992998
extractConverseOutput: extractConverseOutput,
993999
extractConverseStreamOutput: extractConverseStreamOutput,
9941000
},
9951001
'eu.anthropic.claude-sonnet-4-20250514-v1:0': {
996-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
1002+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
9971003
usecaseParams: USECASE_DEFAULT_PARAMS,
9981004
createConverseCommandInput: createConverseCommandInput,
9991005
createConverseStreamCommandInput: createConverseStreamCommandInput,
10001006
extractConverseOutput: extractConverseOutput,
10011007
extractConverseStreamOutput: extractConverseStreamOutput,
10021008
},
10031009
'apac.anthropic.claude-sonnet-4-20250514-v1:0': {
1004-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
1010+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
10051011
usecaseParams: USECASE_DEFAULT_PARAMS,
10061012
createConverseCommandInput: createConverseCommandInput,
10071013
createConverseStreamCommandInput: createConverseStreamCommandInput,
@@ -1041,23 +1047,23 @@ export const BEDROCK_TEXT_GEN_MODELS: {
10411047
extractConverseStreamOutput: extractConverseStreamOutput,
10421048
},
10431049
'us.anthropic.claude-3-7-sonnet-20250219-v1:0': {
1044-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
1050+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
10451051
usecaseParams: USECASE_DEFAULT_PARAMS,
10461052
createConverseCommandInput: createConverseCommandInput,
10471053
createConverseStreamCommandInput: createConverseStreamCommandInput,
10481054
extractConverseOutput: extractConverseOutput,
10491055
extractConverseStreamOutput: extractConverseStreamOutput,
10501056
},
10511057
'eu.anthropic.claude-3-7-sonnet-20250219-v1:0': {
1052-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
1058+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
10531059
usecaseParams: USECASE_DEFAULT_PARAMS,
10541060
createConverseCommandInput: createConverseCommandInput,
10551061
createConverseStreamCommandInput: createConverseStreamCommandInput,
10561062
extractConverseOutput: extractConverseOutput,
10571063
extractConverseStreamOutput: extractConverseStreamOutput,
10581064
},
10591065
'apac.anthropic.claude-3-7-sonnet-20250219-v1:0': {
1060-
defaultParams: CLAUDE_3_5_DEFAULT_PARAMS,
1066+
defaultParams: CLAUDE_SONNET_4_DEFAULT_PARAMS,
10611067
usecaseParams: USECASE_DEFAULT_PARAMS,
10621068
createConverseCommandInput: createConverseCommandInput,
10631069
createConverseStreamCommandInput: createConverseStreamCommandInput,

0 commit comments

Comments
 (0)