-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Update tool_loop_agent_runner.py #6725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,9 +139,9 @@ async def reset( | |
| # TODO: 2. after LLM output a tool call | ||
| self.context_config = ContextConfig( | ||
| # <=0 will never do compress | ||
| max_context_tokens=provider.provider_config.get("max_context_tokens", 0), | ||
| max_context_tokens=provider.provider_config.get("max_context_tokens", 4096), | ||
| # enforce max turns before compression | ||
| enforce_max_turns=self.enforce_max_turns, | ||
| enforce_max_turns=self.enforce_max_turns if self.enforce_max_turns != -1 else 15, | ||
| truncate_turns=self.truncate_turns, | ||
| llm_compress_instruction=self.llm_compress_instruction, | ||
| llm_compress_keep_recent=self.llm_compress_keep_recent, | ||
|
|
@@ -606,6 +606,8 @@ async def step_until_done( | |
| ) -> T.AsyncGenerator[AgentResponse, None]: | ||
| """Process steps until the agent is done.""" | ||
| step_count = 0 | ||
| # TODO:将max_step由30改为一个较小的值 | ||
| max_step = min(max_step, 3) | ||
|
Comment on lines
+609
to
+610
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Hard-capping max_step to 3 may break callers and can fail when max_step is None or non-positive. Rebinding
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value MAX_TOOL_STEPS_CAP = 3Then, you could use |
||
| while not self.done() and step_count < max_step: | ||
| step_count += 1 | ||
| async for resp in self.step(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values
4096and15are used as magic numbers for default configuration values. To improve code clarity and maintainability, it's recommended to define these as named constants at the module level. For example:These constants can then be used here, making the code easier to understand and modify in the future.