-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix(agent): resolve iteration cap from the agent definition, not the global default (#4868) #4870
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
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 |
|---|---|---|
|
|
@@ -135,7 +135,6 @@ pub(super) async fn run_autonomous( | |
| run_id: &str, | ||
| session_thread_id: Option<String>, | ||
| ) -> Result<String, String> { | ||
| config.agent.max_tool_iterations = TASK_RUN_MAX_ITERATIONS; | ||
| // Match skill-run egress handling: only widen to the permissive default | ||
| // when the operator hasn't configured an explicit allow-list. See the | ||
| // threat-model note above on why `*` is the default here. | ||
|
|
@@ -151,6 +150,13 @@ pub(super) async fn run_autonomous( | |
| executor.profile.as_ref(), | ||
| ) | ||
| .map_err(|e| format!("build agent: {e:#}"))?; | ||
| // Issue #4868 — apply the autonomous task-run iteration budget AFTER | ||
| // construction. The session builder now stamps the resolved agent | ||
| // definition's own cap onto the agent; an autonomous task run | ||
| // intentionally needs a much larger budget (200), so this must be a | ||
| // post-construction override rather than a pre-set on `config` (which | ||
| // the builder would otherwise clobber). | ||
| agent.set_max_tool_iterations(TASK_RUN_MAX_ITERATIONS); | ||
|
Comment on lines
+153
to
+159
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. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Post-construction override is correct; missing state-transition log. The override logic itself is sound and matches As per coding guidelines, "New or changed flows should log entry/exit, branches, external calls, retries/timeouts, state transitions, and errors with stable prefixes and correlation fields." 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| agent.set_event_context(run_id.to_string(), "task"); | ||
| agent.set_agent_definition_name(format!( | ||
| "task-{}-{}", | ||
|
|
||
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.
This shared assignment also gives
flow_discoveryits extended effective cap of 50, butflows_discoverstill wraps the turn inFLOW_DISCOVER_TIMEOUT_SECS = 300atsrc/openhuman/flows/ops.rs:3198-3200. With slower providers or tool calls averaging just over 6s per loop, the fixed 300s wall-clock timeout fires before the newly applied definition cap can be reached;workflow_builderwas moved to a 600s bound for the same 50-iteration budget, so Flow Scout needs the same treatment or equivalent scaling.Useful? React with 👍 / 👎.