Expand description
Response formatting utilities for agent tools
This module provides consistent response formatting for all agent tools.
It works alongside the error utilities in error.rs to provide a complete
response infrastructure.
§Pattern
Tools should use these utilities for successful responses:
- Use
format_successfor simple successful operations - Use
format_success_with_metadatawhen including truncation/compression info - Use
format_file_contentfor file read operations - Use
format_listfor directory listings and other lists
§Example
ⓘ
use crate::agent::tools::response::{format_success, format_file_content, ResponseMetadata};
// Simple success response
let response = format_success("read_file", json!({"content": "file contents"}));
// File content response with metadata
let response = format_file_content(
"src/main.rs",
&file_content,
100, // total lines
100, // returned lines
false, // not truncated
);Structs§
- Response
Metadata - Metadata about a tool response
- Tool
Response - Standard tool response structure
Functions§
- format_
cancelled - Format a cancelled operation response
- format_
file_ content - Format file content response
- format_
file_ content_ range - Format file content response for line range
- format_
list - Format a list/directory response
- format_
list_ with_ metadata - Format a list response with custom metadata
- format_
success - Format a simple success response
- format_
success_ with_ metadata - Format a success response with metadata
- format_
write_ success - Format a write operation response