Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(mcp): strip markdown wrappers before trailing punctuation in string args

Steven Enamakelbb7fa5cd7c2d
diff --git a/crates/openhuman-core/src/mcp/registry/tools_tests.rs b/crates/openhuman-core/src/mcp/registry/tools_tests.rs
index ca20f96a3e..2158a4037b 100644
--- a/crates/openhuman-core/src/mcp/registry/tools_tests.rs
+++ b/crates/openhuman-core/src/mcp/registry/tools_tests.rs
@@ -229,7 +229,10 @@ async fn tool_call_refuses_arguments_that_are_not_an_object() {
let message = err.to_string();
assert!(message.contains("mcp_registry_tool_call"), "{message}");
assert!(message.contains("invalid tool arguments"), "{message}");
- assert!(!message.contains('5'), "module failure must not echo arguments: {message}");
+ assert!(
+ !message.contains('5'),
+ "module failure must not echo arguments: {message}"
+ );
}
/// A workspace of its own, so the host this opens is not shared.
diff --git a/crates/openhuman-core/src/tools/impl/network/mcp.rs b/crates/openhuman-core/src/tools/impl/network/mcp.rs
index fa5ba14623..ccb2a6390e 100644
--- a/crates/openhuman-core/src/tools/impl/network/mcp.rs
+++ b/crates/openhuman-core/src/tools/impl/network/mcp.rs
@@ -525,13 +525,12 @@ fn required_string_arg(args: &Value, key: &str) -> anyhow::Result<String> {
.map(str::trim)
.filter(|value| !value.is_empty())
.ok_or_else(missing)?;
- let unpunctuated = value.trim_end_matches(['.', ',', ';', ':', '!']);
- let fenced = if unpunctuated.ends_with(['`', '*']) {
- unpunctuated
- } else {
- value
- };
- let cleaned = fenced.trim_matches(['`', '*']);
+ // Strip model-introduced markdown wrappers before trailing sentence
+ // punctuation so `**search!**` is read as `search`, not `search!`.
+ let cleaned = value
+ .trim_matches(['`', '*'])
+ .trim_end_matches(['.', ',', ';', ':', '!'])
+ .trim_matches(['`', '*']);
if cleaned.is_empty() {
return Err(missing());
}