Tool reply meta (#6074)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -221,12 +221,12 @@ pub fn tool_response_to_markdown(resp: &ToolResponse, export_all_content: bool)
|
||||
md.push_str("#### Tool Response:\n");
|
||||
|
||||
match &resp.tool_result {
|
||||
Ok(contents) => {
|
||||
if contents.is_empty() {
|
||||
Ok(result) => {
|
||||
if result.content.is_empty() {
|
||||
md.push_str("*No textual output from tool.*\n");
|
||||
}
|
||||
|
||||
for content in contents {
|
||||
for content in &result.content {
|
||||
if !export_all_content {
|
||||
if let Some(audience) = content.audience() {
|
||||
if !audience.contains(&Role::Assistant) {
|
||||
@@ -581,7 +581,12 @@ mod tests {
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "test-id".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -601,7 +606,12 @@ mod tests {
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "test-id".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -707,7 +717,12 @@ if __name__ == "__main__":
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "shell-cat".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&tool_request, true);
|
||||
@@ -748,7 +763,12 @@ if __name__ == "__main__":
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "git-status".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&tool_request, true);
|
||||
@@ -797,7 +817,12 @@ warning: unused variable `x`
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "cargo-build".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let response_result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -844,7 +869,12 @@ warning: unused variable `x`
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "curl-api".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let response_result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -880,7 +910,12 @@ warning: unused variable `x`
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "editor-write".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&tool_request, true);
|
||||
@@ -937,7 +972,12 @@ def process_data(data: List[Dict]) -> List[Dict]:
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "editor-view".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let response_result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -974,7 +1014,12 @@ Command failed with exit code 2"#;
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "shell-error".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let response_result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -1014,7 +1059,12 @@ Command failed with exit code 2"#;
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "script-exec".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&tool_request, true);
|
||||
@@ -1061,7 +1111,12 @@ drwx------ 3 user staff 96 Dec 6 16:20 com.apple.launchd.abc
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "multi-cmd".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&_tool_request, true);
|
||||
@@ -1104,7 +1159,12 @@ src/middleware.rs:12:async fn auth_middleware(req: Request, next: Next) -> Resul
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "grep-search".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&tool_request, true);
|
||||
@@ -1144,7 +1204,12 @@ src/middleware.rs:12:async fn auth_middleware(req: Request, next: Next) -> Resul
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "json-test".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let response_result = tool_response_to_markdown(&tool_response, true);
|
||||
@@ -1185,7 +1250,12 @@ found 0 vulnerabilities"#;
|
||||
};
|
||||
let tool_response = ToolResponse {
|
||||
id: "npm-install".to_string(),
|
||||
tool_result: Ok(vec![Content::text(text_content.raw.text)]),
|
||||
tool_result: Ok(rmcp::model::CallToolResult {
|
||||
content: vec![Content::text(text_content.raw.text)],
|
||||
structured_content: None,
|
||||
is_error: Some(false),
|
||||
meta: None,
|
||||
}),
|
||||
};
|
||||
|
||||
let request_result = tool_request_to_markdown(&tool_request, true);
|
||||
|
||||
@@ -285,8 +285,8 @@ fn render_tool_response(resp: &ToolResponse, theme: Theme, debug: bool) {
|
||||
let config = Config::global();
|
||||
|
||||
match &resp.tool_result {
|
||||
Ok(contents) => {
|
||||
for content in contents {
|
||||
Ok(result) => {
|
||||
for content in &result.content {
|
||||
if let Some(audience) = content.audience() {
|
||||
if !audience.contains(&rmcp::model::Role::User) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user