Honor personality = "none" in model instructions (#32277)

## Why

Model catalog instructions can include a baked-in `# Personality` section. An
explicit `none` setting should omit that section instead of sending it as part
of the model's base instructions.

## What changed

- Pass the configured personality into the models manager.
- When personality support is enabled and the setting is explicitly `none`,
  remove the `# Personality` section through the next level-one heading from
  catalog base instructions and instruction templates.
- Preserve explicit `base_instructions` overrides and avoid warning when no
  personality was requested.

## Testing

Added unit and integration coverage for section removal, heading boundaries,
CRLF input, preserved configurations, and explicit base instructions.

GitOrigin-RevId: 452c88d3ac6001c2ac7d4fef269cd75dc239fa61
This commit is contained in:
rhan-oai
2026-07-10 21:39:56 +00:00
committed by copyberry
parent e7d0e14172
commit 09ccae2c07
6 changed files with 220 additions and 9 deletions
+10 -7
View File
@@ -465,14 +465,17 @@ impl ModelInfo {
.get_personality_message(personality)
.unwrap_or_default();
template.replace(PERSONALITY_PLACEHOLDER, personality_message.as_str())
} else if let Some(personality) = personality {
warn!(
model = %self.slug,
%personality,
"Model personality requested but model_messages is missing, falling back to base instructions."
);
self.base_instructions.clone()
} else {
match personality {
Some(personality @ (Personality::Friendly | Personality::Pragmatic)) => {
warn!(
model = %self.slug,
%personality,
"Model personality requested but model_messages is missing, falling back to base instructions."
);
}
Some(Personality::None) | None => {}
}
self.base_instructions.clone()
}
}