Module response

Module response 

Source
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:

  1. Use format_success for simple successful operations
  2. Use format_success_with_metadata when including truncation/compression info
  3. Use format_file_content for file read operations
  4. Use format_list for 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§

ResponseMetadata
Metadata about a tool response
ToolResponse
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