Skip to content

Commit 2e5ebb5

Browse files
committed
Add configurable execution limits for beeai
1 parent 6661561 commit 2e5ebb5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

beeai/agents/base_agent.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import os
12
from abc import ABC, abstractmethod
23
from typing import TypeVar
34

45
from pydantic import BaseModel
56

7+
from beeai_framework.agents import AgentExecutionConfig
68
from beeai_framework.agents.experimental import RequirementAgent, RequirementAgentRunOutput
79
from beeai_framework.template import PromptTemplate, PromptTemplateInput
810

@@ -31,9 +33,18 @@ def _render_prompt(self, input: TInputSchema) -> str:
3133
return template.render(input)
3234

3335
async def _run_with_schema(self, input: TInputSchema) -> TOutputSchema:
36+
max_retries_per_step = int(os.getenv("BEEAI_MAX_RETRIES_PER_STEP", 5))
37+
total_max_retries = int(os.getenv("BEEAI_TOTAL_MAX_RETRIES", 10))
38+
max_iterations = int(os.getenv("BEEAI_MAX_ITERATIONS", 100))
39+
3440
response = await self.run(
3541
prompt=self._render_prompt(input),
3642
expected_output=self.output_schema,
43+
execution=AgentExecutionConfig(
44+
max_retries_per_step=max_retries_per_step,
45+
total_max_retries=total_max_retries,
46+
max_iterations=max_iterations,
47+
),
3748
)
3849
return self.output_schema.model_validate_json(response.result.text)
3950

beeai/templates/beeai-agent.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@ CHAT_MODEL=
55
#GEMINI_API_KEY=
66
#ANTHROPIC_API_KEY=
77

8+
# BeeAI Framework Configuration
9+
BEEAI_MAX_ITERATIONS=100
10+
BEEAI_MAX_RETRIES_PER_STEP=5
11+
BEEAI_TOTAL_MAX_RETRIES=10
12+
813
GITLAB_USER=
914
GITLAB_TOKEN=

0 commit comments

Comments
 (0)