Grenat, a new compiled programming language designed specifically for AI agent systems, has emerged with a radical premise: prompt injection should be a compile-time error, not a runtime surprise. Built with Ruby-like syntax and Rust-level performance, Grenat treats prompts, tools, and agents as first-class citizens within a typed actor model. The project, hosted on GitHub by user itsmedit, aims to solve the fragility of current LLM integration by enforcing strict effect systems and data validation at the language level.
Treating Prompts as Typed Functions
The core innovation in Grenat is the prompt keyword, which defines a function that a model must implement. Unlike traditional string concatenation, these prompts return structured types, such as ~Summary, which the compiler enforces. Any output from a model is initially marked as untrusted (~T) and must be explicitly checked, approved by a human, or trusted before it can reach network calls or file systems. If a modelβs output fails validation, grenat check throws error E0412, preventing malformed data from propagating through the application.
Agents as Supervised Actors with Budgets
Grenat implements agents as supervised actors that operate within strict budgets for both time and currency. For example, a Support agent can be defined with budget usd: 0.50, time: 2.min and max_turns 12. The language enforces these limits at runtime, ensuring that runaway loops or expensive model calls do not drain resources. Tools, such as read_page or open_ticket, are also typed functions that declare their effects (e.g., uses fs.read, uses net), allowing the compiler to verify that an agent has the necessary permissions to perform an action before execution begins.
Durable Workflows and Native Performance
Beyond individual agents, Grenat supports durable workflows where each step is journaled. If a process crashes or waits days for human approval, the system resumes exactly where it left off without re-billing model calls. Performance is handled by a Cranelift JIT compiler, which compiles numeric and string operations to machine code, achieving speeds comparable to Rust. The language also includes native support for embeddings and semantic search, allowing developers to define Vector fields and perform nearest-neighbor queries directly within the database abstraction layer.
Key Takeaways
- Prompt injection is treated as a type safety issue, catching errors at compile time.
- Agents are supervised actors with enforced USD and time budgets.
- The language features a Cranelift JIT for near-native performance.
- Durable workflows ensure no double-billing for model calls after crashes.
The Bottom Line
Grenat is a bold attempt to bring static typing discipline to the chaotic world of LLM agents, potentially saving developers from the endless loop of prompt debugging.