{"record":{"id":"f48ace2a090e64be","repo":"AprilNEA/OpenLogi","slug":"the-running-agent-timed-out-before-semantic-capture-could","errorCode":null,"errorMessage":"the running Agent timed out before semantic capture could begin","messagePattern":"the running Agent timed out before semantic capture could begin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/fixture/record_profile.rs","lineNumber":142,"sourceCode":"    id: String,\n    name: String,\n) -> Result<CapturedProfile> {\n    if connection.version != PROTOCOL_VERSION {\n        bail!(\n            \"the running Agent speaks protocol v{}, but this CLI requires v{PROTOCOL_VERSION}; \\\n             update or restart OpenLogi so both processes match (no profile was written)\",\n            connection.version\n        );\n    }\n\n    tokio::time::timeout(\n        DECLARE_TIMEOUT,\n        connection\n            .client\n            .declare_client(context::current(), ClientKind::Cli),\n    )\n    .await\n    .map_err(|_| anyhow!(\"the running Agent timed out before semantic capture could begin\"))?\n    .map_err(|_| anyhow!(\"the running Agent disconnected before semantic capture could begin\"))?;\n\n    let snapshot = tokio::time::timeout(\n        SNAPSHOT_TIMEOUT,\n        connection.client.snapshot(context::current()),\n    )\n    .await\n    .map_err(|_| anyhow!(\"the running Agent timed out while providing its device snapshot\"))?\n    .map_err(|_| anyhow!(\"the running Agent disconnected while providing its device snapshot\"))?;\n\n    let captured = capture_profile(&connection.client, snapshot, selector, id, name).await?;\n    captured\n        .profile\n        .validate()\n        .context(\"captured semantic profile failed version-1 validation; no profile was written\")?;\n    Ok(captured)\n}\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/fixture/record_profile.rs#L124-L160","documentation":"After connecting, `capture_connected_profile` asks the agent to register the CLI as a client via `declare_client`, wrapped in a `DECLARE_TIMEOUT`. If the future does not resolve before the timeout (the outer `Err` of `tokio::time::timeout`), this error fires; the inner `Err` (agent-side rejection/disconnect) produces the sibling 'disconnected' error instead.","triggerScenarios":"The agent's tarpc response to `declare_client` never arrives within `DECLARE_TIMEOUT` — agent event loop blocked (busy doing HID I/O or a hook stall), hung tarpc channel, or a very slow/loaded machine.","commonSituations":"Agent wedged by a blocking HID write, system sleep/resume leaving the IPC channel half-dead, heavy CPU load at capture start, or an agent that accepted the connection but stopped servicing requests.","solutions":["Retry the command — transient stalls often clear","Restart the agent to free its blocked event loop","Increase headroom by closing other CLI clients doing hardware diagnostics against the same agent","If reproducible, investigate the agent's event loop for blocking calls in HID write paths"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// only attempt capture when the agent is responsive\nmatch tokio::time::timeout(Duration::from_secs(2), connect_probe()).await {\n    Ok(_) => println!(\"agent responsive\"),\n    Err(_) => eprintln!(\"agent unresponsive; restart before capture\"),\n}","typeGuard":null,"tryCatchPattern":"for attempt in 0..2 {\n    match capture_connected_profile(&conn, ...).await {\n        Err(e) if e.to_string().contains(\"timed out before semantic capture\") && attempt == 0 => continue,\n        other => break other,\n    }\n}","preventionTips":["Avoid running heavy hardware diagnostics against the agent during capture","Check for system sleep/resume issues in long sessions","Investigate blocking HID writes in the agent if timeouts reproduce"],"tags":["cli","ipc","agent","timeout"],"backgroundTag":"request-timeout","analyzedSha":"e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8","analyzedAt":"2026-09-13T03:07:16.451Z","contentChangedAt":"2026-09-13T03:07:16.451Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}