fix(tui): wrap startup embed calls with tokio::time::timeout (#2879)#2880
Merged
fix(tui): wrap startup embed calls with tokio::time::timeout (#2879)#2880
Conversation
Five embed call sites on the agent startup path had no timeout, causing the TUI to hang indefinitely when an Ollama embedding provider was slow to respond (e.g. model still loading or queued requests). Sites fixed: - src/runner.rs: resolve_rl_embed_dim (new embedding_timeout_secs param) - src/daemon.rs: resolve_rl_embed_dim call site updated - crates/zeph-core/src/bootstrap/mcp.rs: create_mcp_registry embed_fn - crates/zeph-core/src/bootstrap/skills.rs: create_skill_matcher embed_fn - crates/zeph-core/src/agent/mcp.rs: sync_mcp_registry + rebuild_semantic_index - crates/zeph-core/src/agent/mod.rs: rebuild_skill_matcher embed_fn All sites now use config.timeouts.embedding_seconds (default 30 s). On timeout a warn! is logged and LlmError::Timeout returned; each caller already handles this gracefully so startup continues without abort. Adds two unit tests for resolve_rl_embed_dim covering the timeout-fallback and fast-provider paths. Extends MockProvider in zeph-llm with with_embedding() and with_embed_delay() builders to support these tests. Closes #2879
a48ebbd to
3462841
Compare
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
tokio::time::timeout(config.timeouts.embedding_seconds)to prevent TUI from hanging indefinitely when an Ollama embedding provider is slowwarn!logged,LlmError::Timeoutreturned — each caller degrades gracefully, startup continuesresolve_rl_embed_dim(timeout-fallback path and fast-provider path)MockProviderwithwith_embedding()andwith_embed_delay()buildersSites fixed
src/runner.rsresolve_rl_embed_dim(newembedding_timeout_secsparam)src/daemon.rscrates/zeph-core/src/bootstrap/mcp.rscreate_mcp_registryembed_fncrates/zeph-core/src/bootstrap/skills.rscreate_skill_matcherembed_fncrates/zeph-core/src/agent/mcp.rssync_mcp_registry+rebuild_semantic_indexcrates/zeph-core/src/agent/mod.rsrebuild_skill_matcherembed_fnReference pattern:
SkillMatcher::newincrates/zeph-skills/src/matcher.rsalready usedtokio::time::timeoutcorrectly; this PR applies the same pattern to all remaining startup sites.Test plan
cargo +nightly fmt --check— cleancargo clippy --workspace --features full -- -D warnings— cleancargo nextest run --workspace --features full --lib --bins— 8149 passed, 25 skippedresolve_rl_embed_dim_timeout_uses_fallback— mock delay 1100ms, timeout 1s → returns FALLBACK 1536resolve_rl_embed_dim_fast_provider_returns_dim— fast mock returns vec[768] → returns 768Closes #2879