feat: only run identity agent if file has seed identities
Identity agent now checks Qdrant _seeds collection for the file's seed identity photos before running. If no seeds exist, the agent is skipped to avoid unnecessary processing. Flow: 1. Job completes (Face + ASRX done) 2. Check Qdrant _seeds for file_uuid 3. If seeds exist → run identity agent 4. If no seeds → skip identity agent
This commit is contained in:
@@ -1786,23 +1786,49 @@ impl JobWorker {
|
||||
});
|
||||
}
|
||||
|
||||
// 🚀 P3 Trigger: Identity Agent (Face + ASRX)
|
||||
// 🚀 P3 Trigger: Identity Agent (Face + ASRX + has seed identities)
|
||||
if has_face && has_asrx {
|
||||
info!("📝 Prerequisites met for Identity Agent. Starting analysis...");
|
||||
let db_clone = self.db.clone();
|
||||
let redis_clone = self.redis.clone();
|
||||
let uuid_clone = uuid.to_string();
|
||||
tokio::spawn(async move {
|
||||
match run_identity_agent(&db_clone, &uuid_clone, Some(redis_clone.clone())).await {
|
||||
Ok(()) => {
|
||||
info!("✅ Identity Agent completed for {}", uuid_clone);
|
||||
let mut pp = PipelineProgress::new(&uuid_clone);
|
||||
pp.update_stage("identity_agent", 1.0, "completed", None);
|
||||
publish_pipeline_progress(redis_clone.as_ref(), &uuid_clone, &pp).await;
|
||||
// Check if file has seed identity photos in Qdrant _seeds collection
|
||||
let has_seeds = {
|
||||
use crate::core::db::qdrant_db::QdrantDb;
|
||||
let qdrant = QdrantDb::new();
|
||||
let schema = std::env::var("DATABASE_SCHEMA").unwrap_or_else(|_| "dev".to_string());
|
||||
let seeds_collection = if schema == "public" {
|
||||
"momentry_public_seeds"
|
||||
} else {
|
||||
&format!("momentry_{}_seeds", schema)
|
||||
};
|
||||
let filter = serde_json::json!({
|
||||
"must": [{"key": "file_uuid", "match": {"value": uuid}}]
|
||||
});
|
||||
match qdrant.scroll_all_points("_seeds", filter, 1).await {
|
||||
Ok(points) => !points.is_empty(),
|
||||
Err(e) => {
|
||||
warn!("Failed to check _seeds for {}: {}", uuid, e);
|
||||
false
|
||||
}
|
||||
Err(e) => error!("❌ Identity Agent failed for {}: {}", uuid_clone, e),
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if has_seeds {
|
||||
info!("📝 Prerequisites met for Identity Agent (has seeds). Starting analysis...");
|
||||
let db_clone = self.db.clone();
|
||||
let redis_clone = self.redis.clone();
|
||||
let uuid_clone = uuid.to_string();
|
||||
tokio::spawn(async move {
|
||||
match run_identity_agent(&db_clone, &uuid_clone, Some(redis_clone.clone())).await {
|
||||
Ok(()) => {
|
||||
info!("✅ Identity Agent completed for {}", uuid_clone);
|
||||
let mut pp = PipelineProgress::new(&uuid_clone);
|
||||
pp.update_stage("identity_agent", 1.0, "completed", None);
|
||||
publish_pipeline_progress(redis_clone.as_ref(), &uuid_clone, &pp).await;
|
||||
}
|
||||
Err(e) => error!("❌ Identity Agent failed for {}: {}", uuid_clone, e),
|
||||
}
|
||||
});
|
||||
} else {
|
||||
info!("📝 Skipping Identity Agent for {} (no seed identities)", uuid);
|
||||
}
|
||||
}
|
||||
|
||||
// 🚀 P4 Trigger: TKG Build (Face + ASRX) → then Rule2 ingestion
|
||||
|
||||
Reference in New Issue
Block a user