Hmbown/CodeWhale · error
agent profile must be a simple token
Error message
agent profile {} {field} must be a simple token What it means
Token fields in agent profiles must be simple tokens: no surrounding whitespace and every character must satisfy is_agent_profile_token_char. A value that trims differently than itself or contains disallowed characters (spaces, punctuation, unicode) is rejected.
Solutions
- Rewrite the value using only simple token characters (letters, digits, hyphens/underscores — see is_agent_profile_token_char)
- Remove leading/trailing whitespace from the field
- Move any descriptive text into a comment or a display-name field that is not token-validated
Example fix
// before id = "My Research Agent" // after id = "my-research-agent"
Defensive patterns
Strategy: validation
Validate before calling
fn is_simple_token(s: &str) -> bool {
let t = s.trim();
t == s && !t.is_empty() && t.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
}
if !is_simple_token(&profile.id) { eprintln!("id must be a simple token"); } Type guard
fn is_simple_token(s: &str) -> bool {
let t = s.trim();
t == s && !t.is_empty() && t.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
} Try / catch
match result {
Err(e) if e.to_string().contains("must be a simple token") => {
eprintln!("rewrite the field using only letters, digits, hyphens, underscores");
}
other => other?,
} Prevention
- Use kebab-case ids without spaces or punctuation in profiles
- Strip whitespace from values before writing generated profiles
- Keep human-readable descriptions out of token-validated fields
When it happens
Trigger: An agent profile field such as id = "my agent" (space inside), id = " researcher" (leading space), or containing characters like '/' or ':' passed through validate_agent_profile_token from load_agent_profile_identity_file or agent_profile_from_toml.
Common situations: Human-readable display names put into id fields ('My Research Agent!'); pasted values carrying leading/trailing whitespace; ids copied from paths or model strings containing slashes.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- agent profile cannot be empty
- agent profile model must be a visible model id without…
- agent profile may not disable approval_required
- agent profile may not request allow_shell=true
- agent profile may not request trust=true
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/0676ce2bf1967134.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/fleet/profile.rs:528
);
}
if permissions.approval_required == Some(false) {
bail!(
"agent profile {} may not disable approval_required",
path.display()
);
}
}
Ok(())
}
fn validate_agent_profile_token(path: &Path, field: &str, value: &str) -> Result<()> {
let trimmed = value.trim();
if trimmed.is_empty() {
bail!("agent profile {} {field} cannot be empty", path.display());
}
if trimmed != value || !trimmed.chars().all(is_agent_profile_token_char) {
bail!(
"agent profile {} {field} must be a simple token",
path.display()
);
}
Ok(())
}
fn validate_agent_profile_model_hint(path: &Path, value: Option<&str>) -> Result<()> {
let Some(value) = value else {
return Ok(());
};
if !is_model_hint(value) {
bail!(
"agent profile {} model must be a visible model id without whitespace or secrets",
path.display()
);
}
Ok(())View on GitHub (pinned to 73e0f67d83)