Straiker Coding Agent Buffered

Third Party
Related Documentation
Made by
Compatible Protocols
grpc grpcs http https
Minimum Version
Kong Gateway - 3.14
Tags

Third Party: This plugin is developed, tested, and maintained by Straiker.

Use the Straiker Coding Agent Buffered plugin (straiker-coding-agent-buffered) to hold a Claude Code or other Anthropic Messages coding agent response until Straiker Defend scores it, so a denied tool_use never reaches the agent to run.

Coding agents call tools on the developer’s machine, outside the request/response cycle a gateway can inspect. Kong Gateway sees the wire, not the endpoint: interactive permission decisions, cwd, and permission_mode aren’t visible to this plugin. What Straiker Coding Agent Buffered does see is tool calls that fail and @-mention file reads that never become a tool call, both of which endpoint-based tooling often misses.

Straiker Coding Agent Buffered ships in the same LuaRock as the Straiker and Straiker coding agent streaming plugins, but only one Straiker plugin should be attached to a given Route. Never attach both coding-agent plugins to the same Route.

Note: This plugin is built for AI Gateway running on Kong Gateway. It has not been validated against AI Gateway 2.0.

Which Straiker plugin do I need?

The right plugin depends on the client sending the traffic:

 
flowchart TD
  start["LLM traffic through Kong Gateway"]
  start --> q1{"What is the client?"}
  q1 -->|"Chat app, assistant, RAG"| A["Straiker
webhook plugin"] q1 -->|"Claude Code or other Anthropic
Messages coding agent"| q2{"Must a tool call be
stopped before it runs?"} q2 -->|"No, interactive developers"| B["Straiker Coding Agent Streaming"] q2 -->|"Yes, CI or unattended agents"| C["Straiker Coding Agent Buffered"] click A "/plugins/straiker/" click B "/plugins/straiker-coding-agent-streaming/" click C "/plugins/straiker-coding-agent-buffered/"

Benefits of using the Straiker Coding Agent Buffered plugin:

  • Stops a tool call before it runs: The only Straiker plugin that can prevent the agent from ever seeing a denied tool_use.
  • Detects indirect prompt injection: Denies a poisoned tool_result on the next request too, in case a tool already ran.
  • Centralizes AI security enforcement: Applies Straiker Defend policy at the gateway instead of relying on endpoint agents alone.
  • Fits unattended automation: Suited to CI and unattended agents, where the added time to first token is an acceptable trade-off for pre-execution enforcement.

How it works

A tool runs locally, so the model’s decision to call a tool first appears in the response, and the tool’s result appears in the developer’s next request. Straiker Coding Agent Buffered holds that response until Straiker Defend scores it, so the agent never sees a denied tool_use:

 
sequenceDiagram
    autonumber
    participant Agent as Claude Code
    participant Plugin as Kong Gateway
buffered plugin participant Defend as Straiker Defend participant LLM as Anthropic Agent->>Plugin: POST /v1/messages Plugin->>Defend: request phase Defend-->>Plugin: verdict alt Request denied Plugin-->>Agent: HTTP 200 end_turn else Allowed Plugin->>LLM: Forward LLM-->>Plugin: Full response (held) Plugin->>Defend: response-sync Defend-->>Plugin: verdict alt tool_use denied Plugin-->>Agent: HTTP 200 end_turn
tool never reaches the agent else Allowed Plugin-->>Agent: Model response end end

Straiker Coding Agent Buffered runs in the access and response phases:

  • access: Sends the incoming request to Straiker Defend and denies it before it reaches the model if the verdict says to.
  • response: Holds the full model response, sends it to Straiker Defend for synchronous scoring, and only forwards it to the agent once the scan passes.

Holding the response adds latency to the first token, typically around 1.2 times the median time-to-first-token, because the agent doesn’t see anything until generation finishes and scoring completes. Use the streaming plugin instead for interactive developers who need immediate tool execution.

Caution: Don’t attach Straiker Coding Agent Buffered to a Route that also uses AI Proxy or AI Proxy Advanced. AI Proxy clears Kong Gateway’s response buffering (ctx.buffered_proxying) whenever the client streams, and coding agents always stream. Straiker Coding Agent Buffered then silently stops enforcing while still returning an HTTP 200 with x-straiker-verdict: allow. Inject the upstream credential with Request Transformer instead.

If you need AI Proxy in front of your coding-agent traffic, use the streaming plugin on that Route instead. It still inspects prompts and tool results, and isn’t affected by this restriction.

Plugin priority

Straiker Coding Agent Buffered runs at priority 1000, so it reads the client body before AI Proxy (priority 770) would translate it. For more information, see plugin priority.

Body buffer

Set this before attaching Straiker Coding Agent Buffered. At Kong Gateway’s 8 KB default client_body_buffer_size, a Claude Code request body (often 138 KB, over 1 MB with a large tool set) spills to an nginx temp file, the plugin can’t read the raw body, and traffic is proxied without inspection, returning HTTP 200 with x-straiker-verdict: fail-open-no-body.

nginx_http_client_body_buffer_size = 32m

Or set KONG_NGINX_HTTP_CLIENT_BODY_BUFFER_SIZE=32m. Also raise nginx_http_client_max_body_size to 64m. This setting is node-level and needs a restart to take effect. If you can’t set it, for example on a fully Konnect-managed data plane, request-body inspection isn’t possible.

Path matching

Straiker Coding Agent Buffered only inspects paths that end in /v1/messages, not /v1/messages/count_tokens. If your Route rewrites that suffix away, there’s no x-straiker-verdict header at all.

Fail-closed risk

Unlike straiker, setting config.fail_open to false on Straiker Coding Agent Buffered also applies to the response phase. Because the model’s answer is only generated once, setting fail_open to false can return a 503 for a request whose response was already produced by the model, if Straiker Defend is unreachable when the response is scored.

Install the Straiker Coding Agent Buffered plugin

LuaRock name: kong-plugin-straiker (current version 0.11.0-1). This single rock provides all three Straiker plugins: straiker, straiker-coding-agent-streaming, and straiker-coding-agent-buffered.

Prerequisites

Before installing the plugin, you need:

  • Kong Gateway 3.14 or later.
  • A Straiker account and Straiker Defend API key. Contact your Straiker team for enterprise API keys and sandbox access.
  • Network egress from Kong Gateway data planes to Straiker Defend.
  • nginx_http_client_body_buffer_size raised, as described in Body buffer.
  • Optional: Kong authentication plugins configured to map callers to Consumers.

Konnect Serverless and Dedicated Cloud Gateways aren’t supported. Custom plugins are rejected on those topologies. Use self-managed Kong Gateway or Konnect hybrid mode instead.

Installation steps

Enable the plugin

Straiker Coding Agent Buffered proxies Anthropic Messages traffic directly, for example to https://api.anthropic.com, rather than sitting behind AI Proxy.

See the Enable Straiker coding agent buffered example.

Point Claude Code at your Kong Gateway Route:

export ANTHROPIC_BASE_URL=https://kong.example.com/claude-code
export ANTHROPIC_API_KEY=placeholder

Then start Claude Code:

claude

Claude Code appends /v1/messages to ANTHROPIC_BASE_URL itself, so don’t include it in the URL. If Kong Gateway injects the upstream credential, for example with Request Transformer, ANTHROPIC_API_KEY can be a placeholder value.

Note: A policy block is an HTTP 200 response with the Anthropic stop_reason set to end_turn, not an HTTP error. Claude Code treats a 403 as an auth failure and retries a 5xx, so alert on the x-straiker-verdict header and the straiker object in your log serializer output, not on HTTP status.

Test the plugin

Send a minimal request with a tool defined:

curl -i -X POST https://kong.example.com/claude-code/v1/messages \
  -H 'content-type: application/json' \
  -H 'x-api-key: placeholder' \
  -H 'anthropic-version: 2023-06-01' \
  -H 'x-claude-code-session-id: install-check-1' \
  -d '{"model":"claude-sonnet-4-5-20250929","max_tokens":32,"stream":true,
       "tools":[{"name":"Bash","description":"run","input_schema":{"type":"object"}}],
       "messages":[{"role":"user","content":[{"type":"text","text":"say OK"}]}]}'

You want an HTTP 200 response, an SSE stream, and x-straiker-verdict: allow. A fail-open-* value means traffic is flowing but inspection is degraded.

Troubleshooting

No x-straiker-verdict header on coding-agent traffic

Symptoms: Requests reach the upstream model, but there’s no x-straiker-verdict header in the response.

Possible solutions:

  • Confirm the request path ends in /v1/messages, not /v1/messages/count_tokens.
  • Confirm Straiker Coding Agent Buffered is attached to that Route.
  • A fail-open-no-body verdict means the request body spilled past the buffer. See Body buffer.
  • A fail-open-no-key verdict means a vault reference didn’t resolve. If you’re using the environment vault, also set KONG_NGINX_MAIN_ENV.

Enforcement silently stops on streamed traffic

Symptoms: Straiker Coding Agent Buffered is attached, but tool_use calls the agent shouldn’t be running still reach it, even though x-straiker-verdict says allow.

Possible solutions:

  • Confirm AI Proxy isn’t also attached to the Route. AI Proxy clears response buffering on streamed requests, which coding agents always send. See How it works.

Plugin not found

Symptoms: Kong Gateway returns plugin 'straiker-coding-agent-buffered' not enabled.

Possible solutions:

  • Confirm the plugin files are installed on every data plane node.
  • Confirm KONG_PLUGINS includes straiker-coding-agent-buffered and still includes bundled.
  • Restart or reload Kong Gateway after installation.
  • In Konnect hybrid mode, confirm the plugin schema was uploaded to the control plane.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!