feat(agent): route the agent through a Cloudflare AI Gateway on Kimi#270
Open
saada wants to merge 1 commit into
Open
feat(agent): route the agent through a Cloudflare AI Gateway on Kimi#270saada wants to merge 1 commit into
saada wants to merge 1 commit into
Conversation
Swap the agent's Google Gemini CLI backend for a direct OpenAI-compatible chat call routed through a Cloudflare AI Gateway, defaulting to the fast kimi-k2.5 model. The gateway is one place to observe and cost-control every model call. - add util.ai-gateway: an OpenAI-compatible client for the gateway's compat endpoint, with a configurable custom-provider route (Moonshot by default) and an optional Authenticated Gateway header - rewrite the agent as a chat responder: drop the headless gemini CLI, the generated yetibot-tool.py tool bridge, the scratch workdir, and the GitHub App token minting that existed only to authenticate the CLI's git pushes. The agent no longer opens PRs on its own. - agent config moves to [:agent] (model defaults to kimi-k2.5); gateway credentials live under [:cloudflare :ai-gateway] - the agent keeps drawing from the shared monthly budget; its per-run weight drops to a Kimi-sized estimate ($0.05) so the $5 pool isn't spent in a handful of runs Image and video generation are unchanged and still call Google directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
agentcommand now answers with a fast Kimi model (kimi-k2.5),reached over a Cloudflare AI Gateway instead of the headless Google Gemini
CLI. The gateway is a single place to observe and cost-control every model call,
and lets us swap upstream providers by config.
Why
We wanted the agent off Gemini and onto a fast Kimi model, with all of its
traffic flowing through one gateway for visibility and spend control — without
standing up per-provider plumbing.
Changes
util.ai-gateway(new): an OpenAI-compatible client for the gateway's…/compat/chat/completionsendpoint. Configurable custom-provider route(Moonshot by default), Bearer auth for the upstream key, and an optional
cf-aig-authorizationheader for an Authenticated Gateway.commands.agent: rewritten as a chat responder over the gateway. Drops theheadless
geminiCLI, the generatedyetibot-tool.pytool bridge, the scratchworkdir + sweep, and the GitHub App token minting that existed only to
authenticate the CLI's
gitpushes.[:agent](:modeldefaults tokimi-k2.5); gatewaycredentials live under
[:cloudflare :ai-gateway]. The old[:gemini :agent :model]is still honored as a fallback.drops to a Kimi-sized estimate (
$0.05) so the$5pool isn't spent in ahandful of runs.
Behavior change
The agent no longer opens pull requests or runs
gh/git— a chatcompletion has no autonomous tool-use loop. It now answers questions, writes
code, reviews, and debugs in-thread.
Image (
banana) and video (veo) generation are unchanged and still callGoogle Gemini directly.
Config to set before use
:agent {:model "kimi-k2.5"} :cloudflare {:ai-gateway {:account-id "…" :gateway-id "…" :provider "custom-moonshot" :api-key "…"}} ; Moonshot keyCreate an AI Gateway with a Moonshot custom provider (base URL
https://api.moonshot.ai/v1); the provider route prefix iscustom-<name>.Testing
lein testfor the touched namespaces is green:util.ai-gateway,commands.agent,util.gemini, pluscommands.banana/commands.veo(sharedbudget ledger). A live
!agentsmoke test needs a provisioned gateway + key.