refactor: Enforce agentic API design across mcp-memory handlers
- Replaced unconstrained JSON serialization (serde_json) with dense YAML (serde_yaml) to prevent context window bloat (ADR-0122). - Replaced 404/empty array dead ends with token-efficient LLM fallback hints in router and meta/graph handlers. - Ensured graceful error fallbacks instead of hard crashes.
This commit is contained in:
1 parent
f56750f596
commit
2024d9521b
3 files changed
+18
-18
No files matched your search
@@ -126,7 +126,7 @@ impl McpTool for SearchErrorFixesHandler {
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&suggestions)?)
|
||||
if suggestions.is_empty() { Ok::<String, crate::error::AppError>("No matching error fixes found. Try relaxing the search query.".to_string()) } else { Ok::<String, crate::error::AppError>(serde_yaml::to_string(&suggestions)?) }
|
||||
})?;
|
||||
return Ok(data);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl McpTool for SearchErrorFixesHandler {
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?)
|
||||
if filtered.is_empty() { Ok::<String, crate::error::AppError>(format!("No matching results found.")) } else { Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?) }
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
@@ -339,7 +339,7 @@ impl McpTool for QueryRecentChangesHandler {
|
||||
c
|
||||
})
|
||||
.collect();
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?)
|
||||
if filtered.is_empty() { Ok::<String, crate::error::AppError>(format!("No matching results found.")) } else { Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?) }
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
@@ -552,7 +552,7 @@ impl McpTool for DecisionsHandler {
|
||||
.collect();
|
||||
|
||||
if include_body {
|
||||
Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?)
|
||||
if filtered.is_empty() { Ok::<String, crate::error::AppError>(format!("No matching results found.")) } else { Ok::<String, crate::error::AppError>(serde_yaml::to_string(&filtered)?) }
|
||||
} else {
|
||||
let compact: Vec<_> = filtered
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user