File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
packages/cdk/lambda-python/generic-agent-core-runtime/src Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 99from strands import Agent as StrandsAgent
1010from strands .models import BedrockModel
1111
12- from .config import extract_model_info , get_system_prompt , get_max_iterations
12+ from .config import extract_model_info , get_max_iterations , get_system_prompt
1313from .tools import ToolManager
1414from .types import Message , ModelInfo
1515from .utils import process_messages , process_prompt
1616
1717logger = logging .getLogger (__name__ )
1818
19+
1920class IterationLimitExceededError (Exception ):
2021 """Exception raised when iteration limit is exceeded"""
22+
2123 pass
2224
25+
2326class AgentManager :
2427 """Manages Strands agent creation and execution."""
2528
@@ -37,9 +40,8 @@ def iteration_limit_handler(self, **ev):
3740 if ev .get ("start_event_loop" ):
3841 self .iteration_count += 1
3942 if self .iteration_count > self .max_iterations :
40- raise IterationLimitExceededError (
41- f"Event loop reached maximum iteration count ({ self .max_iterations } ). Please contact the administrator."
42- )
43+ raise IterationLimitExceededError (f"Event loop reached maximum iteration count ({ self .max_iterations } ). Please contact the administrator." )
44+
4345 async def process_request_streaming (
4446 self ,
4547 messages : list [Message ] | list [dict [str , Any ]],
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ def extract_model_info(model_info: Any) -> tuple[str, str]:
7474
7575 return model_id , region
7676
77+
7778def get_max_iterations () -> int :
7879 """Get maximum iterations from environment or default to {DEFAULT_MAX_ITERATIONS}"""
7980 try :
You can’t perform that action at this time.
0 commit comments