MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / dispatch_model_for_agent

Function dispatch_model_for_agent

src/sessions/cursor.rs:700–723  ·  view source on GitHub ↗
(path: &Path, agent_id: &str)

Source from the content-addressed store, hash-verified

698}
699
700fn dispatch_model_for_agent(path: &Path, agent_id: &str) -> Option<String> {
701 let contents = std::fs::read_to_string(path).ok()?;
702 for line in contents.lines() {
703 let Ok(record) = serde_json::from_str::<Value>(line) else {
704 continue;
705 };
706 let message = record.get("message").unwrap_or(&record);
707 let content = message.get("content").unwrap_or(message);
708 let Some(items) = content.as_array() else {
709 continue;
710 };
711 for item in items {
712 let Some(name) = item.get("name").and_then(Value::as_str) else {
713 continue;
714 };
715 if is_subagent_dispatch_tool(name) && dispatch_targets_agent(item, agent_id) {
716 if let Some(model) = cursor_dispatch_model(item) {
717 return Some(model);
718 }
719 }
720 }
721 }
722 None
723}
724
725fn dispatch_targets_agent(item: &Value, agent_id: &str) -> bool {
726 let input = item.get("input").unwrap_or(item);

Callers 1

Calls 3

dispatch_targets_agentFunction · 0.85
cursor_dispatch_modelFunction · 0.85

Tested by

no test coverage detected