Genkit Flows on Kubernetes: Senro Steps Driven by a Decision Model
We move the Genkit flows from the previous post into Kubernetes as senro steps, and on the Go side we use a generative model together with a model that makes decisions.
Foundation from the previous post
In the previous post, I explained how to place Genkit flows inside senro steps. This made it possible to get retries, caching, and event streaming for every model call. However, all the steps in that post ran on a single machine, the developer's own computer. In this post we change two things: we move the steps onto Kubernetes, and we add a second model type to the flow.
Moving the steps to Kubernetes
Moving from local execution to a cluster environment changes less about where the steps run and more about how they find each other and what happens when something fails. When you package each step as a separate process and run it in its own pod, scaling and restart decisions are left to the platform. The remaining real questions are: where will the intermediate state between steps be written, and when a step fails, how can the flow resume from where it stopped? These questions immediately come up in a cluster for a design that caused no problems locally.
Gemini writes, jev decides
There are two different models at the center of the flow. The first is Gemini, which is responsible for generating text. It writes responses, produces summaries, and creates content. The second is jev, and it is the main subject of this post. jev does not generate text. It takes a state, asks typed questions about it, and answers each question with a probability. Since its answers arrive in the order of a few hundred milliseconds, it seems sensible to use it at a branching point in the flow that is repeated often.
The practical benefit of this separation is that you do not have to ask the same model both "what should we write?" and "which path should we take?" The generative model can be both slow and expensive. The decision model, since it performs classification and scoring, can handle this job more cheaply and quickly. In the end, the flow gains a short checkpoint that decides which step will run.
What a decision looks like in Go
Genkit Go 1.14 gives access to jev through the System One plugin. A decision is written as a single genkit.GenerateData call, and a set of questions is supplied as the output type. In other words, instead of asking the model for free text, you define a Go structure in which each field corresponds to a question. The returned value is the filled-in form of that structure.
This approach has two consequences. First, the decision output is type-safe, so your code does not have to parse a text. Second, because the questions are explicitly stated in the code, it becomes easier to review what a decision is based on. There is a cost as well: the better the question set is designed, the more meaningful the decision will be. A carelessly written question set produces wrong routing, even with the fastest model.
Highlights
- The senro steps from the previous post can now run as separate processes on Kubernetes.
- While Gemini produces content, jev makes probabilistic decisions about the state; the two tasks are separated.
- jev answers typed questions with probabilities, and the answers come back within a few hundred milliseconds.
- Genkit Go 1.14 and the System One plugin reduce a decision to a single GenerateData call.
- Because the output type is a question set, the decision result is type-safe and inspectable.
When to use it
It is worth considering this approach if your flow has a frequently repeated, low-latency branching decision, and making that decision with a generative model feels both expensive and unnecessary. It is a good candidate if you can clearly define your questions and want to see the rationale behind a decision later. On the other hand, where the decision has no single correct answer, requires text generation, or where preparing the question set in advance is difficult, classic rules or a generative model alone may remain more suitable.
Comments (0)
No comments yet; be the first.
Leave a comment