Skip to main content

Response

Struct Response 

Source
pub struct Response {
    pub id: String,
    pub success: bool,
    pub data: Value,
}
Expand description

Outbound response envelope.

data is flattened into the top-level JSON object, so a response like Response { id: "1", success: true, data: json!({"command": "pong"}) } serializes to {"id":"1","success":true,"command":"pong"}.

§Honest reporting convention (tri-state)

Tools that search, check, or otherwise produce results MUST follow this convention so agents can distinguish “did the work, found nothing” from “couldn’t do the work” from “partially did the work”:

  1. success: false — the requested work could not be performed. Includes a code (e.g., "path_not_found", "no_lsp_server", "project_too_large") and a human-readable message. The agent should treat this as an error and read the message.

  2. success: true + completion signaling — the work was performed. Tools must report whether the result is complete OR which subset was actually performed. Conventional fields:

    • complete: true — full result, agent can trust absence of items
    • complete: false + pending_files: [...] / unchecked_files: [...] / scope_warnings: [...] — partial result, with named gaps
    • removed: true|false (for mutations) — did the file actually change
    • skipped_files: [{file, reason}] — files we couldn’t process inside the requested scope
    • no_files_matched_scope: bool — the scope (path/glob) found zero candidates (distinct from “candidates found, no matches”)
  3. Side-effect skip codes — when the main work succeeded but a non-essential side step was skipped (e.g., post-write formatting), use a <step>_skipped_reason field. Approved values:

    • format_skipped_reason: "unsupported_language" | "no_formatter_configured" | "formatter_not_installed" | "timeout" | "error"
    • validate_skipped_reason: "unsupported_language" | "no_checker_configured" | "checker_not_installed" | "timeout" | "error"

Anti-patterns to avoid:

  • Returning success: true with empty results when the scope didn’t resolve to any files — agent reads as “all clear” but really nothing was checked. Use no_files_matched_scope: true or success: false, code: "path_not_found".
  • Reusing format_skipped_reason: "not_found" for two different causes (“no formatter configured” vs “configured formatter binary missing”). The agent can’t act on the ambiguous code.

See ARCHITECTURE.md “Honest reporting convention” for the full rationale.

Fields§

§id: String§success: bool§data: Value

Implementations§

Source§

impl Response

Source

pub fn success(id: impl Into<String>, data: Value) -> Self

Build a success response with arbitrary data merged at the top level.

Source

pub fn error( id: impl Into<String>, code: &str, message: impl Into<String>, ) -> Self

Build an error response with code and message fields.

Source

pub fn error_with_data( id: impl Into<String>, code: &str, message: impl Into<String>, extra: Value, ) -> Self

Build an error response with code, message, and additional structured data.

The extra fields are merged into the top-level response alongside code and message.

Trait Implementations§

Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Response

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more