allow a max_subagents of 0: no subagents for the agent
This commit is contained in:
parent
7539ef82f7
commit
a1f99c77f8
7 changed files with 85 additions and 31 deletions
|
|
@ -53,8 +53,8 @@ pub struct InferenceSettings {
|
|||
/// The models the agent may start its subagents on. At least one.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
subagent_models: Option<Vec<String>>,
|
||||
/// How many subagents the agent may have running at once, from 1 to
|
||||
/// [`MAX_SUBAGENTS`]. Absent is no cap.
|
||||
/// How many subagents the agent may have running at once, from 0 (no
|
||||
/// subagents) to [`MAX_SUBAGENTS`]. Absent is no cap.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
max_subagents: Option<u32>,
|
||||
}
|
||||
|
|
@ -107,10 +107,10 @@ impl InferenceSettings {
|
|||
}
|
||||
}
|
||||
if let Some(max) = self.max_subagents
|
||||
&& !(1..=MAX_SUBAGENTS).contains(&max)
|
||||
&& max > MAX_SUBAGENTS
|
||||
{
|
||||
return Err(format!(
|
||||
"max_subagents is {max}; it is from 1 to {MAX_SUBAGENTS}, or left out for no cap"
|
||||
"max_subagents is {max}; it is from 0 (no subagents) to {MAX_SUBAGENTS}, or left out for no cap"
|
||||
));
|
||||
}
|
||||
Ok(AgentInference {
|
||||
|
|
@ -286,7 +286,7 @@ pub(crate) async fn get_agent_inference(
|
|||
ones whole", body = InferenceSettings),
|
||||
(status = 400, description = "not an identifier, not declared on any hive, or a \
|
||||
model name is empty, has whitespace, starts with `-`, or is listed \
|
||||
twice, or `max_subagents` is outside 1 to 32 (problem+json)",
|
||||
twice, or `max_subagents` is above 32 (problem+json)",
|
||||
body = String),
|
||||
(status = 422, description = "an unknown field, or an effort that is not one of \
|
||||
the five levels"),
|
||||
|
|
@ -558,15 +558,18 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn max_subagents_outside_its_range_is_refused() {
|
||||
for json in [r#"{"max_subagents":0}"#, r#"{"max_subagents":33}"#] {
|
||||
assert!(settings(json).unwrap().into_stored().is_err(), "{json}");
|
||||
}
|
||||
assert!(
|
||||
settings(r#"{"max_subagents":33}"#)
|
||||
.unwrap()
|
||||
.into_stored()
|
||||
.is_err()
|
||||
);
|
||||
assert!(settings(r#"{"max_subagents":-1}"#).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn max_subagents_in_range_is_stored() {
|
||||
for max in [1, 3, MAX_SUBAGENTS] {
|
||||
for max in [0, 1, 3, MAX_SUBAGENTS] {
|
||||
let stored = settings(&format!(r#"{{"max_subagents":{max}}}"#))
|
||||
.unwrap()
|
||||
.into_stored()
|
||||
|
|
|
|||
Loading…
Reference in a new issue