anomalyco / anomalyco/opencode

Cloudflare REST route ignores AI Gateway control options

Open
#45,295 0 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 26, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

When OpenCode is routed through Cloudflare's AI Gateway using the REST (/workers/ai/v1/...) route, AI Gateway control options (cacheTtl, cacheKey, metadata, cacheStatus, etc.) configured via provider.cloudflare.options are dropped. The OpenAI-compatible chat route applies them, but the REST branch constructs its request without forwarding the gateway control headers, so caching/metadata policies are silently ignored on that path.

Expected

Both the OpenAI-compatible and REST Cloudflare routes honor the same options (gateway id, account id, api key, and control options) and attach the corresponding cf-aig-* control headers.

Actual

packages/opencode/src/provider/provider.ts builds the REST request body and URL but does not include the aiGateway* control parameters that the OpenAI-compatible branch (aiGateway) forwards. Requests through the REST route therefore never carry cf-aig-cache_ttl / cf-aig-metadata / etc.

Environment

  • opencode version: dev
  • provider: cloudflare with options.accountId/gatewayId/gatewayApiKey and any cf-aig-* control option, using the REST endpoint

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.