Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/zeph-core/src/agent/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,12 @@ impl<C: Channel> Agent<C> {
)
.await;

let indices: Vec<usize> = if scored.len() >= 2
let indices: Vec<usize> = if scored.is_empty() {
// Embed or Qdrant failure: fall back to all skills so the agent
// remains functional rather than running with an empty skill set.
tracing::warn!("skill matcher returned no results, falling back to all skills");
(0..all_meta.len()).collect()
} else if scored.len() >= 2
&& (scored[0].score - scored[1].score) < self.skill_state.disambiguation_threshold
{
match self.disambiguate_skills(query, &all_meta, &scored).await {
Expand Down
9 changes: 9 additions & 0 deletions crates/zeph-core/src/bootstrap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ impl AppBuilder {
tracing::info!(context_window = ctx, "detected Ollama model context window");
}

if let AnyProvider::Orchestrator(ref mut orch) = provider {
orch.auto_detect_context_window().await;
}
if let Some(ctx) = provider.context_window()
&& !matches!(provider, AnyProvider::Ollama(_))
{
tracing::info!(context_window = ctx, "detected orchestrator context window");
}

Ok((provider, status_rx))
}

Expand Down
10 changes: 10 additions & 0 deletions crates/zeph-llm/src/orchestrator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ impl ModelOrchestrator {
self.status_tx = Some(tx);
}

/// Detect and apply the context window size from the default sub-provider.
///
/// Currently supported for Ollama sub-providers via `show` API.
/// Other sub-providers are skipped silently.
pub async fn auto_detect_context_window(&mut self) {
if let Some(provider) = self.providers.get_mut(&self.default_provider) {
provider.auto_detect_context_window().await;
}
}

/// Aggregate model lists from all sub-providers, deduplicating by id.
///
/// Individual sub-provider errors are logged as warnings and skipped.
Expand Down
10 changes: 10 additions & 0 deletions crates/zeph-llm/src/orchestrator/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ pub enum SubProvider {
}

impl SubProvider {
/// Detect and set the context window size from the underlying provider where supported.
pub async fn auto_detect_context_window(&mut self) {
if let Self::Ollama(p) = self
&& let Ok(info) = p.fetch_model_info().await
&& let Some(ctx) = info.context_length
{
p.set_context_window(ctx);
}
}

pub fn set_status_tx(&mut self, tx: StatusTx) {
match self {
Self::Claude(p) => {
Expand Down
Loading