Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(config): bound max_actions_per_hour to its real u32 range

obchain916b557bcdca
diff --git a/crates/openhuman-core/src/config/schemas/controllers/agent.rs b/crates/openhuman-core/src/config/schemas/controllers/agent.rs
index 5a9df48004..515e61c1b8 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/agent.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/agent.rs
@@ -25,9 +25,7 @@ pub(crate) fn handle_update_autonomy_settings(params: Map<String, Value>) -> Con
forbidden_paths: update.forbidden_paths,
trusted_roots: update.trusted_roots,
allow_tool_install: update.allow_tool_install,
- max_actions_per_hour: update
- .max_actions_per_hour
- .map(|v| u32::try_from(v).unwrap_or(u32::MAX)),
+ max_actions_per_hour: update.max_actions_per_hour,
auto_approve: update.auto_approve,
require_task_plan_approval: update.require_task_plan_approval,
auto_approve_all: update.auto_approve_all,
diff --git a/crates/openhuman-core/src/config/schemas/helpers.rs b/crates/openhuman-core/src/config/schemas/helpers.rs
index 5f12520b5a..195cc42daa 100644
--- a/crates/openhuman-core/src/config/schemas/helpers.rs
+++ b/crates/openhuman-core/src/config/schemas/helpers.rs
@@ -200,9 +200,7 @@ pub(super) struct AutonomySettingsUpdate {
/// `{ "path": "/abs/dir", "access": "read" | "readwrite" }`.
pub(super) trusted_roots: Option<Vec<crate::security::TrustedRoot>>,
pub(super) allow_tool_install: Option<bool>,
- // Accept u64 to match the published schema (`TypeSchema::U64`); clamped to the
- // internal u32 at apply time. u32::MAX/hr is already effectively unlimited.
- pub(super) max_actions_per_hour: Option<u64>,
+ pub(super) max_actions_per_hour: Option<u32>,
/// Replaces the "Always allow" allowlist wholesale — tool names the agent
/// may run without an approval prompt. Empty list clears it.
pub(super) auto_approve: Option<Vec<String>>,
diff --git a/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs b/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
index 4f1e677c39..b2dfa6cc8d 100644
--- a/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
+++ b/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
@@ -41,8 +41,13 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
optional_bool("allow_tool_install", "Allow the agent to install OS packages via install_tool (intended for Full mode)."),
FieldSchema {
name: "max_actions_per_hour",
- ty: TypeSchema::Option(Box::new(TypeSchema::U64)),
- comment: "Rate limit for side-effecting actions per hour.",
+ // A non-zero `u32`: 0 is refused by the apply path, and
+ // u32::MAX is the "unlimited" sentinel the UI saves.
+ ty: TypeSchema::Option(Box::new(TypeSchema::BoundedU64 {
+ min: 1,
+ max: u32::MAX as u64,
+ })),
+ comment: "Rate limit for side-effecting actions per hour (1..=4294967295; 4294967295 = unlimited).",
required: false,
},
FieldSchema {
diff --git a/tests/raw_coverage/dispatch_param_validation_e2e.rs b/tests/raw_coverage/dispatch_param_validation_e2e.rs
index ab060fb902..5440775759 100644
--- a/tests/raw_coverage/dispatch_param_validation_e2e.rs
+++ b/tests/raw_coverage/dispatch_param_validation_e2e.rs
@@ -144,3 +144,36 @@ async fn explicit_null_passes_the_gate_and_the_handler_refuses_instead() {
"the gate must NOT have refused this: {err}"
);
}
+
+/// A field backed by a `u32` declares its real range, so a value that is a
+/// valid `u64` but not a valid `u32` is refused at the gate with the bound
+/// named — rather than passing validation and failing (or, before #6137, being
+/// silently clamped to "unlimited") inside the handler.
+#[tokio::test]
+async fn out_of_range_integer_is_refused_with_the_bound_named() {
+ let err = dispatch(
+ state(),
+ "openhuman.config_update_autonomy_settings",
+ json!({ "max_actions_per_hour": 4_294_967_296u64 }),
+ )
+ .await
+ .expect_err("4294967296 does not fit the u32 field");
+ assert_eq!(
+ err,
+ "invalid type for param 'max_actions_per_hour' in config.update_autonomy_settings: \
+ expected unsigned integer <= 4294967295, got 4294967296"
+ );
+
+ let err = dispatch(
+ state(),
+ "openhuman.config_update_autonomy_settings",
+ json!({ "max_actions_per_hour": 0 }),
+ )
+ .await
+ .expect_err("0 is below the declared minimum");
+ assert_eq!(
+ err,
+ "invalid type for param 'max_actions_per_hour' in config.update_autonomy_settings: \
+ expected unsigned integer >= 1, got 0"
+ );
+}