{"record":{"id":"420976fc549658fd","repo":"xai-org/grok-build","slug":"failed-to-create-agent-config-e-420976","errorCode":null,"errorMessage":"Failed to create agent config: {e}","messagePattern":"Failed to create agent config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/acp/mod.rs","lineNumber":290,"sourceCode":"    cancel: &CancellationToken,\n    flags: ConnectFlags,\n    raw_config: &toml::Value,\n) -> Result<AcpConnection> {\n    use xai_grok_shell::leader::{\n        ClientCapabilities, ClientMode, LeaderReconnector, ReconnectPolicy, connect_or_spawn,\n    };\n\n    // These flags are baked into the agent at startup\n    // In leader mode the agent is already running, so per-client overrides cannot be applied\n    warn_unsupported_leader_flags(&flags);\n\n    apply_config_writes(&flags);\n\n    startup::enter(StartupPhase::ConfigLoad);\n    // The leader path never runs the managed-policy sync in this process.\n    startup::set_auth_mode(xai_grok_shell::managed_config::classify_auth_mode());\n    let mut agent_config = AgentConfig::new_from_toml_cfg(raw_config)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create agent config: {e}\"))?;\n    // resolve_telemetry_mode reads remote_settings.\n    agent_config.remote_settings = flags.remote_settings.clone();\n\n    let client_type = flags\n        .client_identifier\n        .as_deref()\n        .unwrap_or(HEADLESS_CLIENT_TYPE);\n    let env_urls = xai_grok_shell::leader::LeaderEnvUrls::from(&agent_config.grok_com_config);\n    let capabilities = ClientCapabilities {\n        // Leader agent is pre-running; capabilities carry the mode seeds into session meta\n        yolo_mode: flags.default_yolo_mode,\n        auto_mode: flags.default_auto_mode && !flags.default_yolo_mode,\n        default_model: agent_config.models.default.clone(),\n        client_version: Some(PAGER_CLIENT_VERSION.to_string()),\n        code_nav_enabled: false,\n        terminal: flags.terminal,\n        fs_read: flags.fs_read,\n        fs_write: flags.fs_write,","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/acp/mod.rs#L272-L308","documentation":"This error wraps a failure from AgentConfig::new_from_toml_cfg while building the ACP agent configuration from the raw TOML config during connect_via_leader. The library throws it because the leader process cannot proceed without a valid AgentConfig; the underlying parse/validation error is embedded in the message.","triggerScenarios":"Calling connect_via_leader when raw_config contains invalid TOML, missing required keys, or values that fail AgentConfig validation.","commonSituations":"Hand-edited or stale config files, schema drift after upgrading (renamed/removed config keys), environment-specific overrides producing invalid TOML, typos in config fields.","solutions":["Read the embedded {e} message to identify the exact TOML key or value that failed validation","Fix or regenerate the TOML config so it matches the AgentConfig schema","Validate the config with new_from_toml_cfg in a preflight check before connect_via_leader","If caused by an upgrade, migrate the config to the current schema"],"exampleFix":"// before\nlet agent_config = AgentConfig::new_from_toml_cfg(raw_config)\n    .map_err(|e| anyhow::anyhow!(\"Failed to create agent config: {e}\"))?;\n// after\n// preflight: parse and inspect errors with context\nlet agent_config = AgentConfig::new_from_toml_cfg(&raw_config)\n    .with_context(|| format!(\"invalid agent config: {}\", raw_config.path()))?;","handlingStrategy":"validation","validationCode":"fn validate_agent_config(raw: &str) -> Result<(), String> {\n    raw.parse::<toml::Value>().map_err(|e| format!(\"invalid TOML: {e}\"))?;\n    Ok(())\n}\n// call validate_agent_config(&raw_config) before connect_via_leader","typeGuard":null,"tryCatchPattern":"match connect_via_leader(cfg).await {\n    Err(e) if e.to_string().starts_with(\"Failed to create agent config\") => {\n        eprintln!(\"config error: {e:#}\"); // inspect chained source for the TOML detail\n    }\n    r => r?,\n}","preventionTips":["Validate TOML config against the AgentConfig schema at startup before connecting","Version-control the config and lint it in CI","After upgrades, diff config keys against the new schema","Keep per-environment overrides small and reviewed"],"tags":["config","toml","startup","agent-runtime"],"backgroundTag":"config-validation-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}