subspace-agent-tools 0.7.0

Subspace Framework: the agent tool interface boards advertise, with batched writes. Internal crate; apps depend on `subspace-framework`.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use serde_json::json;

use super::{MAX_RESPONSE_BYTES, bounded_response};

#[test]
fn budget_includes_envelope_and_sources_not_only_hits() {
    let response = bounded_response(json!({"hits":["x".repeat(MAX_RESPONSE_BYTES - 20)],"sources":["source"],"untrusted":true,"truncated":false})).unwrap();
    assert!(serde_json::to_vec(&response).unwrap().len() <= MAX_RESPONSE_BYTES);
    assert_eq!(response["truncated"], true);
    assert!(response["hits"].as_array().unwrap().is_empty());
    let sources = bounded_response(
        json!({"hits":[],"sources":["x".repeat(MAX_RESPONSE_BYTES)],"truncated":false}),
    )
    .unwrap();
    assert!(sources["sources"].as_array().unwrap().is_empty());
    assert!(bounded_response(json!({"body":"x".repeat(MAX_RESPONSE_BYTES)})).is_err());
}