Fix: resolve async communication deadlock and daemon stability issuesnication core#91
Merged
bfly123 merged 3 commits intobfly123:mainfrom Feb 23, 2026
Merged
Conversation
OpenCode 0.29.0+ migrated from JSON file storage to SQLite database. This commit adds full SQLite support with backward compatibility. Changes: - Add SQLite database reading for sessions, messages, and parts - Implement session discovery from database with improved matching - Query LIMIT increased from 50 to 200 sessions - Find most recent matching session instead of first match - Fixes issue where other projects' sessions pushed target out of results - Enable reasoning fallback for text extraction - Handles OpenCode responses in "reasoning" type parts - Maintain backward compatibility with JSON file storage - Add comprehensive test coverage for SQLite operations Fixes communication detection issue where OpenCode completes tasks but CCB doesn't receive replies. Co-authored-by: Codex <codex@ccb> Co-authored-by: Gemini <gemini@ccb>
This commit fixes three critical issues that caused async requests to gemini and opencode to get stuck in "processing" state: 1. OpenCode session ID pinning: Modified _get_latest_session_from_db() to detect and switch to newer sessions even when session_id_filter is set. This fixes the "second call always fails" issue. 2. Incomplete state updates: Enhanced _read_since() to update all state fields (assistant_count, last_assistant_id, etc.) when session_updated changes, preventing stale state comparisons. 3. Strict completion detection: Added degraded completion detection in both OpenCode and Gemini adapters. When timeout occurs but reply contains any CCB_DONE marker, accept as completed even if req_id doesn't match (with warning log). These minimal changes resolve: - OpenCode second call failure (100% reproducible) - Gemini intermittent failures - Permanent "processing" state when req_id mismatches Files changed: - lib/opencode_comm.py: Session detection and state sync fixes - lib/askd/adapters/opencode.py: Degraded completion detection - lib/askd/adapters/gemini.py: Degraded completion detection Test: ./test_minimal_fix.sh Documentation: ISSUE_ANALYSIS.md, PR_MINIMAL_FIX.md Co-analyzed-by: Gemini, OpenCode, Codex
This commit fixes three critical bugs that cause daemon crashes and communication failures: 1. Unified askd not used in background mode: Removed foreground_mode requirement from _use_unified_daemon() check. This ensures askd is used in all modes (foreground and background), fixing the core issue where CCB_CALLER triggers background mode but askd was not used. 2. _parent_monitor thread crash: Fixed indentation bug where threading.Thread(target=_parent_monitor).start() was outside the if block where _parent_monitor was defined. This caused NameError when parent_pid was not set, leading to daemon crashes and zombie processes. 3. Gemini hash overflow: Added None check for msg_id before comparison in GeminiLogReader. When msg_id is None, skip comparison to prevent hash overflow issues that cause message detection failures. These fixes resolve: - Requests not using askd in background mode (root cause) - Daemon becoming zombie process (defunct) - Gemini intermittent message detection failures - System-wide communication breakdowns Tested: 18 concurrent/sequential calls across 3 LLMs, all successful. Files changed: - bin/ask: Enable unified askd in all modes - lib/askd_server.py: Fix _parent_monitor thread start indentation - lib/gemini_comm.py: Add None check for msg_id comparison Related to commit aad38e3 (async communication fixes)
bfly123
added a commit
that referenced
this pull request
Feb 24, 2026
Remove temporary analysis docs (ISSUE_ANALYSIS.md, PR_MINIMAL_FIX.md) that should not live in the repo, move test_minimal_fix.sh to test/, and update _REQ_ID_RE in opencode_comm.py to match both old hex and new timestamp-based req_id formats. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bfly123
added a commit
that referenced
this pull request
Feb 26, 2026
Move notify_mode check before unified daemon path in ask command. PR #91 moved unified daemon check to catch all modes, but this caused --notify (fire-and-forget) to go through full request-response cycle, triggering notify_completion -> ask -> daemon -> notify loop. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes critical bugs that cause async requests to get stuck in
"processing" state and daemon crashes. These issues affect OpenCode
and Gemini providers, causing communication failures and system-wide
breakdowns.
Issues Fixed
1. OpenCode SQLite Support (commit 8afd215)
session discovery
compatibility
tasks but CCB doesn't receive replies
2. Async Communication Deadlock (commit 30efee8)
_read_since()req_id mismatch)
and Gemini
3. Daemon Stability (commit 8c24969)
_parent_monitorthread crashes due to indentation bug_parent_monitorthread start indentationmodes
Testing
Codex)
test_minimal_fix.shFiles Changed
lib/opencode_comm.py: SQLite support + session detection fixeslib/askd/adapters/opencode.py: Degraded completion detectionlib/askd/adapters/gemini.py: Degraded completion detectionbin/ask: Enable unified askd in all modeslib/askd_server.py: Fix _parent_monitor thread crashlib/gemini_comm.py: Add None check for msg_idBackward Compatibility
All changes maintain backward compatibility:
Co-authored
Co-analyzed-by: Gemini, OpenCode, Codex (multi-model collaborative
debugging)