Skip to content

fix(llm,mcp,core): add embed timeout and track JoinHandles in ShadowSentinel#4588

Merged
bug-ops merged 2 commits into
mainfrom
4566-4570-async-task-safety
May 28, 2026
Merged

fix(llm,mcp,core): add embed timeout and track JoinHandles in ShadowSentinel#4588
bug-ops merged 2 commits into
mainfrom
4566-4570-async-task-safety

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 28, 2026

Summary

Changed files

File Change
crates/zeph-llm/src/router/mod.rs embed timeout in spawn_asi_update
crates/zeph-mcp/src/embedding_guard.rs embed_timeout_ms field + timeout in check_async
crates/zeph-core/src/agent/shadow_sentinel.rs JoinSet, spawn_persist, drain_pending
crates/zeph-core/src/agent/mod.rs drain_pending().await in Agent::shutdown()

Test plan

Closes #4566
Closes #4570

@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate bug Something isn't working size/L Large PR (201-500 lines) labels May 28, 2026
bug-ops added 2 commits May 29, 2026 00:33
…entinel

Closes #4566 — RouterProvider::spawn_asi_update and EmbeddingAnomalyGuard::check_async
now wrap embed() calls with tokio::time::timeout(embed_timeout_ms). On Elapsed the task
returns early (same as embed error path); no ASI window update or anomaly event is emitted.
EmbeddingAnomalyGuard gains an embed_timeout_ms field (default 5000 ms) with a
with_embed_timeout() builder.

Closes #4570 — ShadowSentinel::check_tool_call and record_tool_event no longer drop
JoinHandles. A bounded Mutex<JoinSet<()>> (cap MAX_PENDING_WRITES = 32) replaces the two
let _ = tokio::spawn(...) sites. spawn_persist() reaps completed handles with try_join_next
(non-blocking) before spawning; if still at capacity the new task is skipped with a debug
log. drain_pending() (blocking) is called in Agent::shutdown() to flush remaining writes.
@bug-ops bug-ops enabled auto-merge (squash) May 28, 2026 22:33
@bug-ops bug-ops force-pushed the 4566-4570-async-task-safety branch from 6cf44a3 to 52bbfbb Compare May 28, 2026 22:33
@bug-ops bug-ops merged commit 20b6b63 into main May 28, 2026
32 checks passed
@bug-ops bug-ops deleted the 4566-4570-async-task-safety branch May 28, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

1 participant