{"record":{"id":"6bd432dd119499dd","repo":"AprilNEA/OpenLogi","slug":"the-running-agent-disconnected-before-semantic-capture-could","errorCode":null,"errorMessage":"the running Agent disconnected before semantic capture could begin","messagePattern":"the running Agent disconnected before semantic capture could begin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/fixture/record_profile.rs","lineNumber":143,"sourceCode":"    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\nfn validate_metadata(args: &RecordProfileArgs) -> Result<()> {","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/fixture/record_profile.rs#L125-L161","documentation":"The inner-error sibling of [76]: the `declare_client` tarpc call itself returned `Err`, meaning the agent dropped the connection or rejected the client registration mid-call. Capture aborts before any snapshot is taken.","triggerScenarios":"The agent process exits or its connection breaks while handling `declare_client(ClientKind::Cli)` — agent crash, shutdown during capture, bincode/serialization failure of the request, or the agent refusing the client kind.","commonSituations":"Agent auto-restarting (crash loop) right as capture begins; killing the agent/ quitting the GUI during a long record session; version-skew causing deserialization failure of the declare request.","solutions":["Retry once the agent is stable — check `pgrep openlogi-agent` before and after","Restart the agent cleanly and ensure it isn't crash-looping (check its logs)","Align CLI and agent versions so the wire types deserialize correctly","Re-run capture when no agent shutdown/restart is in progress"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// confirm agent stability before capture\nlet before = agent_pid();\ntokio::time::sleep(Duration::from_secs(2)).await;\nif agent_pid() != before {\n    eprintln!(\"agent is restart-looping; stabilize it before capture\");\n}","typeGuard":null,"tryCatchPattern":"match capture_connected_profile(&conn, ...).await {\n    Err(e) if e.to_string().contains(\"disconnected before semantic capture\") => {\n        eprintln!(\"agent dropped the connection; check agent logs and retry\");\n    }\n    other => other,\n}","preventionTips":["Don't quit the GUI or kill the agent mid-capture","Keep CLI and agent versions aligned so declare requests deserialize","Watch agent logs for crash loops before long record sessions"],"tags":["cli","ipc","agent","disconnection"],"backgroundTag":"broken-pipe","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"}