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.

Attaches to:

Route
Backend

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

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

Buffer settings

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

FieldDescriptionDefault
policies.buffer.request.maxBytesMaximum number of request body bytes to buffer.Uses the global proxy buffer setting, which defaults to 2Mi.
policies.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.

Buffer request and response bodies

Use a policies block to configure body buffering at the listener, route, or backend level. The same buffer section works anywhere policies is supported.

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
binds:
- port: 3000
  listeners:
  - routes:
    - backends:
      - host: localhost:8080
        policies:
          buffer:
            request:
              maxBytes: 64Ki
            response:
              maxBytes: 256Ki
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/.