Skip to content

Instantly share code, notes, and snippets.

@christian-posta
Last active March 5, 2026 23:24
Show Gist options
  • Select an option

  • Save christian-posta/a88bd2f59c07f6ae62556fff6ae7c1a6 to your computer and use it in GitHub Desktop.

Select an option

Save christian-posta/a88bd2f59c07f6ae62556fff6ae7c1a6 to your computer and use it in GitHub Desktop.

Agentgateway Objects context

CEL name Rust field When / where it’s set
request request HTTP request (method, uri, host, scheme, path, version, headers, body, startTime, endTime). Set from live request or from RequestSnapshot.
response response HTTP response (code, headers, body). Only set when the executor is built with a response (e.g. new_request_and_response, new_response, or logger with response).
jwt jwt JWT claims. Present when JWT auth is enabled and a token was verified.
apiKey api_key API key claims. Present when API key auth is enabled.
basicAuth basic_auth Basic auth claims (e.g. username). Present when Basic auth is enabled.
llm llm LLM context (streaming, models, provider, token counts, prompt, completion, params, etc.). Present for AI backends.
llmRequest llm_request Raw LLM request JSON. Present during LLM policies; often not kept for later stages (e.g. logging).
mcp mcp MCP resource (e.g. tool, prompt, resource with target/name). Present when the request is MCP.
backend backend Backend info: name, type (ai/mcp/static/dynamic/service), protocol (http/tcp/a2a/mcp/llm).
source source Downstream connection: address, port, TLS/identity fields (identity, subjectAltNames, issuer, subject, subjectCn).
extauthz extauthz Dynamic metadata from ext_authz filters.
extproc extproc Dynamic metadata from ext_proc filters.

Agentgateway CEL functions

  • contains — check containment
  • size — size of string/list/map
  • max, min — numeric max/min
  • startsWith, endsWith — string prefix/suffix
  • string, bytes, double, int, uint — type conversions
  • matches — string vs regex
  • optional.none(), optional.of(), optional.ofNonZeroValue()
  • value, hasValue, or, orValue (on optional values)
  • duration, timestamp
  • getFullYear, getMonth, getDayOfYear, getDayOfMonth, getDate, getDayOfWeek
  • getHours, getMinutes, getSeconds, getMilliseconds
  • json, jsonField — parse string/bytes as JSON (or single field)
  • to_json / toJson — value → JSON string
  • with — variable binding
  • mapValues, merge — map operations
  • variables — expose all variables (use with care)
  • random — float in [0, 1)
  • default — fallback when expression can’t be resolved
  • regexReplace — regex replace in string
  • fail — always fail expression
  • uuid — UUIDv4
  • base64Encode / base64.encode, base64Decode / base64.decode
  • charAt, indexOf, lastIndexOf
  • join, lowerAscii, upperAscii
  • trim, replace, split, substring
  • stripPrefix, stripSuffix
  • cidr("...").ip(), .masked(), .prefixLength(), .containsIP(...), .containsCIDR(...)
  • ip("...").family(), .isUnspecified(), .isLoopback(), .isLinkLocalMulticast(), .isLinkLocalUnicast(), .isGlobalUnicast()
  • isIP("...") — true if string is valid IP
  • flatten — flatten list or map for logging
  • flattenRecursive / flatten_recursive — recursive flatten
  • precompiled_matches — used when optimizing string.matches(regex) (not something you call directly in expressions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment