Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agent-harness): gzip responses (#7520)

Wolf Mermelstein32e20508477f
diff --git a/Cargo.lock b/Cargo.lock
index 81132cfc40..a3ba58d0ff 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -477,6 +477,7 @@ dependencies = [
"tokio-retry",
"tokio-util",
"tower 0.5.3",
+ "tower-http",
"tracing",
"url",
"utoipa",
diff --git a/services/agent_harness_service/Cargo.toml b/services/agent_harness_service/Cargo.toml
index 9d8ef89e47..f5ccc0b9f4 100644
--- a/services/agent_harness_service/Cargo.toml
+++ b/services/agent_harness_service/Cargo.toml
@@ -112,6 +112,7 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] }
tokio-retry = { workspace = true }
tokio-util = { workspace = true, features = ["rt"] }
tower = { workspace = true }
+tower-http = { workspace = true }
tracing = { workspace = true }
workspace-hack = { version = "0.1", path = "../../crates/workspace-hack" }
diff --git a/services/agent_harness_service/src/api.rs b/services/agent_harness_service/src/api.rs
index b066f23002..2cf7d00271 100644
--- a/services/agent_harness_service/src/api.rs
+++ b/services/agent_harness_service/src/api.rs
@@ -32,6 +32,7 @@ use axum::routing::get;
use entity_access::domain::ports::EntityAccessService;
use macro_authorization::MacroAuthorizationService;
use macro_tower_layers::MacroRequestIdAndTracingLayer;
+use tower_http::{CompressionLevel, compression::CompressionLayer};
use utoipa::OpenApi;
use utoipa_swagger_ui::SwaggerUi;
@@ -195,7 +196,16 @@ where
let inner = api_router(states)
.layer(MacroRequestIdAndTracingLayer::new(Duration::from_millis(200)).into_inner())
.merge(health_router(runtime_commands_ready))
- .layer(macro_cors::cors_layer());
+ .layer(macro_cors::cors_layer())
+ // A session log is megabytes of repetitive JSON; gzip cuts the transfer
+ // more than tenfold, and the fetch is what a session open waits on.
+ // Fastest: the default level spent ~1 s of CPU on a 13 MB log for a
+ // few percent more savings, which costs more than it saves on a LAN.
+ .layer(
+ CompressionLayer::new()
+ .gzip(true)
+ .quality(CompressionLevel::Fastest),
+ );
let app = mount_at_root_and_prefix(inner, GATEWAY_PATH_PREFIX)
.merge(SwaggerUi::new("/docs").url("/api-doc/openapi.json", swagger::ApiDoc::openapi()))
.merge(SwaggerUi::new("/agent-harness/docs").url(