sigoden/aichat · error
Some variable values are not key=value pairs
Error message
Some variable values are not key=value pairs
What it means
The `.agent` REPL command accepts variables as `key=value` pairs; pairs without an '=' separator are dropped by `split_once('=')` via `filter_map`. If any pair is dropped (`variables.len() != variable_pairs.len()`), the command bails with this error instead of silently setting incomplete variables.
Solutions
- Ensure every variable argument is formatted as key=value with an '=' separator
- Quote variable pairs containing spaces: --var "msg=hello world"
- Check the agent invocation syntax with .help before retrying
Example fix
// before: .agent myagent --var API_KEY .agent myagent --var API_KEY=sk-123 // after (quoting for values with spaces) .agent myagent --var "msg=hello world"
Defensive patterns
Strategy: validation
Validate before calling
let pairs = ["API_KEY=sk-123", "msg=hello"];
assert!(pairs.iter().all(|p| p.split_once('=').is_some()), "every --var must be key=value"); Type guard
fn parse_var(s: &str) -> Option<(String, String)> {
s.split_once('=').map(|(k, v)| (k.to_string(), v.to_string()))
} Try / catch
match run_repl_command(...).await {
Err(e) if e.to_string().contains("not key=value pairs") => {
eprintln!("Format variables as key=value, quoting pairs with spaces");
}
other => other?,
} Prevention
- Always include '=' in each --var argument
- Quote variable pairs that contain spaces
- Test variable syntax with .help examples before long sessions
When it happens
Trigger: Running `.agent <name> --var foo` or `.agent <name> --var foo bar` — any variable argument missing the '=' separator between key and value.
Common situations: Typing `--var API_KEY` instead of `--var API_KEY=xyz`; shell stripping quotes so a value with spaces splits into separate args (e.g. `--var msg=hello world`); forgetting to quote pairs containing spaces.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- No TTY for REPL
- Unknown command. Type ".help" for additional help.
- No models
- Unknown client
- Already in a session, please run '.exit session' first to…
AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09).
Data as JSON: /api/errors/376bcc8b6082a713.
Report an issue: GitHub.
Appendix: source
Thrown at src/repl/mod.rs:466
}
".rag" => {
Config::use_rag(config, args, abort_signal.clone()).await?;
}
".agent" => match split_first_arg(args) {
Some((agent_name, args)) => {
let (new_args, _) = split_args_text(args.unwrap_or_default(), cfg!(windows));
let (session_name, variable_pairs) = match new_args.first() {
Some(name) if name.contains('=') => (None, new_args.as_slice()),
Some(name) => (Some(name.as_str()), &new_args[1..]),
None => (None, &[] as &[String]),
};
let variables: AgentVariables = variable_pairs
.iter()
.filter_map(|v| v.split_once('='))
.map(|(key, value)| (key.to_string(), value.to_string()))
.collect();
if variables.len() != variable_pairs.len() {
bail!("Some variable values are not key=value pairs");
}
if !variables.is_empty() {
config.write().agent_variables = Some(variables);
}
let ret =
Config::use_agent(config, agent_name, session_name, abort_signal.clone())
.await;
config.write().agent_variables = None;
ret?;
}
None => {
println!(r#"Usage: .agent <agent-name> [session-name] [key=value]..."#)
}
},
".starter" => match args {
Some(id) => {
let mut text = None;
if let Some(agent) = config.read().agent.as_ref() {View on GitHub (pinned to 82976d349a)