Skip to content
🎯 New workshop: Govern AI Costs in Real Time — Hands-On with agentgateway agentgateway has joined the Agentic AI FoundationLearn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Page as Markdown

Body buffering

Buffer request and response bodies before forwarding them.

Use the traffic.buffer policy to buffer request or response bodies in the gateway proxy before the bodies are forwarded. By default, agentgateway streams bodies. When you configure traffic.buffer, the proxy accumulates the configured body direction in memory until the body is complete, and then forwards it.

This policy is different from Buffering, which configures the gateway-level frontend.http.maxBufferSize limit used by policies that need buffering.

Buffer settings

You can configure request buffering, response buffering, or both.

FieldDescriptionDefault
traffic.buffer.request.maxBytesMaximum number of request body bytes to buffer.Uses the global proxy buffer setting, which defaults to 2Mi.
traffic.buffer.response.maxBytesMaximum number of response body bytes to buffer.Uses the global proxy buffer setting, which defaults to 2Mi.

The maxBytes value accepts byte-size strings such as 32Ki, 2Mi, or 10M. Large buffered bodies can increase proxy memory usage, so set strict limits for routes that receive untrusted or large payloads. When a body exceeds the applicable buffer limit, agentgateway rejects the body if possible. If response headers were already sent before the limit is exceeded, the proxy closes the connection.

Before you begin

  1. Set up an agentgateway proxy.
  2. Install the httpbin sample app.

Buffer request and response bodies

Use a AgentgatewayPolicy to configure body buffering for a Gateway, HTTPRoute, or route rule.

  1. Create a policy that buffers request bodies up to 64Ki and response bodies up to 256Ki.

    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayPolicy
    metadata:
      name: body-buffer
      namespace: agentgateway-system
    spec:
      targetRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
      traffic:
        buffer:
          request:
            maxBytes: 64Ki
          response:
            maxBytes: 256Ki
    EOF
  2. Review the policy.

    kubectl get AgentgatewayPolicy body-buffer -n agentgateway-system -o yaml

Cleanup

You can remove the resources that you created in this guide.
kubectl delete AgentgatewayPolicy body-buffer -n agentgateway-system
Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.