Prompts Are Code. Genkit Makes... Note

Prompts Are Code. Genkit Makes the Runtime Reviewable.

Prompts in a production environment differ significantly from those in a model playground, leading to potential failures. Genkit addresses this by integrating prompts with flows, schemas, tools, context, traces, and evaluations into a unified application model. Prompts should be stored as versioned artifacts using Genkit's Dotprompt format, encapsulating template content, model configuration, and schema definitions. This ensures prompt changes are reviewable in Git, and settings travel with the template.Prompts should be wrapped in typed flows, establishing application boundaries with stable names, validated inputs and outputs, and trace identity. This separation ensures pre-generation business rules and post-generation validation occur independently of the model's core function. Execution context, such as authentication tokens, should be passed via Genkit's context object, not interpolated into the prompt itself, enhancing security. Model output must be treated as untrusted data, with schemas validating parseability and other controls addressing claims, tone, and delivery.Genkit traces the entire flow, offering a view of operations, model calls, tools, and latent failures. This telemetry, based on OpenTelemetry, aids in debugging and observability. Changes should be evaluated against datasets, including various edge cases, to ensure the workflow meets its product contract rather than just matching individual sentences. Developers should deploy the entire flow, not just loose prompts, allowing for coordinated rollbacks, consistent evaluation, and secure deployment. Ultimately, the complete workflow, encompassing prompts, flows, context, tools, schemas, traces, and evaluations, forms the maintainable product.